Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Russian version/Русская версия
- --Past version/Прошлая версия: http://pastebin.com/e46ZkmEm (ComputerCraft)
- --options/настройки
- VERSION = "3.0.1"
- NAME = "miner"
- TORCHSLOT = 1
- BLOCKSLOT = 2
- CHESTSLOT = 16
- TORCHDIST = 10
- CLEVERTORCHING = true
- CHESTS = false --не реализовано
- --variables/переменные
- arg = { ... }
- version = "v3.0.1b"
- robot = require("robot")
- term = require("term")
- sides = require("sides")
- --functions/функции
- function cotorch(dist, tdist)
- local col = math.floor(dist/tdist)
- return col
- end
- function torch()
- if robot.count(TORCHSLOT) ~= 0 then
- robot.back()
- if CLEVERTORCHING == true then
- robot.down()
- os.sleep(0.1)
- if not robot.detectDown() then
- robot.select(BLOCKSLOT)
- robot.placeDown()
- end
- robot.up()
- robot.select(TORCHSLOT)
- robot.placeDown()
- else robot.select(TORCHSLOT)
- robot.placeDown()
- end
- robot.forward()
- end
- end
- function testitems()
- local relay = true
- local relayone = true
- while relay do
- local torchcount = robot.count(TORCHSLOT)
- if torchcount == 0 then
- term.clear()
- print("Положите несколько факелов в слот "..tostring(TORCHSLOT))
- os.sleep(2)
- else relay = false
- end
- end
- if CHESTS == true then
- while realyone do
- local chestcount = robot.count(CHESTSLOT)
- if chestcount == 0 then
- term.clear()
- print("Положите несколько сундуков в слот "..tostring(CHESTSLOT))
- os.sleep(2)
- else relayone = false
- end
- end
- end
- end
- function dig()
- repeat robot.swing(sides.front)
- os.sleep(0.1)
- until not robot.detect()
- end
- function digUp()
- repeat robot.swingUp()
- os.sleep(0.1)
- until not robot.detectUp()
- end
- function digDown()
- robot.swingDown()
- end
- --body/тело
- if #arg < 1 then
- print("Использование: "..NAME.." <distance>")
- return
- elseif tonumber(arg[1]) < 1 then
- print("Дистанция должна быть больше нуля")
- return
- end
- col = cotorch(arg[1], TORCHDIST)
- if col > 64 then
- print("Нужно более стака факелов")
- print("Часть пути будет не освещена")
- print("Всё равно продолжить? y/n")
- answ = read()
- if ans == "n" then
- return
- end
- end
- testitems()
- --main/главное
- print("Нужно "..col.." факелов")
- print("Нажмите Enter для начала")
- print("Введите cancel для отмены")
- qwe = io.read()
- if qwe == "cancel" then
- print("Отменено")
- os.sleep(1)
- term.clear()
- return
- end
- light = 1
- dig()
- robot.forward()
- for i = 1, arg[1]-1 do
- digUp()
- digDown()
- dig()
- robot.forward()
- if light == TORCHDIST then
- torch()
- light = 0
- else light = light + 1
- end
- end
- digUp()
- digDown()
- if light == TORCHDIST then
- torch()
- end
- print("Сделано!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement