Seite 1 von 1

#1 RANDOM

Verfasst: Do 15. Mär 2012, 00:53
von Franky
Hi Filip,

is it possible, to use in the logic a random function like:

Zufall = math.random()

#2 RE: RANDOM

Verfasst: Do 15. Mär 2012, 12:05
von DOMIQ
Yes, random will return random value between 0 and 1. So you should use it like:

Code: Alles auswählen

if math.random() > 0.8 then
  -- do something with 80% probability
end

#3 RE: RANDOM

Verfasst: Do 15. Mär 2012, 12:16
von Beleuchtfix
This should give you a 20% probability, ;)
or it should be
if math.random() < 0.8 then

Regards Florian

#4 RE: RANDOM

Verfasst: Do 15. Mär 2012, 17:49
von DOMIQ
This was to test you... ;)

You are right.