How to use object indexing

Get help using Construct 3!

Post » Fri Jun 02, 2017 11:38 am

Hi there,
I have an object 'MyObject' with an instance variable 'SomeValue'.
Within a loop I'm trying to get the value of the instance variable as follows:
MyObject(3).SomeValue
This doesn't work, because the C3 intellisense doesn't give me the option to choose a property after the dot.
What I am missing?
Thanks,
Ueli
B
21
S
5
Posts: 24
Reputation: 1,221

Post » Fri Jun 02, 2017 6:48 pm

I'm not sure exactly what's wrong here, because any Sprite.Value should always return the number of that value. Is your program not returning a value, do you not know how to access it, or is it something else?
B
3
Posts: 6
Reputation: 187

Post » Fri Jun 02, 2017 11:30 pm

C2 just did not autocomplete at all.
C3 auto completes with only system expressions. Guess that looks like a bug.

Work around it by first typing MyObject.SomeValue.
The type the (3) in between them to get MyObject(3).SomeValue (with auto complete)

But be aware of this. That value between the ( ) is the IID (it is in c2) for all items, whatever is picked.

Unless the loop runs trough ALL instances in the SAME order as they are created, it has no function.

-------------------------- <---- no pre-picking
For each MyObject <- runs trough them in creation order
Compare two values ... first = MyObject(loopindex).SomeValue =? second ... 5
Compare two values ... first = MyObject(loopindex + 1).SomeValue =? second ... 5
Compare two values ... first = MyObject(loopindex + 2).SomeValue =? second ... 5
__________ Actions

To test if 3 consecutive SomeValue's are = 5 ...
Works flawless.

This will not work

Is on Screen (MyObject) <-- prepick
System: For each MyObject order by MyObject.​X ascending <-- & wrong order
Compare two values ... first = MyObject(loopindex).SomeValue =? second ... 5
Compare two values ... first = MyObject(loopindex + 1).SomeValue =? second ... 5
Compare two values ... first = MyObject(loopindex + 2).SomeValue =? second ... 5
__________ Actions
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I...?

Who is online

Users browsing this forum: No registered users and 0 guests