Instance Variables for Instances Variables?

0 favourites
  • 10 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I completely jest. LOL

    I was thinking how I have this patrol system for my enemies to follow. Depending on the frame of the object, its two instance variables will have different values. Then, on top of that, I need to check at what times those values are accessed. If one is accessed, it should be "turned off", so it can't be accessed again. Kind of like a "Trigger Once" condition. Then, on another pass, the previously "off" instance variable would be "turned on", and the other back to "off".

    In a sense, I guess my thought is something akin to making certain variables temporarily "non-existent", similar to how groups or behaviors can be enabled or disabled.

    So, maybe I'm not totally joking. LOL I do realize the practicality of making such a feature would perhaps be more trouble than its worth.


  • Make another instance variable that is set when you access one of the object's other instance variables?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • <img src="" border="0" />

  • Jase00 - Aw, dude, that was so sweet! :) LOL

    Excal - That's essentially what I'm doing now. I started this post as a kind of joke, but then got to thinking as I typed it that it a functional idea. Heh, but I'm sure Ashley would agree with you.

  • LOL

  • I'm guessing coordinates in the instances?

    What about 1 string instance, and 1 number instance to tell which tokenat is next in that string instance?

    for example:


    CoordinateX = tokenat(tokenat(InstaceString,InstanceNumber,"|"),0,",")

    CoordinateY = tokenat(tokenat(InstaceString,InstanceNumber,"|"),1,",")

    If instanceNumber=0 it will use the first set, if it's 1 it uses the second. (and if it's a top down game, you could have as many waypoints as you like.)

    edit: You mentioned frame dependence, the Number instance could actually be the frame number.

  • a variable inside a variable would basically be an array or struct, etc...

  • Yeah, and you can put a variable in an array in a hash table in another variable in a -

    (Resists temptation to post an inception 'we need to go deeper' image)

  • Paradox I just found about about TokenAt this week and omg, wish I knew about it sooner. Would have saved me SO much trouble and variables that do basically nothing until a very specific condition is met.

  • Yeah, they are one of my favorite tricks. You can use them as mini-arrays, break strings into words at the spaces, or make overly complex nests of variables, making <font color=blue>the dream of instance variables in instance variables</font> a possibility.

    The more you play with it, the more you will find it can do. A sentence that fits most "favorite" things.

    Edit: andreyin

    Next day edit:

    And for those of you searching for a way to port real old games and need Data Statements, ("Read data") TokenAt() is for you.


Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)