Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local computer = require("computer")
- local robot = require("robot")
- local component = require("component")
- local sides = require("sides")
- local redstone = component.redstone
- print("Введи число от 0 до 100 шанс выйгрыша в %: ")
- local x = math.floor(tonumber(io.read()))
- print("Шанс выйгрыша "..x.."%")
- if type(x) ~= "number" and (x<0 or x>100) then
- error("Ты ввёл не число или больше чем 100")
- end
- while true do
- redstone.setOutput(sides.back,0)
- robot.suck()
- local alm = robot.compareTo(16)
- local co = robot.count()
- for i=1, co do
- if alm and x ~= 0 then
- robot.dropDown()
- rand = math.random(1, 100)
- print(rand)
- if rand <= x then
- print("Ты выиграл")
- redstone.setOutput(sides.back,15)
- os.sleep(0.5)
- redstone.setOutput(sides.back,0)
- elseif rand>x then
- print("Ты проиграл")
- computer.beep(2000, 0.7)
- end
- elseif alm and x==0 then
- print("Тебя обманывают")
- robot.dropDown()
- computer.beep(2000, 0.7)
- else
- print("Что-то пошло не так")
- computer.beep(1000, 1)
- robot.drop()
- end
- end
- os.sleep(0)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement