subzero22

slots

Sep 2nd, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. cash = 100
  4.  
  5. print("Press Spacebar to play and E to exit")
  6.  
  7. function won()
  8.  print("YOU WON!!!")
  9. end
  10.  
  11. function lost()
  12.  print("YOU LOST")
  13. end
  14.  
  15. line1 = " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
  16. line2 = " -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
  17.  
  18. while true do
  19.  
  20.  term.setCursorPos(2,2)
  21.  print("Cash: "..cash.."    ")
  22.  
  23.  local event, key = os.pullEvent("char")
  24.  if key == "e" then
  25.   term.clear()
  26.   return
  27.  elseif cash <= 0 then
  28.   local x = 10
  29.   for i=1,10 do
  30.    term.clear()
  31.    term.setCursorPos(1,5)
  32.    print("Sorry you are out of cash please")
  33.    print("start a new game.")
  34.    x = x - 1
  35.    print(x)
  36.    sleep(1)
  37.   end
  38.   return
  39.  end
  40.  
  41.  
  42.   for i=1,10 do
  43.    term.setCursorPos(1,1)
  44.     if line == 0 then
  45.      print(line1)
  46.      line = 1
  47.     else
  48.      print(line2)
  49.      line = 0
  50.     end
  51.     term.setCursorPos(1,17)
  52.     if line == 0 then
  53.      print(line2)
  54.     else
  55.      print(line1)
  56.     end
  57.  
  58.     a = math.random(9)
  59.     b = math.random(9)
  60.     c = math.random(9)
  61.  
  62.     term.setCursorPos(20,9)
  63.     print(a.." - "..b.." - "..c)
  64.     sleep(0.5)
  65.    end
  66.    sleep(0.5)
  67.    term.setCursorPos(20,9)
  68.    print(a.." - "..b.." - "..c)
  69.    print()
  70.    term.setCursorPos(20,7)
  71.  
  72.    if a == b and b == c then
  73.     won()
  74.     if b == 9 then
  75.      cash = cash + 500
  76.     elseif b >= 5 then
  77.      cash = cash + 100
  78.     else    
  79.      cash = cash + 25
  80.     end
  81.    elseif a == b or b == c then
  82.     won()
  83.     if b == 9 then
  84.      cash = cash + 25
  85.     elseif b >= 5 then
  86.      cash = cash + 10
  87.     else
  88.      cash = cash + 5
  89.     end
  90.    else
  91.     lost()
  92.     cash = cash - 5
  93.    end
  94.    term.setCursorPos(1,18)
  95.   end
Advertisement
Add Comment
Please, Sign In to add comment