Use a loop with an accumulator variable. Example code:
function: attack ATTACK:d {
result: ATTACK
}
function: multiattack X:n Y:d {
TOTAL: 0
loop N over {1..X} {
DAMAGE: [attack Y]
TOTAL: TOTAL + DAMAGE
}
result: TOTAL
}
MULTIATTACK: 3
ATTACK: 2d10
output [multiattack MULTIATTACK ATTACK] named "[MULTIATTACK] attacks"
The "attack" function handles the resolution of an individual attack. In this case it's very simple, and just returns the die it is given.
The "multiattack" function is a helper function which handles calling the attack function a specified number of times. Note that you can take parameters here which the multiattack function itself does not care about and pass them on to the attack function, which does. It uses the accumulator variable, TOTAL, to track the total result of the attacks, and then returns it when all attacks are calculated.
The variable "N" is also available inside the scope of the loop. My example doesn't directly use it, but if you were modelling 3e D&D's iterative attacks, for instance, you could write logic using the value of N to apply the appropriate attack penalty depending on if it were the 2nd, 3rd, or 4th attack, for instance.
Then there's variables and the output statement which I hope are self-explanatory.