Iterating over character traits

The place to post your WML questions and answers.

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.
Post Reply
Zolm
Posts: 29
Joined: May 18th, 2012, 1:30 am

Iterating over character traits

Post by Zolm »

Guys, another question. What's wrong here?

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}
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.
User avatar
Pentarctagon
Project Manager
Posts: 5526
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Iterating over character traits

Post by Pentarctagon »

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
Zolm
Posts: 29
Joined: May 18th, 2012, 1:30 am

Re: Iterating over character traits

Post by Zolm »

Thanks pal.
Post Reply