Instance Variables for Instances Variables?

Discussion and feedback on Construct 2

Post » Tue Aug 20, 2013 10:03 pm

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.

Thoughts?
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
135
S
22
G
8
Posts: 770
Reputation: 14,689

Post » Tue Aug 20, 2013 11:04 pm

Make another instance variable that is set when you access one of the object's other instance variables?
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,224

Post » Wed Aug 21, 2013 12:31 pm

B
51
S
20
G
10
Posts: 571
Reputation: 9,819

Post » Thu Aug 22, 2013 4:02 am

@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 might...MIGHT...be a functional idea. Heh, but I'm sure @Ashley would agree with you.
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
135
S
22
G
8
Posts: 770
Reputation: 14,689

Post » Thu Aug 22, 2013 10:46 am

LOL
B
10
S
2
G
1
Posts: 77
Reputation: 1,278

Post » Thu Aug 22, 2013 11:21 am

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:

InstanceString="203,245|381,45"

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.Paradox2013-08-22 11:24:28
B
226
S
60
G
33
Posts: 902
Reputation: 39,989

Post » Thu Aug 22, 2013 6:08 pm

a variable inside a variable would basically be an array or struct, etc...
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,573

Post » Thu Aug 22, 2013 8:15 pm

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)
Moderator
B
94
S
33
G
33
Posts: 3,006
Reputation: 27,744

Post » Fri Aug 23, 2013 4:28 am

@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.

B
122
S
42
G
40
Posts: 846
Reputation: 27,994

Post » Fri Aug 23, 2013 7:21 am

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 the dream of instance variables in instance variables 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.

DATA STATEMENT (tag)Paradox2013-08-23 22:59:30
B
226
S
60
G
33
Posts: 902
Reputation: 39,989

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 7 guests