I want to have the following:
Common Event
SetXforXdY - X (number of dice)
SetYforXdY - Y (number of sides)
SetAPD - Adjustment Per Dice ... so (+APD)
SetAPR - Adjustment Per Roll ... so(+APR)
SetXDY - the dice to be used eg SetXforXdY D SetYforXdY
I managed to find this on the forums:
ROLL_FORMAT = /(\d+)[d](\d+)/i
def roll(n, sides)
result = 0
n.times {|x| result += rand(sides)+1 }
return result
end
def dice_roll(expr)
fn_call = expr.gsub ROLL_FORMAT do |match|
'roll(' + $1 + ',' + $2 + ')'
end
return eval(fn_call)
end
The call to that would be dice_roll(XDY)
I would probably have to adjust the formula also because it doesn't take into account the adjustment variables. ie APD and APR
What I need is a way so that an event like a treasure chest or some action can define and roll dynamically. Also it would need to take into account other variables.
Anyway I am hacking my way towards making something but can any of you give me a or provide a link to a royalty free dice rolling script?
Common Event
SetXforXdY - X (number of dice)
SetYforXdY - Y (number of sides)
SetAPD - Adjustment Per Dice ... so (+APD)
SetAPR - Adjustment Per Roll ... so(+APR)
SetXDY - the dice to be used eg SetXforXdY D SetYforXdY
I managed to find this on the forums:
ROLL_FORMAT = /(\d+)[d](\d+)/i
def roll(n, sides)
result = 0
n.times {|x| result += rand(sides)+1 }
return result
end
def dice_roll(expr)
fn_call = expr.gsub ROLL_FORMAT do |match|
'roll(' + $1 + ',' + $2 + ')'
end
return eval(fn_call)
end
The call to that would be dice_roll(XDY)
I would probably have to adjust the formula also because it doesn't take into account the adjustment variables. ie APD and APR
What I need is a way so that an event like a treasure chest or some action can define and roll dynamically. Also it would need to take into account other variables.
Anyway I am hacking my way towards making something but can any of you give me a or provide a link to a royalty free dice rolling script?