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

Problem with modulo | Problème avec le modulo

[EN] I have a problem with the modulo (the% symbol) in an ability. Instead of a thousand words I think the images will be more explicit. The macro :  here The result :  here As you can see. If it doesn't have the desired effect at all, either "[result_d4]% 2 + [result_d4]". In the example it should do as calculate: "2% 2 + 2" or "1 + 2" therefore return "3" in the chat. [FR] J'ai un problème avec le modulo (le symbole %) dans une abilité. Au lieu de mille mots je pense que des images seront plus explicites. Les images sont juste au-dessus, l'une pour le code de la macro et l'autre le résultat une fois lancé. Comme vous pouvez le voir. Si me fait pas du tout l'effet voulu, soit "[result_d4]%2+[result_d4]". Dans l'exemple ça devrait faire comme calcule : "2%2+2" soit "1+2" donc renvoyer "3" dans le tchat.
1628724622

Edited 1628724660
David M.
Pro
API Scripter
Unfortunately, you can't perform  any  math operations on re-used rolls. You would need to rearrange your rolls (if possible) to do the math inside of the inline brackets and display the results with the $[[n]] syntax. However, it is not immediately apparent to me how to do that exact calculation without using the api. Your last comment seems to be incorrectly calculating modulo. You say that 2%2+2 should be 3, but 2%2 is actually 0, giving a total result of 2. So, if you actually want the results to be this (based on your comment) die roll    fear damage 1            1 2            3 3            4 4            6 It seems to me that you could use an approach like this instead (using default template and not including your other rolls since I can't cut and paste from your image: &{template:default} [[floor([[1d4]]*1.5)]] {{name=re-use rolls example}} {{d4 roll = $[[0]]}} {{fear damage=$[[1]]}}
[EN] Indeed the modulo was not the right solution ^^ Sorry I misspoke: / But good news your code at the end works perfectly for me and does what I wanted !! I don't have a try a round(x) xD [FR] En effet le modulo n'était pas la bonne solution ^^ Désolé je me suis mal exprimé :/ Mais bonne nouvelle votre code à la fin fonctionne parfaitement chez moi et fait ce que je voulais !! J'ai pas un essayer un round(x) xD
1628786006
David M.
Pro
API Scripter
Great!