Reference an object by string like "Name"&gSurname

0 favourites
  • 4 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • 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!

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

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

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