Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------------------------
- -- Программа --
- -- для автоматической ловли рыбы или хлама в Майнкрафт --
- -- на роботе из мода OpenComputers --
- -- проект http://computercraft.ru --
- -- 2016, © Asior --
- ---------------------------------------------------------
- ----------------ПЕРЕМЕННЫЕ-------------------
- local event = require("event")
- local r = require('robot')
- local computer = require("computer")
- err = false
- slots = 16;
- --------------ПРОЦЕДУРЫ----------------------
- function instrument()--сканирует первый слот инвентаря на наличие в нем удочки
- if incontrol.getStackInInternalSlot(1)~=nil then
- if incontrol.getStackInInternalSlot(1).name=='minecraft:fishing_rod' then
- incontrol.equip()
- end
- else
- print('У меня закончились удочки, или произошла неизвестная ошибка')
- computer.beep(2000, 10)
- os.sleep(20)
- end
- end
- function lovka()--функция ловли рыбы(или хлама)
- r.use(0, true, 1)
- os.sleep(3)
- print('Ловись рыбка большая и маленькая...')
- _ = event.pull(60,'redstone_changed')
- r.use(0, true, 1)
- print('УРА! чего-то клюнуло ... или показалось...')
- os.sleep(2)
- if redstone.getInput(0) > 0 then r.use(0, true, 1) end
- os.sleep(1)
- end
- -----------------ОСНОВНОЙ КОД-----------------
- print('Подключение устройств...')
- if require("component").isAvailable("redstone") then
- redstone = require("component").redstone
- print('Плата красного камня успешно подключена')
- else
- print("Плата красного камня не обнаружена!")
- print("Вы забыли установить плату красного камня, работа без неё невозможна, установите отсутствующее устройство и перезагрузите программу")
- os.exit()
- end
- if require("component").isAvailable("inventory_controller") then
- incontrol = require("component").inventory_controller
- print('Контроллер успешно подключен')
- else
- print("Контроллер не обнаружен!")
- print("Вы забыли установить контроллер инвентаря, работа без него возможна, но некоторые функции будут недоступны."..' \n '..'Продолжить работу? (1-да, 0-нет')
- a = io.read(1)
- if a == '1' then
- print('Продолжаем работать, положите в руку удочку.')
- print('Внимание! Как только удочка поломается, робот будет отключен!')
- print('Жду удочку 10 секунд')
- os.sleep(10)
- err = true;
- else
- print('Выход...')
- os.exit()
- end
- end
- while true do
- if (r.durability() ~= nil) and (r.count(slots) == 0) then --проверка целостности предмета и пустоты инвенторя
- lovka()
- else
- for i = 1, slots, 1 do
- r.select(i)
- r.dropDown(64)
- end
- r.select(1)
- if r.durability() == nil then
- if err == false then
- r.suckUp()
- instrument()
- else
- print('Сломан инструмент, или его забыли мне дать')
- computer.beep(2000, 5)
- computer.shutdown()
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement