How do I Refer to a Instance Variable using an expression?

Get help using Construct 2

Post » Wed May 25, 2016 5:22 am

I know, poor title.
I'm wondering if it's in any way possible to refer to a variable based on a variable expression. For example I have a few variables, object_info_0, object_info_1 and so on...
I'm trying to put each variable's contents into a co-ordinate of an array but from what I've tried I can't write an expression anything like:

object_info_ & array.x

or something along the lines.
B
5
Posts: 9
Reputation: 237

Post » Wed May 25, 2016 6:01 am

You can store the variables values in the array and check the array value instead
B
22
S
4
G
3
Posts: 61
Reputation: 2,683

Post » Wed May 25, 2016 7:18 am

for "loop" 0 to object.count - 1
set aray(loopindex("loop")) to object(loopindex("loop")).X

or
for "loop" 0 to object.count - 1
pick object by nth (loopindex("loop"))
set aray(loopindex("loop")) to object.X

Eventualy you can make a previous pick above the loop.
like: pick objects who's instance variable is 1
then it runs only trough those objects
B
33
S
18
G
27
Posts: 2,436
Reputation: 20,336

Post » Wed May 25, 2016 4:38 pm

That's what I'm trying to do. I want to create a instance variable and them into the array.


Thanks but I was referring to local/global variables. Even if I referenced an object's instance variable I couldn't do something like:

object.instance_variable_ & loopindex

What I want to do is if I had variables named var_1, var_2, var_3 and so on I'd like to refer to each of those.
B
5
Posts: 9
Reputation: 237

Post » Wed May 25, 2016 4:44 pm

Image
Here's an example.

I want to set each X of an array to the value of these variables.
B
5
Posts: 9
Reputation: 237

Post » Wed May 25, 2016 6:37 pm

I have nothing to add to this:
https://www.scirra.com/tutorials/307/ar ... -beginners
at this point.
B
33
S
18
G
27
Posts: 2,436
Reputation: 20,336


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests