Skip to content
Download

Random numbers

self.vspeed = random(0.8, 1.6)
local pista = randomInt(1, 3)
if chance(0.1) then spawn("PowerUp", self.x, self.y, "Instancias") end
self.sprite = pick("inimigo_verde", "inimigo_roxo")
Function What it does
random(a, b) Decimal from a up to almost b.
randomInt(a, b) Integer from a to b, both included.
chance(p) true with probability p: 0.25 = 25%.
pick(a, b, ...) One of the values.
randomSeed(seed) Fixes the sequence: the same seed repeats the same draws.

Reference: Math and random.