Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Random Variables?

11 years ago

How do I do those? Do they even exist?

Random Variables?

11 years ago

To use Random Variable, you need to Use Scripting.

Say you have a Variable to represent a d20 and one to represent a d6. You 'Roll' them with the Scripting as such:

D20 := 1D20
D6 := 1D6

IF D20 > 15 THEN
BEGIN
DMG := 5 + D6
HP := HP - DMG
END

IF HP < 1 THEN
DEST := @P200

Random Variables?

11 years ago

In case you're confused, him saying "1D6", will return a value between 1 and 6 (1 dice rolled with 6 sides).

2D6 would return a value between 2 and 12 (2 6-sided dice rolled)

His D6 and D20 are actual variables he created to store the random value, you could just as easily do:

IF 1D20 > 15 THEN
BEGIN
DMG := 5 + 1D6
HP := HP - DMG
END

IF HP < 1 THEN
DEST := @P200

(Unless the scripting system dislikes comparisons with dice rolls)

Random Variables?

11 years ago

Good point, you don't need the Variable at all, unless you want to be able to reference it later for some reason (such as embedding the value in the text on a page; such as: "You roll a %%D20%%...