Advertisement
LuaWeaver

main.lua

Dec 22nd, 2011
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. require("mini1/mini1.lua")
  2. require("mini2/mini2.lua")
  3. require("mini3/mini3.lua")
  4.  
  5. function pickAtRandom(last) --Picks a new minigame.
  6.     local rand=math.random(1, 3) --Picks a random number.
  7.     if rand==last then --Checks if the new minigame is the same as the last, and if not, returns the new minigame.
  8.         pickAtRandom(last)
  9.     else
  10.         oldMini=last
  11.         currentMini=rand
  12.         return rand
  13.     end
  14. end
  15.  
  16. function love.load()
  17.     currentMini=pickAtRandom(0)
  18.     oldMini=0
  19.     print(currentMini)
  20.     mini1.load()
  21.     mini2.load()
  22.     mini3.load()
  23. end
  24.  
  25. function love.draw()
  26.     if currentMini==1 then
  27.         mini1.draw()
  28.     elseif currentMini==2 then
  29.         mini2.draw()
  30.     elseif currentMini==3 then
  31.         mini3.draw()
  32.     end
  33. end
  34.  
  35. function love.update(dt)
  36.     if currentMini==1 then
  37.         mini1.update(dt)
  38.     elseif currentMini==2 then
  39.         mini2.update(dt)
  40.     elseif currentMini==3 then
  41.         mini3.update(dt)
  42.     else
  43.         pickAtRandom(oldMini)
  44.     end
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement