Rolisteam/DiceParser

Macro Assisstance

Nikhil-Kurien opened this issue · 1 comments

So I'm looking to specify a complicated expression using a macro, only the problem is I'm not quite sure how to specify a particular variable in the following expression using a macro.

!1d100;$1i[<10]{70-$1}{$1};$2|10;$1i[<70]{"$1, success! Degrees of Success: $3"}{"$1, failure! Degrees of Failure: $3"}

The one I want replaced with a user definable variable is the wherever the number 70 appears above. Any assistance would be greatly appreciated.

Try something like this (I created 2 macros to test skills and weapon skills in WFRP):

!macro add a([0-9]+) "\1;1d100;# your code goes here #" True

That way, every number that user puts after "!a" i caught by parentheses and then referred by \1 in the first line. That \1 is then positional parameter $1 that you use in the rest of your code.

Here is my code with comments to know what's going on in this madness: https://github.com/pszeptynski/DiceParser-macros/blob/master/wfrp4ed_test_weapon_skill.dsmacro