Page 2 of 2

Re: Modfiy to add advantage/disadvantage

Posted: Wed Aug 16, 2017 5:09 pm
by Xaelvaen
I have no clue about the error you're getting, sorry Dorpond =/ I'm not by any means 'pro' like these guys at clean and simple scripts, but I saw your question and had just recently coded that into my 5E framework so thought I'd drop in the same lines I used for my prototype. I usually try to just get it working, then spend weeks cleaning it up with little snippits of code samples I see these guys posting all over the forums XD

I did test this in 1.4.1.7 and it seemed to function just peachy. Hope you get it worked out - with these guys helping, I'm sure you will =)

Re: Modfiy to add advantage/disadvantage

Posted: Thu Aug 17, 2017 10:05 am
by dorpond
Xaelvaen wrote:I did test this in 1.4.1.7 and it seemed to function just peachy. Hope you get it worked out - with these guys helping, I'm sure you will =)
I appreciate your help - thank you!

I think your code is a result of coping and pasting from the forums (or something like that), so could you please upload your code in a txt file? I would really like to see how yours works. Thanks!

Re: Modfiy to add advantage/disadvantage

Posted: Thu Aug 17, 2017 10:11 am
by dorpond
SOLUTION: with the help of many up here, we were able to get this working. The solution depends on Bag of Tricks for it to work properly. Thank you guys!

I attached the code below.

I would also love to get Xaelvaen's version working also, which doesn't depend on BoT, if for any reason, just to learn and understand more.

Xaelvaen, could you put your code into a txt file like Aliasmask did, to see if it is the copy paste issue from the forum? Much appreciated!

Code: Select all

<!-- set some basic values -->
[H: saveDC = 0]
[H: tokenList = getSelected()]
[H: statNameList = "STR,DEX,CON,INT,WIS,CHR"]
[H: advantageColorCode = "black,blue,red"]
[H: output = ""]

<!-- get user input -->
[H: abort(input("saveDC|0|Enter Save DC|TEXT",
    "rollAdvantage|No Advantage,Advantage,Disadvantage|Select Advantage|RADIO|ORIENT=H",
    strformat("statName|%{statNameList}|Choose Stat Save|RADIO|VALUE=STRING"),
    "outputType|all,self,gm|Output to Who?|RADIO|SELECT=1 ORIENT=H VALUE=STRING"
))]

<!-- get token data, rolls and saving throw modifier -->
[H, foreach(tokenId,tokenList), code: {
    [H: switchToken(tokenId)]
    
    <!-- get advantage roll -->
    [H: saveRoll = 1d20]
    [H, if(rollAdvantage == 1): saveRoll = max(1d20,saveRoll)]
    [H, if(rollAdvantage == 2): saveRoll = min(1d20,saveRoll)]
    
    <!-- get token stat save roll modifier. note: token name is not case sensitive -->
    [H: statModifier = getProperty(statName+"Save")]
    
    <!-- calc total -->
    [H: rollTotal = statModifier + saveRoll]
    [H: rollColor = listGet(advantageColorCode,rollAdvantage)]
    
    <!-- set state DCFail value. Probably shouldnt do it here, but its easier -->
    [H, if(rollTotal < saveDC): state.DCFail = 1; state.DCFail = 0]
    
    <!-- save output for each token -->
    [H: output = json.append(output,strformat('%{token.name} makes a %{statName} Save and gets a <span title="Roll: %{saveRoll}; Mod: %{statModifier}"><b color="%{rollColor}">%{rollTotal}</b></span>.'))]
}]

<!-- Display Output -->
[H: broadcast(json.toList(output,"<BR>"),eval("bot_"+outputType+"()"))]

<!-- you can remove this line if you make a function of this with hidden output, or you can remove all the comments for final macro -->
[H: abort(0)] 

Re: Modfiy to add advantage/disadvantage

Posted: Thu Aug 17, 2017 3:34 pm
by Xaelvaen
Their code is highly likely to be superior, but here's the .txt as you've requested. Glad you got it working =D

Re: Modfiy to add advantage/disadvantage

Posted: Fri Aug 18, 2017 12:05 pm
by dorpond
That worked like a champ, Xaelvaen, thanks!!

Thanks to all players for helping get through this! Much appreciated!

Re: Modfiy to add advantage/disadvantage

Posted: Fri Aug 18, 2017 2:34 pm
by Xaelvaen
You're very welcome. How is 5E working out for you? That's pretty much our classic fantasy go-to for tabletop (and Shadowrun Anarchy for anything non-traditional fantasy) - always happy to see others using it =)

Re: Modfiy to add advantage/disadvantage

Posted: Fri Aug 18, 2017 2:40 pm
by dorpond
Xaelvaen wrote:You're very welcome. How is 5E working out for you? That's pretty much our classic fantasy go-to for tabletop (and Shadowrun Anarchy for anything non-traditional fantasy) - always happy to see others using it =)
I've played all versions of D&D since 3.0 and hands down think 5e is the best of the bunch. :)

Re: Modfiy to add advantage/disadvantage

Posted: Sun Aug 20, 2017 11:13 am
by Xaelvaen
Couldn't agree more, though I played 2nd edition as well, and it's still a close favorite. Cheers and happy gaming =)

Re: Modfiy to add advantage/disadvantage

Posted: Wed Sep 20, 2017 10:26 am
by StarMan
Got this working in my 4e (tried 5e once and found it too simplistic; wasn't happy there was no DDI) fw. Go to this page, scroll down to "The MacroPolicebox Group" and watch the last video (named "Toggles"). You can make your output private by using Silent Running Mode and do advantage/disadvantage with d20 Choice Mode.