I've got a set of macros set up that work fine on the Token level, but I can't seem to get it to work on the Campaign macro level and I'm not sure if it's just because it uses a Lib: token and that's just a known limitation of Lib: tokens.
This is the Token/Campaign level macro:
Code: Select all
[h: defineFunction("CAT_Pickup", "CAT_Pickup@Lib:SpaceHulk")]
[h: switchToken(getSelected())]
[h:isCAT=state.CAT]
[if(Side=="SpaceMarines" && isCAT == 0), code:
{
[h:setState("CAT", 1)]
[h: CAT_Pickup()]
<b>[r:getSelectedNames()] picked up the CAT</b>
};{}]
[if(Side=="SpaceMarines" && isCAT == 1), code:
{
[h:setState("CAT", 0)]
<b>[r:getSelectedNames()] droppped the CAT</b>
[h: UNITS_CELLS = 0]
[h: marine = currentToken()]
[h: x = getTokenX(UNITS_CELLS, marine)]
[h: y = getTokenY(UNITS_CELLS, marine)]
[h: updates = json.set("", "x", x, "y", y, "useDistance", UNITS_CELLS)]
[h: copyToken("CAT", 1, "Tokens", updates)]
[h: setState("CAT", 0)]
[h:switchToken("CAT")]
[h: sendToBack()]
};{}]
Code: Select all
[h: switchToken(getSelected())]
[h: areaOffsets = '[ {x:0, y:0}]']
[h: area = json.set("{}", "offsets", areaOffsets)]
[h: cond = json.set("{}", "area", area, "npc", 1, "unsetState", "['Dead']")]
[h: ids = getTokens("json", cond)]
[r,foreach(id, ids, "<br>"),CODE:
{
[h:switchToken(id)]
[if(Side == "CAT"), code:
{
[h:removeToken("CAT")]
};{}]
}]
I've tried inserting [h: switchToken(getSelected())] in a number of places to make sure the selected token is the impersonated token to get it to work, but it doesn't seem to matter. This code works fine on the Token macro level, but does not work on the Campaign macro level. Can anybody see what I'm missing in this that is generating the "Error executing "getTokens": there is no impersonated token" error?