This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
random_number [2018/08/29 09:03] – created justin | random_number [2020/05/26 10:35] (current) – justin | ||
---|---|---|---|
Line 2: | Line 2: | ||
---- | ---- | ||
- | The **random number** syntax generates an integer value within the given range (inclusive of the minimum and maximum value). It can be used in place of a literal value for most function arguments where a numeric value is expected. | + | The **random number** syntax generates an integer value within the given range (inclusive of the minimum and maximum value). It can be used in [[script|scripts]] anywhere |
====Examples: | ====Examples: | ||
- | < | + | < |
wait(random(1, | wait(random(1, | ||
</ | </ | ||
+ | Waits for a random amount of time between 1 and 5 seconds. | ||
- | < | + | < |
- | if random(0, 100) < 25 then | + | if random(0, 100) <= 25 then |
give_item(" | give_item(" | ||
else | else | ||
Line 16: | Line 17: | ||
end | end | ||
</ | </ | ||
+ | Gives either ITEM_0001 or ITEM_0002 to the player, with a 25% chance that the [[item]] will be ITEM_0001. | ||
~~NOTOC~~ | ~~NOTOC~~ |