I need to get a number from a list of text

Get help using Construct 2

Post » Tue Apr 23, 2013 1:13 pm

find(src, text)
Find the first index within src that text occurs, else returns -1.

I have slots in a list.

Slot = "Head,Chest,Gloves,Belt,Legs,Boots,Back,Ring1,Ring2,Neck"

I was under the impression that find(Slot,Gloves) would return 2 as a value, but instead of giving me Gloves position, it's giving me a total number of characters... TOTALLY not what I need.

Does anyone have a suggestion of how I could pull a number from a search into this list?
B
10
S
2
Posts: 20
Reputation: 1,142

Post » Tue Apr 23, 2013 1:57 pm

Use tokencount() and tokenat() expressions.

Something like this:

for 0 to tokencount(str, ",")-1
tokenat(str, loopindex, ",") = wantedStuff
.. do stuff, like set the current loopIndex into variable
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 11 guests