Reference an object by string like "Name"&gSurname

Get help using Construct 2

Post » Sat Feb 02, 2013 3:21 pm


Can I reference an object by its name only?

I have several different level layouts, each one stored in a separate Text object. Like, text object Stage1 "floor,floor,leftwall,topwall,floor"; text object Stage2 "topwall, floor, leftwall, leftwall, floor"; text object Stage3 "topwall, topwall, topwall, topwall, leftwall".

Then I have another global variable int gChapter, that I increase whenever I finish some objective ingame.

I wish to have an event where I ask the system to set up the level according to the text stored in one of the text objects. The chosen text object is dependand on the currently set gChapter value.

Something like this:
tokenat("Stage"&gChapter.Text,loopindex,",")

This is driving me crazy. Can't I reference an object just by its name?

Thanks for reading, pls help!gamekill2013-02-02 15:21:51
B
10
S
2
G
3
Posts: 28
Reputation: 2,690

Post » Sat Feb 02, 2013 9:03 pm

How about System Pick nth Instance?

Where the nth instance is Chapter.

The first instance of your Text object would be 0 and increase in the order you created them.
B
12
S
4
G
2
Posts: 59
Reputation: 3,739

Post » Sat Feb 02, 2013 9:20 pm


David, that would be a workaround, yes. Thanks for the heads up.
But usind IIDs is not too reliable, I'd like to know if there's a more solid alternative to this.
B
10
S
2
G
3
Posts: 28
Reputation: 2,690

Post » Sat Feb 02, 2013 9:24 pm

Put your data into array and use gchapter to index y of the array. Each x value would hold the relevant stuff for the level.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest