tim

small extendable personal assistant
git clone git://edryd.org/tim
Log | Files | Refs | LICENSE

rand.lua (916B)


      1 math.randomseed(os.time())
      2 math.random(); math.random(); math.random()
      3 
      4 local m8ball = {
      5 	"It is certain",
      6 	"It is decidedly so",
      7 	"Without a doubt",
      8 	"Yes, definitely",
      9 	"You may rely on it",
     10 	"As I see it, yes",
     11 	"Most likely",
     12 	"Outlook good",
     13 	"Yes",
     14 	"Signs point to yes",
     15 	"Reply hazy try again",
     16 	"Ask again later",
     17 	"Better not tell you now",
     18 	"Cannot predict now",
     19 	"Concentrate and ask again",
     20 	"Don't count on it",
     21 	"My reply is no",
     22 	"My sources say no",
     23 	"Outlook not so good",
     24 	"Very doubtful"
     25 }
     26 
     27 if args:find("coin") then
     28 	return math.random(0,1) == 1 and "heads" or "tails"
     29 elseif args:find("from %d to %d") then
     30 	num1, num2 = args:match("number from (.-) to (.-)$")
     31 	return math.random(num1, num2)
     32 elseif args:find("between %d and %d") then
     33 	num1, num2 = args:match("between (.-) and (.-)$")
     34 	return math.random(num1, num2)
     35 elseif args:find("should") then
     36 	return m8ball[math.random(1,#m8ball)]
     37 end