Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local robot = require("robot")
- local component = require("component")
- local computer = require("computer")
- local ic = component.inventory_controller
- local last_level = math.floor(robot.level())
- function Notifications(code)
- Beep(3)
- if code == 1 then print("Уровень повышен до " .. math.floor(robot.level()) .. "!") end
- if code == 2 then print("Текущий уровень - " .. math.floor(robot.level()) .. "!") end
- return 0
- end
- function Check_level()
- if math.floor(robot.level()) > last_level then
- last_level = math.floor(robot.level())
- Notifications(1)
- end
- return 0
- end
- function Swing()
- if robot.detect() == true then
- while (robot.swing() == 0) do computer.sleep(100) end
- end
- return 0
- end
- function Beep(code)
- if code == 1 then
- computer.beep(800,0.1)
- computer.beep(1000,0.1)
- computer.beep(1200,0.2)
- end
- if code == 2 then
- computer.beep(1000,0.2)
- computer.beep(1000,0.2)
- end
- if code == 3 then
- computer.beep(1000,0.2)
- end
- return 0
- end
- function Get_things()
- robot.select(1)
- while true do
- for i = 1, ic.getInventorySize(1) do
- if ic.getStackInSlot(1, i) ~= nil then
- ic.suckFromSlot(1, i)
- return 0
- end
- end
- end
- end
- function Give_things_away()
- for i = 1, robot.inventorySize() do
- if robot.count(i) ~= 0 then
- robot.select(i)
- for j = 1, ic.getInventorySize(0) do
- if ic.getStackInSlot(0, j) == nil then
- ic.dropIntoSlot(0, j)
- break
- end
- end
- end
- end
- return 0
- end
- function Break_the_block()
- robot.select(1)
- for i = 1, robot.count() do
- while (robot.place() == 0) do computer.sleep(100) end
- Swing()
- end
- return 0
- end
- Beep(1)
- print("Вас приветствует " .. robot.name() .. "!")
- Notifications(2)
- Beep(2)
- while true do
- Check_level()
- Get_things()
- Break_the_block()
- Give_things_away()
- end
- --pastebin run 3NZwmg4S
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement