Advertisement
RealHero

kazik

Aug 18th, 2020 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.88 KB | None | 0 0
  1. local event = require("event")
  2. local component = require("component")
  3. local gpu = component.gpu
  4. local term = require("term")
  5.  
  6.  
  7. function localsay(msg) chat.say("§e".. msg) end
  8.  
  9. local values = {[0] = 'z','r','b','r','b','r','b','r','b','r','b','b','r','b','r','b','r','b','r','r','b','r','b','r','b','r','b','r','b','b','r','b','r','b','r','b','r'}
  10. local wheel = {0,32,15,19,4,21,2,25,17,34,6,27,13,36,11,30,8,23,10,5,24,16,33,1,20,14,31,9,22,18,29,7,28,12,35,3,26,0,32,15,19,4,21,2,25,17}
  11. local red = {1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36}
  12. local black = {2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35}
  13.  
  14. function drawNumber(left,top,number)
  15.   if(values[number] == 'r') then gpu.setBackground(0xff0000)
  16.   elseif(values[number] == 'b') then gpu.setBackground(0x000000)
  17.   else gpu.setBackground(0x00ff00) end
  18.   gpu.fill(left,top,6,3,' ')
  19.   gpu.set(left+2,top+1,tostring(number))
  20. end
  21.  
  22. function getColor(number)
  23.     if(number == 0) then return "" end
  24.     for i = 1,#red do
  25.         if(red[i] == number) then return "(красное)" end
  26.     end
  27.     return "(чёрное)" end
  28.  
  29. gpu.setResolution(112,21)
  30. gpu.setBackground(0xffffff)
  31. term.clear()
  32. gpu.setForeground(0x000000)
  33. gpu.set(103,14,"Ставки:")
  34. gpu.set(103,15,"ЛКМ 1 дюр")
  35. gpu.set(103,16,"ПКМ 10 дюр")
  36. gpu.setForeground(0x777777)
  37. gpu.set(103,18,"Автор:")
  38. gpu.set(103,19,"krovyaka")
  39. gpu.setForeground(0xffffff)
  40. gpu.setBackground(0x00ff00)
  41. gpu.fill(13,2,5,11,' ')
  42. gpu.set(15,7,"0")
  43. for i = 1, 36 do
  44.   drawNumber(19+math.floor((i-1)/3)*7,2+((3-i)%3*4),i)
  45. end
  46. gpu.setBackground(0x34a513)
  47. gpu.fill(103,2,9,3,' ') gpu.fill(103,6,9,3,' ') gpu.fill(103,10,9,3,' ')
  48. gpu.set(106,3,"2к1") gpu.set(106,7,"2к1") gpu.set(106,11,"2к1")
  49. gpu.fill(19,14,27,3, ' ') gpu.fill(47,14,27,3, ' ') gpu.fill(75,14,27,3, ' ')
  50. gpu.set(28,15,"первая 12") gpu.set(56,15,"вторая 12") gpu.set(84,15,"третья 12")
  51. gpu.fill(19,18,13,3,' ') gpu.fill(33,18,13,3,' ')  gpu.fill(75,18,13,3,' ')  gpu.fill(89,18,13,3,' ')
  52. gpu.set(22,19,"1 до 18") gpu.set(38,19,"Чёт") gpu.set(79,19,"Нечёт") gpu.set(91,19,"19 до 36")
  53. gpu.setBackground(0xff0000) gpu.fill(47,18,13,3,' ') gpu.set(50,19,"Красное")
  54. gpu.setBackground(0x000000) gpu.fill(61,18,13,3,' ') gpu.set(64,19,"Чёрное")
  55. gpu.setBackground(0xffb109) gpu.fill(3,2,8,19,' ')
  56. gpu.setBackground(0xffda54) gpu.fill(3,9,8,5,' ')
  57.  
  58. function Roll()
  59.   local current = math.random(1,35)
  60.   for i = 1,math.random(30,50) do
  61.     current = current + 1
  62.     if (current == 38) then current = 1 end
  63.     drawNumber(4,2,wheel[current+4])
  64.     drawNumber(4,6,wheel[current+3])
  65.     drawNumber(4,10,wheel[current+2])
  66.     drawNumber(4,14,wheel[current+1])
  67.     drawNumber(4,18,wheel[current])
  68.     os.sleep(i/140)
  69.   end
  70.   return wheel[current+2]
  71. end
  72.  
  73. function getNumberClick(left,top)
  74.   if(top==5) or (top==9) or (left%7==4) then return 0 end
  75.   return (math.floor((left-18)/7)*3) + math.floor(4-(top-1)/4)
  76. end
  77.  
  78.  
  79. Bets = {}
  80. function resetBets() Bets={} for i = 0,36 do Bets[i] = {} end end
  81.  
  82. function placeBet(nick,number,money)  
  83.   if(Bets[number][nick]==nil) then Bets[number][nick]=money else Bets[number][nick] = Bets[number][nick] + money end
  84. end
  85.  
  86. function placeBetByTable(t,nick,money) for i = 1,#t do placeBet(nick,t[i],money) end end
  87.  
  88. function fixClicks(left,top)
  89.   return not((left<13) or (top<2) or (left>111) or (top>20) or (left<19 and top>12) or (left==18) or (left==46) or (left==102) or (top==12) or (top==17) or (((left>18)and(left<102)and(top>1)and(top<13)) and getNumberClick(left,top)==0) or (top>17 and top<21 and (left==32 or left==46 or left==60 or left==74 or left==88)) or (left>101 and top>12) or (left>102 and (top == 5 or top==9))) end
  90.  
  91. local endbets = 0
  92.  
  93. while true do
  94.   resetBets()
  95.   endbets = 0
  96.   while endbets==0 or (endbets>os.time()) do
  97.     local _,_,left,top,clicktype,p = event.pull(3,"touch")
  98.     if(p~=nil) then
  99.       local number,money = 0,1+clicktype*9
  100.       if(fixClicks(left,top)) then
  101.         if(Connector:pay(p,money)) then
  102.           if(endbets == 0) then endbets = os.time()+1080  end  
  103.           if(left>18)and(left<102)and(top>1)and(top<13) then
  104.             number = getNumberClick(left,top)
  105.           end
  106.           if number > 0 then placeBet(p,number,money*36)
  107.           elseif (left>12)and(left<18)and(top>1)and(top<13) then  placeBet(p,0,money*36)
  108.           elseif (left>18)and(left<46)and(top>13)and(top<17) then  money = money*3 for i = 1, 12 do placeBet(p,i,money) end
  109.           elseif (left>46)and(left<74)and(top>13)and(top<17) then  money = money*3 for i = 13, 24 do placeBet(p,i,money) end
  110.           elseif (left>74)and(left<102)and(top>13)and(top<17) then  money = money*3 for i = 25, 36 do placeBet(p,i,money) end
  111.           elseif (left>18)and(left<32)and(top>17)and(top<21) then  money = money*2 for i = 1, 18 do placeBet(p,i,money) end
  112.           elseif (left>32)and(left<46)and(top>17)and(top<21) then  money = money*2 for i = 2,36,2 do placeBet(p,i,money) end
  113.           elseif (left>46)and(left<60)and(top>17)and(top<21) then  placeBetByTable(red,p,money*2)
  114.           elseif (left>60)and(left<74)and(top>17)and(top<21) then  placeBetByTable(black,p,money*2)
  115.           elseif (left>74)and(left<88)and(top>17)and(top<21) then  money = money*2 for i = 1,35,2 do placeBet(p,i,money) end
  116.           elseif (left>88)and(left<102)and(top>17)and(top<21) then  money = money*2 for i = 19, 36 do placeBet(p,i,money) end
  117.           elseif (left>102)and(left<112)and(top>1)and(top<5) then  money = money*3 for i = 3,36,3 do placeBet(p,i,money) end
  118.           elseif (left>102)and(left<112)and(top>5)and(top<9) then  money = money*3 for i = 2,35,3 do placeBet(p,i,money) end
  119.           elseif (left>102)and(left<112)and(top>9)and(top<13) then  money = money*3 for i = 1,34,3 do placeBet(p,i,money) end
  120.           end
  121.         else  end
  122.       end
  123.     end
  124.   end
  125.  
  126.   for nick,money in pairs(Bets[out]) do Connector:give(nick,money)  end
  127. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement