I am trying to get an understanding some strange code behaviour.
In the example below I have removed a large amount of code for ease of explanation.
I have a macro called "TokenActions" that calls a macro called "DisplayMessage" for each token in its list.
I wanted to add a condition to only do this if the token was not dead.
Since in the original code, the foreach was imbedded within in an if statement, and the text output from the "DisplayMessage" macro was also imbedded in 2 conditional levels, I decided that the best way was to insert a macro ("IfNotDead") which does the check.
Unfortunately this does not work??
For 3 tokens, I should get 6 lines of output. But I only get 3 (from calling the "DisplayMessage" directly).
If I remove the if statement from "IsNotDead" and just leave "[macro("PDam@Lib:Miror"):id]", then I get all 6 lines of output.
Any ideas?
===TokenActions===========================================================================
Code: Select all
[h: cond = "{layer:["TOKEN"]}"]
[h: newlist=getTokenNames()]
[h: tokenList = ""]
[h, foreach(name, newlist, ""), code:{
[h: id = findToken(name)]
[if(getProperty("ObjectType", Id) == "PC-NPC"), CODE:{[h: tokenList = listAppend(tokenList, name)]};{}]
}]
[foreach(name, tokenList, ""), code:{
[h: id = findToken(name)]
[macro("IfNotDead@Lib:Miror"):id]
[macro("DisplayMessage@Lib:Miror"):id]
}]
Code: Select all
[h: id = macro.args]
[h: IsDead = 0]
[h, if(IsDead == 0),code:{ [macro("DisplayMessage@Lib:Miror"):id]};{}]
Code: Select all
<b>THIS IS A TEST<b><br>
Templar: THIS IS A TEST
THIS IS A TEST
THIS IS A TEST