User functions are defined with the defineFunction() function. Once you have defined a function you can call it as you would call any of the existing functions, for example
attackRoll(Strength, -1). The
arg() function is used within the macro that is called to extract each of these arguments. The index of the first argument is 0.
argCount()function is often used in conjunction with
arg()to determine the number of arguments that have been passed to the user defined function.
index- The index of the argument to return. Indexes begin at
attackRoll()which accepts two arguments, which are attribute value and bonus you could call it in the following way.
Then inside the macro that implements the user defined function you can do the following.
[h: attr = arg(0)] [h: bonus = arg(1)] [r: 1d20 + floor(attr/2) + bonus]