Hey,guys this is my first post.
I had a question that's giving me some trouble, I'm running a Shadowrun game and I need a macro that tells me the number of hits, a character got on a test and then compare it to the results of another characters test, and if either test got a glitch. Relatively easy, but I need a variable to store the number of hits, usually for this I would use the success() function for the number of dice that get a 5 or a 6, but success() does not allow me to account for the number of 1's, but the sr4()function tells me not just the number of hits and 1s but also of a roll is a glitch. So my question is for a variable X how do I make X equal to the number of hits, or if a roll is a glitch in a sr4() roll or any roll that returns more than one value.
Thank you very much for your help.
Assigning a variable to a specific roll result.
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
-
- Kobold
- Posts: 2
- Joined: Sun Oct 12, 2014 1:00 am
Re: Assigning a variable to a specific roll result.
I don't know how Shadowrun's exact mechanics are, but if I have understood what you need, you can use a count() roll option.
Code: Select all
[h: roll = "1d6"]
[h: numOfRolls = 5]
[h: numOfOnes = 0]
[h: numOfSuccesses = 0]
[h, count(numOfRolls), code: {
[h: evalRoll = eval(roll)]
[h, if(evalRoll == 1): numOfOnes = numOfOnes + 1]
[h, if(evalRoll >= 5): numOfSuccesses = numOfSuccesses + 1]
}]
1s: [r: numOfOnes]
<br>
Successes: [r: numOfSuccesses]
"There are many ways my Son, to find where the souls of Demons remain...
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."
Re: Assigning a variable to a specific roll result.
I'm not familiar with the system but after looking at the output of Xsr4gT dice expression I think I understand what you want.
The number of Hits is stored and hasGlitch is true or false.
Code: Select all
[H: abort(input("numDice|1|Number of Dice|Text","T|0|T value|Text"))]
[H: result = eval(strformat("%{numDice}sr4g%{T}"))]
[H: hitsRegex = "Hits: ([0-9]+)"]
[H: hits = getGroup(strfind(result,hitsRegex),1,1)]
[H: hasGlitch = getFindCount(strfind(result,"Glitch"))]
[R: result]
[R, if(hasGlitch): "<br>There is a Glitch"]
[R: strformat("<br>There are %{hits} hit(s)")]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
-
- Kobold
- Posts: 2
- Joined: Sun Oct 12, 2014 1:00 am
Re: Assigning a variable to a specific roll result.
thanks man that's great and pretty elegant also super easy.Irrlicht wrote:I don't know how Shadowrun's exact mechanics are, but if I have understood what you need, you can use a count() roll option.
Code: Select all
[h: roll = "1d6"] [h: numOfRolls = 5] [h: numOfOnes = 0] [h: numOfSuccesses = 0] [h, count(numOfRolls), code: { [h: evalRoll = eval(roll)] [h, if(evalRoll == 1): numOfOnes = numOfOnes + 1] [h, if(evalRoll >= 5): numOfSuccesses = numOfSuccesses + 1] }] 1s: [r: numOfOnes] <br> Successes: [r: numOfSuccesses]