Call variable from self. in a inner class.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By FinFan

Hello again, sry for my stupidness.
I have variable in a script
enter image description here
I try to use variable from near of class, but can’t do that. I trying to find documentation where describes that situation but I failed.

Thank you so much for helping to noobs!

:bust_in_silhouette: Reply From: Eric Ellingson

I don’t believe you have access to that property inside your object class. I think the solution here would be to pass a reference to the outer class/object into your change method:

class Fsm:
    var state = EState.IDLE
    var substate = EState.IDLE

    func _init():
        print("fsm controllable")

    func change(newState, obj):
        state = newState
        match state:
            EState.MOVE:
                print("FSM: move")
                obj._is_moving = false
            EState.IDLE:
                print("FSM: idle")

then in your outer class, you can do:

var _is_moving = false
var fsm = Fsm.new()

func _ready():
    fsm.change(EState.MOVE, self)