Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Working on a specific Macro

1481720501
Matthew C
Pro
Sheet Author
Hey guys, I am trying to get a macro or calculation however you want to call it in my character sheet. The idea is that it is based on a value of 1-10. The value should be 5+(value-5) which is easy to do, however I do not want the value-5 to ever go below 0. The idea behind this is that you get an extra 1 for every point above 5. Is there a way to do this? my current command is input style=width:30px type="text" name="attr_Energy_Base" value='@{Agility_Total}+(min="0"@({Agility_Total}-5))' disabled/ Maybe I am going about it wrong, but I cannot seem to get a minimum of 0 anywhere
1481722661

Edited 1481722775
If you check out  Group Rolls , you can use it for the intended purpose that you are looking for. The problem is that it cannot due the comparison without some dX in the formula but you can get around this by inserting a 0d0 in the statements.  Here is the code for your example   [[{0d0,@{Agility_Total} - 5 + 0d0}kh1]]
1481723089
Matthew C
Pro
Sheet Author
Hey Kyle, for rolling this is perfect, the problem I am having is implementing this into a character sheet. The idea is to have a value based on this number. If this does work like that could you give me the full line of text because just adding that code breaks it
1481734563
vÍnce
Pro
Sheet Author
Might just be a typo in your post, but try this. (note the left  ' ( ' location) @{Agility_Total}+ (min="0" ( @{Agility_Total}-5) )
1481736088
Matthew C
Pro
Sheet Author
'5 + (min="0" ( @{Agility_Total}-5) )' No matter how I do this, it still does not work :( The point is to have a base of 5 and then add 1 point for each point above 5 agility. So the macro makes sense, it just doesn't work
1481737441

Edited 1481737611
vÍnce
Pro
Sheet Author
I only tested  @{Agility_Total}+ (min="0" ( @{Agility_Total}-5) ) in chat with a slight modification/simplification for the attributes.  (substituted 3 for the attributes and used inline rolls...) [[ 3+(min="0"(3-5)) ]]  which resulted in "3" as expected.  So I think your macro is fine. Maybe try adding () around the value of your input value=" ( @{Agility_Total}+ (min="0" ( @{Agility_Total}-5) ) )" What output are you seeing for @{Energy_Base} ?
1481738580
Matthew C
Pro
Sheet Author
( @{Agility_Total}+ (min= This is what the output is showing me
This has nothing to due with your problem but why are you doing 5 + (min="0" ( @{Agility_Total}-5) ), if you can get the min functionality to work, why not do (min="5"(@{Agility_total}) ) and save some calculation?
1481741962
Matthew C
Pro
Sheet Author
uhm, never thought of that but (min="5"(@{Agility_total})-5 ) would be exactly what I need....
1481742107
Matthew C
Pro
Sheet Author
(min= this is what I end up with now, so there is something with the min that screws up everything....what are we missing? XD
1481742263

Edited 1481742642
vÍnce
Pro
Sheet Author
Using min(A, B) for (((@{A} + @{B}) - abs(@{A} - @{B})) / 2) this should work (((@{Agility_Total} + (5)) - abs(@{Agility_Total} - (5))) / 2) also in the initial formula above, input type should be "number". here's my test case <span><label>Agility Total: <input style=width:150px type="number" name="attr_Agility_Total" value="0" /> </label> </span> <span><label>Energy Base: <input style=width:150px type="number" name="attr_Energy_Base" value="(((@{Agility_Total} + (5)) - abs(@{Agility_Total} - (5))) / 2)" disabled="true" /> </label> </span> <span><label>Energy Base Output: <input name="attr_eb_total" type="number" value="(@{Energy_Base})" disabled="true" /> </label> </span>
1481742785

Edited 1481743013
Matthew C said: I do not want the value-5 to ever go below 0. Shouldn't you be using the formula for max (A, B), then? i.e. (((@{A} + @{B}) + abs(@{A} - @{B})) / 2)
1481743260

Edited 1481743602
Matthew C
Pro
Sheet Author
Sorry, I think it was not clear what I meant :p I mean that agility is a value of 1-10. The point is to get an extra point of energy for every point ABOVE 5 (hence the -5) but not to lose anything under 5 (hence the minimum of 0) although it would mke more sense to just have the minimum set at 5...It is hard to explain exactly what I mean XD The ABS one cannot work as that would simply turn any negative into a positive version of it....I basically want Agility-5 where agility is 1 to 10 and I want 1 to 5 to simply be 0
You mean this, presumably: Agility Energy_Base Bonus 1 0 2 0 3 0 4 0 5 0 6 1 7 2 8 3 9 4 10 5 This corresponds to the maximum value of Agility minus 5 and 0, which can be expressed using [[ {@{Agility} - 5, 0}kh1 ]] in-game, within a roll, or ((@{Agility} - 5 + abs(@{Agility} - 5)) / 2) within an autocalculated (disabled) Attribute.
1481744707
Matthew C
Pro
Sheet Author
@Sil that is exactly what I mean, unfortunately the code is giving me 0 no matter what I make the value of Agility, am I doing something wrong?
1481745345
vÍnce
Pro
Sheet Author
(((@{Agility_Total} + (5)) + abs(@{Agility_Total} - (5))) / 2)
1481745569
Matthew C
Pro
Sheet Author
Vince you my friend are a genious, as is everyone else that was trying to help that last one works perfectly. THANKS!!!!
1481745634

Edited 1481745685
vÍnce
Pro
Sheet Author
Kyle and Silvyre did all the work. and Brian, whom I lifted the min max formulas from  ;-P
1481751315
Matthew C
Pro
Sheet Author
well as I said everyone that tried to help is awesome, you figured out how to get it to work for me and the others are awesome for the work. I cannot wait for this character sheet to be done, because some serious blood and sweat is going in to it :D
1481791214

Edited 1481791651
Matthew C
Pro
Sheet Author
Guys I come to you with part two (and final part) of this macro, I thought I could work it out, but I cannot. (((@{Agility_Total} + (5)) + abs(@{Agility_Total} - (5))) / 2) Using the above gives me the perfect result for value-5 min=0 The full macro for a skill is (Attribute-5)(this one is allowed to go below 0)*5 + (Attribute-5)(min=0)*5 (The work you guys did for value-5 min=0 was not for nothing that was used in a different part of the sheet. But no matter where I add the extra lines of code it screws it up, either I end up with the *5 supercedes everything or I just end up with the code showing. (((@{Agility_Total} + (5) * (5)) + abs(@{Agility_Total} - (5) * (5))) / 2) I believe does half of it, but it is the first half I am struggling with.
Matthew C said: (((@{Agility_Total} + (5)) + abs(@{Agility_Total} - (5))) / 2) Using the above gives me the perfect result for value-5 min=0 This is actually 5 + the maximum of Agility - 5 and 0, not simply the maximum of Agility - 5 and 0. i.e. "5 + value-5 min 0": (((@{Agility_Total} + (5) ) + abs(@{Agility_Total} - (5))) / 2) = (@{Agility_Total} + 5 + abs(@{Agility_Total} - 5)) / 2 = (@{Agility_Total} - 5 + 10 + abs(@{Agility_Total} - 5)) / 2 = 10/2 + (@{Agility_Total} - 5 + abs(@{Agility_Total} - 5)) / 2 = 5 + (@{Agility_Total} - 5 + abs(@{Agility_Total} - 5)) / 2 (Which is what you said you wanted in your original post, so that's good!) So, (@{Agility_Total} - 5 + abs(@{Agility_Total} - 5)) / 2 is what we should be working with here. (Attribute-5)(this one is allowed to go below 0)*5 (@{Agility_Total} - 5) * 5 (Attribute-5)(min=0)*5 That would be (@{Agility_Total} - 5 + abs(@{Agility_Total} - 5)) / 2 * 5
1481796923

Edited 1481797204
Matthew C
Pro
Sheet Author
NVM ((@{Agility_Total} - 5) * 5) + (@{Advantage_Total} - 5 + abs(@{Advantage_Total} - 5)) / 2 * 5 This did exactly what I needed, thanks again :D