discontinuity's Forum Posts

  • 2 posts
  • Hey,

    I have a global text variable (WhereAmI) that stores the name of a sprite. I want to be able to use this variable to refer to this sprite's instance variables. I can't figure out how this would work.

    For example, at the beginning of the game, WhereAmI is set to "Location1". The sprite Location1 has an instance variable of clue. I want to set a text object to contain the text from Location1.clue. Instead of referring directly to Location1, I want to use WhereAmI since I may want to pull clue from Location2 in another context. I can't use WhereAmI.clue, because the global variable WhereAmI has no instance variable clue.

    I thought about using an if statement, but it doesn't look like those are implemented? That's a suboptimal solution anyway, I think.

    In the end, I should probably store all this in an array or something and end up having to refer to Array[WhereAmI] or something. However, even if I do change the way I structure this particular action, using a variable to refer to a sprite seems like it could be useful.

    Thanks for your help!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'd appreciate this feature too! Thanks Ashley.

  • 2 posts