Advertisement
FluttyProger

Casino.lua

Jan 28th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 KB | None | 0 0
  1. local computer = require("computer")
  2. local robot = require("robot")
  3. local component = require("component")
  4. local sides = require("sides")
  5. local redstone = component.redstone
  6.  
  7. print("Введи число от 0 до 100 шанс выйгрыша в %: ")
  8. local x = math.floor(tonumber(io.read()))
  9. print("Шанс выйгрыша "..x.."%")
  10.  
  11. if type(x) ~= "number" and (x<0 or x>100) then
  12.   error("Ты ввёл не число или больше чем 100")
  13. end
  14.  
  15. while true do
  16.   redstone.setOutput(sides.back,0)
  17.   robot.suck()
  18.   local alm = robot.compareTo(16)
  19.   local co = robot.count()
  20.   for i=1, co do
  21.     if alm and x ~= 0 then
  22.       robot.dropDown()
  23.       rand = math.random(1, 100)
  24.       print(rand)
  25.       if rand <= x then
  26.         print("Ты выиграл")
  27.         redstone.setOutput(sides.back,15)
  28.         os.sleep(0.5)
  29.         redstone.setOutput(sides.back,0)
  30.       elseif rand>x then
  31.         print("Ты проиграл")
  32.         computer.beep(2000, 0.7)
  33.       end
  34.     elseif alm and x==0 then
  35.       print("Тебя обманывают")
  36.       robot.dropDown()
  37.       computer.beep(2000, 0.7)
  38.     else
  39.       print("Что-то пошло не так")
  40.       computer.beep(1000, 1)
  41.       robot.drop()
  42.     end
  43.   end
  44.   os.sleep(0)
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement