The casting macros I currently use, work like this, and each saves to the on-token attribute of Spell0, Spell1, etc.:
Code: Select all
[h: status=input("cast|0|Spells Cast")]
[h: abort(status)]
[h: abort(cast)]
[h: mySpell1 = listGet(Spell1, 0, " of")]
[h: mySpell1 = mySpell1 - cast]
[h: MaxSpell1 = listGet(Spell1,1," of")]
[h: Spell1=listReplace(Spell1,0,mySpell1," of")]
[h: IsOut = if(mySpell1 < 1, 1, 0)]
<b>[r: token.name] has cast [r: cast] level 1 spell!</b>
{if(IsOut, "<br><span style='color:red'>I'm out of 1st level spells!!</span>", "")}
Code: Select all
[h: spells = "0,1,2,3,4,5,6,7,8,9"]
[h: status=input(
"Spell|"+spells+"|Select Spell|LIST|Value=INDEX",
"junkvar|-|Select Modifiers|LABEL",
)]
[h: abort(status)]
[h: spell_select = listGet(spells, Spell)]
[h: mySpell = listGet(Spell + spells, 0, " of")]
[h: mySpell = mySpell - cast]
[h: MaxSpell = listGet(Spell + spells,1," of")]
[h: Spell=listReplace(Spell + spells,0,mySpell," of")]
[h: IsOut = if(mySpell < 1, 1, 0)]
<b>[r: token.name] has cast a spell!</b>
{if(IsOut, "<br><span style='color:red'>I'm out of this level of spells!!</span>", "")}