Iterating over character traits
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Iterating over character traits
Guys, another question. What's wrong here?
Code to run through all traits of a stored character and identify if any of the traits has the defined ID.
The index "i" is working properly, I put some messages to verify, but it seems it never enters the if; the returned ID is always from the first trait the character has, and never advances.
Probably it's something stupid like I put the array index on the wrong place, but I cannot find what's wrong.
Thanks in advance.
Code: Select all
[store_unit]
variable=verifyChar
[filter]
id=Char
[/filter]
kill=no
[/store_unit]
{FOREACH verifyChar.modifications.trait i}
[if]
{VARIABLE_CONDITIONAL verifyChar.modifications.trait[i].id equals trait1}
[then]
{VARIABLE charHasTrait1 yes}
[/then]
[/if]
{NEXT i}
The index "i" is working properly, I put some messages to verify, but it seems it never enters the if; the returned ID is always from the first trait the character has, and never advances.
Probably it's something stupid like I put the array index on the wrong place, but I cannot find what's wrong.
Thanks in advance.
- Pentarctagon
- Project Manager
- Posts: 5526
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Iterating over character traits
It should be
[$i]
, not [i]
.99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code