ZNZNCOOP

Casino

Apr 1st, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.80 KB | None | 0 0
  1. bonus={2,20,200}
  2. function printTop(p)
  3.   term.setCursorPos(1,1)
  4.   term.setTextColor(colors.yellow)
  5.   write('Bet -')
  6.   for i=1,5 do
  7.     if i==p then term.setTextColor(colors.white)
  8.     else term.setTextColor(colors.yellow) end
  9.     write(string.format('%5d',i))
  10.   end
  11.   print()
  12.   for i=1,3 do
  13.     term.setTextColor(colors.red)
  14.     write(7)
  15.     term.setTextColor(colors.yellow)
  16.     write('x'..i..' -')
  17.     for j=1,5 do
  18.       if j==p then term.setTextColor(colors.white)
  19.       else term.setTextColor(colors.yellow) end
  20.       write(string.format('%5d',bonus[i]*j))
  21.     end
  22.     print()
  23.   end
  24.   term.setTextColor(colors.white)
  25. end
  26.  
  27. banner={'\\  /',' \\/ ','    '}
  28. pb=1
  29. function printRight()
  30.   for i=1,12 do
  31.     term.setCursorPos(34,i)
  32.     if pb>3 then pb=pb-3 end
  33.     write(banner[pb])
  34.     pb=pb+1
  35.   end
  36.   pb=pb-1
  37. end
  38.  
  39. term.clear()
  40. A=wheel:new(8,5,7)
  41. B=wheel:new(16,5,7)
  42. C=wheel:new(24,5,7)
  43.  
  44. function button()
  45.   if rs.getInput('left') then return true end
  46.   sleep(0.5)
  47.   if rs.getInput('left') then return true end
  48.   return false
  49. end
  50.  
  51. function check()
  52.   while button() do sleep(0.5) end
  53.   wheels_stop=true
  54. end
  55.  
  56. while true do
  57.   StartItems=CountItems()
  58.   bet=-1
  59.   repeat
  60.     Items=CountItems()-StartItems
  61.     if Items~=bet then
  62.       bet=Items
  63.       if bet>5 then GiveItems(bet-5) bet=5 end
  64.       printTop(bet)
  65.     end
  66.     if bet<5 then printRight() end
  67.     sleep(0.2)
  68.   until button() and bet~=0
  69.   term.setCursorPos(1,12)
  70.   term.clearLine()
  71.   parallel.waitForAll(A:rotation(0.12),B:rotation(0.1),C:rotation(0.04),check)
  72.  
  73.   prize=0
  74.   if A.pos==7 then prize=prize+1 end
  75.   if B.pos==7 then prize=prize+1 end
  76.   if C.pos==7 then prize=prize+1 end
  77.   if prize>0 then
  78.     prize=bonus[prize]*bet
  79.     term.setCursorPos(1,12)
  80.     write('Win '..prize)
  81.     GiveItems(prize)
  82.   end
  83. end
Advertisement
Add Comment
Please, Sign In to add comment