Aliasmask, actually, I think I do see a return value, but this is weird. If I'm passing '5D' (which means for this game to roll 5 dice), I get back a bunch of commas. If I'm passing 1D, I only get a pair of single quotes. macro.return is getting a number, but the calling macro is getting back punctuation!
Very weird. If you don't mind, I'll post the entire UDF here, which I've copied into a new macro named RollDice2:
Code: Select all
[h: skillCode = arg(0)]
[h: bWild = arg(1)]
[h: pips = 0]
[h: numDice = 0]
[h: totRoll = 0]
[h: ended = endsWith(skillCode, "D")]
[h, if (ended > 0 ), CODE: {
[h: numDice = substring(skillCode,0,length(skillCode)-1)]
[h: pips = 0]
};
{
[h: numDice = substring(skillCode,0,length(skillCode)-3)]
[h: pips = substring(skillCode,length(skillCode)-2), len(skillCode)-1)]
}]
[h: sDice = ""]
[h: totRoll = pips]
[h: newRoll = 0]
[h: highDie = 0]
[h: WildResult = 0]
[h: loops = 0]
[h: loops = numDice]
[h, if(bWild>0), CODE: {
[h: loops = numDice - 1]
[h: WildResult=d6e]
}]
[WHILE(loops > 0), CODE: {
[h: loops = loops - 1]
[h: newRoll = d6]
[h: sDice = sDice + "," + newRoll]
[h: highDie = if(newRoll > highDie, newRoll, highDie)]
[h: totRoll = totRoll + newRoll]
}]
[h: totRoll = totRoll + WildResult]
[if (getLibProperty("WildDieOne","Lib:Utility") == 2 && WildResult == 1), CODE: {
[h: totRoll = totRoll - 1 - highDie]
Wild Die was a 1; Your roll has been reduced by {1 + highDie}
}]
[if (getLibProperty("WildDieOne","Lib:Utility") == 3 && WildResult == 1), CODE: {
[g: "Wild Die was 1, but was included in total result. Introduce a complication!"]
}]
[h: macro.return = totRoll]