Variables to refer to Object's names

Get help using Construct 2

Post » Tue Jan 29, 2013 5:26 am

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 !Tenshi2013-01-29 05:27:59
B
7
G
3
Posts: 46
Reputation: 1,581

Post » Tue Jan 29, 2013 6:48 am

This plugin might be some help in that scenario: http://www.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.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Wed Jan 30, 2013 2:13 am

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 ?

B
7
G
3
Posts: 46
Reputation: 1,581


Return to How do I....?

Who is online

Users browsing this forum: Matthew de and 21 guests