This:

It's not giving me an error, the variables just poof on ready()... i don't understand what's happening here at all.
Can you just not store variables in arrays/dicts? Is that not possible?

  • xyz replied to this.
  • Mhh, i see now.

    After some experimenting, seems simply adding an @onready fixes it as well:

    Squiddy Assignments in the class body are actually executed in the same way the normal code is. If you define one and two before using them in array and dictionary definitions, their values will be there as expected.

    I guess it is a problem with the order of declarations? Try moving the bottom two variables above the other two.

    Note that you only store the value of one and two in your dictionary. You can not store variables in anything (nothing to do with the dictionary). You can only store the value of other variables in a variable. Depending on the type this value may be a reference. In this case (integer), it is not.

    Mhh, i see now.

    After some experimenting, seems simply adding an @onready fixes it as well:

    • xyz replied to this.

      Squiddy It does not "fix" it as there is nothing to fix. It will just postpone the assignment as if it's done in the _ready() callback. If you latter decide you need to have @onready for one as well - you'll have the same "problem". It's better to change the order of definition, so that dependent variables are written after their dependencies. Much cleaner and logical that way.