0 Favourites

Variables to refer to Object's names

  • Hi,

    I tried to find an answer on forum, but not sure what to type and found nothing helpful on it.

    I've got two objects :

    ArmyList1 and ArmyList2, they contain text.

    In events sheet, I've got : "find(ArmyList1.getTextSelected,"Example") = -1"

    I need the "1" in ArmyList1 to be a variable, to call the right object when event is triggered. How can I do that without getting an Construct 2 error ?

    (Same problem as inserting a variable in variable name)

    Thanks !

  • This plugin might be some help in that scenario: scirra.com/forum/plugin-nickname-behavior-nickname_topic57943.html

    But as for your problem, why not make two instances of 'ArmyList' object? Unless there is something radically different between those two, it seems like the best option to me in your case.

    Then you could call them like:

    Select all armyList

    armyList(0).variable = 2

    armyList(1).variable = 4

    Do note that you'll need to have all armyLists picked whenever using this method. You could also save their UID's and use them to directly pick individual lists.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • ArmyList1 and 2 are just two separate listboxes where I insert things depending on which one is selected while pressing a unique button. So your solution might work.

    Didn't know ArmyList(0) and ArmyList(1) was possible with multiple instances of the same object, thanks :)

    Now it's too late to make like that (too much time to change everything), but I'll make like that on my next app.

    But the question still remains ^^ there is no way to insert variables in object names like while coding ?

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