I've written a series of macros for a library token that enable players and GMs to use. In order to do this, I modified zend0g's Exalted dice roller (
found here)
The library token was called Lib:roller and I ended up using HP for the number of dice rolled in a join battle, though both these can be changed.
Never to be used directlymyAction
Code:
[h: speed = json.get(macro.args,0)]
[h: currentInit = getInitiative()]
[h: roundInit = getInitiativeRound()]
[r, IF(currentInit == roundInit), code:{
<b>Finished !</b>
Action Speed: [r:speed]
[h: setInitiative(currentInit + Speed)]
[MACRO("SortInit@Lib:roller"): "TurnDone"]
};{
[assert(0, "<b>Not Your Turn</b>", 0)]
}]
NiceDisplay
Code:
[h: name = json.get(macro.args, 3)]
[h: Roll = json.get(macro.args, 2)]
[h: result = json.get(macro.args, 1)]
[h: successes = json.get(macro.args, 0)]
[h: colour =" "]
[h, IF(result==' Success!'): colour = "green"]
[h, IF(result==' BOTCHED!'): colour = "red"]
[r: name]: <b><font color="[r:colour]">[r:result]</font></b>[r: " "][t ("("+successes+")"):Roll]
Roller
Code:
[h: dataInLength = json.length(macro.args)]
[h: numDice = json.get(macro.args, 0)]
[h: difficulty = json.get(macro.args, 1)]
[h, IF(dataInLength >2), CODE:{
[h: explode = json.get(macro.args, 2)]
}]
[h: explode = "True"]
[h: i=0][h: diceArray='[]']
[h, while(i <numDice), CODE:{
[h: theRoll=1d10]
[h: diceArray=json.append(diceArray,theRoll)]
[h: i=i+1]
}]
[h: diceArray=json.sort(diceArray)]
[h: txtResult='']
[h: numSuccess=0]
[h: numFail=0]
[h: numFumble=0]
[h: diceResults="("]
[h,count(json.length(diceArray)), CODE:{
[h: thedie=json.get(diceArray,roll.count)]
[h,IF(thedie>=difficulty),CODE:{
[h: numSuccess=numSuccess+1]
}]
[h,IF((thedie==10)&&(explode=="True")),CODE:{
[h: numSuccess=numSuccess+1]
}]
[h,IF(thedie ==1),CODE:{
[h: numFumble=numFumble+1]
}]
[h,IF((thedie>=2)&&(thedie<difficulty)),CODE:{
[h: numFail=numFail+1]
}]
[h:diceResults = diceResults + " " + thedie]
}]
[h,IF(numSuccess>0), CODE:{
[h: txtResults=' Success!']
}]
[h,IF((numFumble>0)&&(numSuccess==0)), CODE:{
[h: txtResults=' BOTCHED!']
}]
[h,IF((numFail>0)&&(numSuccess==0)&&(numFumble==0)), CODE:{
[h: txtResults=' Failed!']
}]
[h:diceResults = diceResults + " )"]
[h:returnData = '[]']
[h:returnData = json.append(returnData, numSuccess)]
[h:returnData = json.append(returnData, txtResults)]
[h:returnData = json.append(returnData, diceArray)]
[h:macro.return=returnData]
SortInit
Code:
[h: argsLength = json.length(macro.args)]
[h: initLength = initiativeSize()]
[h: initTick = getInitiativeRound()]
[h: toDo = "Nothing"]
[h, IF(argsLength == 1), CODE:{
[h: toDo = json.get(macro.args, 0)]
}]
[h, IF(toDo == "Begin"), CODE:{
[h: setInitiativeRound(0)]
[h: initTick = getInitiativeRound()]
}]
[h, IF(toDo == "Next"), CODE:{
[h: initTick = initTick + 1]
[h: setInitiativeRound(initTick)]
}]
[h: sortInitiative()]
[h: setCurrentInitiative(initLength-1)]
[h: currentTokenID = getInitiativeToken()]
[h: switchToken(currentTokenID)]
[h: initTickAction = getInitiative()]
[h: initDiff = initTickAction - initTick]
[h: name = getName()]
[ IF(initDiff == 0), CODE:{
<br>
Time for <b>[r:name]</b> to kick donkey
[h: setInitiativeHold(0)]
};{}]
[ IF(initDiff > 0), CODE:{
<br>
Time til [r:name] is up: <b>[r:initDiff] Ticks</b><br>
Anyone moving this tick?
[h: setInitiativeHold(1)]
};{}]
[ IF(initDiff < 0), CODE:{
<br>
<b><font color="red">Hold Up !</font></b><br>
You skipped [r:name] ! Moving back...
[h: setInitiativeRound(initTickAction)]
};{}]
GM MacrosAdd PCs to Init (because it seems stupid not to have it)
Code:
[h: addAllPCsToInitiative()]
Setup Init
Code:
[h: initList = getInitiativeList() ]
[h: tokens = json.get( initList, "tokens" )]
[h, foreach(token, tokens),code:{
[h: tokenStr = json.toStrProp(token)]
[h: varsFromStrProp(tokenStr)]
[h: tokenInit = json.get(token, "initiative")]
[if(tokenInit==""), CODE:{
[h: joinBattle = getProperty("HP", tokenId)]
[h: jsonData = json.append(joinBattle, 7)]
[MACRO("Roller@Lib:roller"): jsonData]
[h: returnData=macro.return]
[h: successes = json.get(returnData, 0)]
[h: init = 6 - successes]
[h: init = max(0, init)]
[h: init = min(6, init)]
[h: switchToken(tokenID)]
[h: setInitiative(init)]
}]
}]
[MACRO("SortInit@Lib:roller"):"Begin"]
Next Tick
Code:
[MACRO("SortInit@Lib:roller"):"Next"]
Macros for Tokens to UseAction Performed (players call this and pass it the speed of their action)
Code:
[h: speed = ActionSpeed]
[MACRO("myAction@Lib:roller"): speed]
Exalted Roller (might as well include the interface for the roller)
Code:
[h: status=input(
"name|Roll|Name of Roll?",
"numDice|10|Number of dice?",
"difficulty|7|Target Number?",
"explode|True,False|Double 10s?|LIST|SELECT=0|VALUE=STRING"
)]
[h: abort(status)]
[h:jsonData = json.append(numDice, difficulty, explode)]
[MACRO("Roller@Lib:roller"): jsonData]
[h:returnData=macro.return]
[h:returnData=json.append(returnData, name)]
[MACRO("NiceDisplay@Lib:roller"): returnData]
I'm sure the code could be improved upon, anyway, hope it helps.