Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Leroki's smart miner on EEPROM --
- -- Умный робот карьер, копает все в указанных параметрах
- -- Настройки --
- trashSlots = 2 -- кол-во слотов под мусор, с 1 по указанный
- lengh = 7 -- Длинна карьера
- width = 4 -- Ширина карьера !!! ТОЛЬКО ЧЕТНЫЕ ЧИСЛА !!!
- deepM = 9 -- Высота карьера !!! ЧИСЛА КРАТНЫЕ 3 !!!
- --------------------------------------------------------
- toolSwich = false -- смена инструментов роботом true - да / false - нет
- tool1 = 5 -- 1 слот для инструмента
- tool2 = 9 -- последний слот для инструмента
- --------------------------------------------------------
- -- functions --
- robot = component.proxy(component.list("robot")())
- if toolSwich then
- inventory = component.proxy(component.list("inventory_controller")())
- end
- function moveFd()
- if direction == 0 then
- robot.move(3)
- z = z + 1
- elseif direction == 1 then
- robot.move(3)
- x = x - 1
- elseif direction == 2 then
- robot.move(3)
- z = z - 1
- elseif direction == 3 then
- robot.move(3)
- x = x + 1
- end
- end
- function moveDn()
- robot.move(0)
- y = y - 1
- end
- function moveUp()
- robot.move(1)
- y = y + 1
- end
- function tollCheck()
- if robot.durability() < 0.1 and tool1 <= tool2 and toolSwich then
- robot.select(tool1)
- inventory.equip()
- tool1 = tool1 + 1
- end
- end
- function mine()
- for i=1, (lengh - 1) do
- check(1)
- check(0)
- robot.swing(3)
- tollCheck()
- dropIt()
- moveFd()
- end
- end
- function turn(dir)
- if dir then
- direction = direction - 1
- robot.turn(dir)
- else
- direction = direction + 1
- robot.turn(dir)
- end
- if direction == -1 then
- direction = 3
- elseif direction == 4 then
- direction = 0
- end
- end
- function corner(engl)
- check(1)
- check(0)
- turn(engl)
- robot.swing(3)
- tollCheck()
- dropIt()
- moveFd()
- turn(engl)
- end
- function check(side)
- for inv = 1, trashSlots do
- robot.select(inv)
- if robot.compare(side) then
- return
- end
- end
- robot.swing(side)
- end
- function dropIt()
- for inv = 1, trashSlots do
- if robot.count(inv) >= 10 then
- robot.select(inv)
- robot.drop(0, 9)
- end
- end
- end
- function turnAround()
- check(1)
- for i = 1, 3 do
- robot.swing(0)
- tollCheck()
- dropIt()
- moveDn()
- end
- turn(true)
- turn(true)
- end
- -- main programm --
- x = 0
- y = 0
- z = 0
- direction = 0
- deepM = deepM - (deepM % 3)
- width = width - (width % 2)
- for i = 1, 2 do
- robot.swing(0)
- tollCheck()
- dropIt()
- moveDn()
- end
- for deep = 1, (deepM / 3) do
- if (deep % 2) == 0 then
- for j = 1, (width / 2) do
- mine()
- corner(true)
- mine()
- if j == (width / 2) then
- if deep == (deepM / 3) then
- check(0)
- check(1)
- break
- end
- turnAround()
- break
- end
- corner(false)
- end
- else
- for j = 1, (width / 2) do
- mine()
- corner(false)
- mine()
- if j == (width / 2) then
- if deep == (deepM / 3) then
- check(0)
- check(1)
- break
- end
- turnAround()
- break
- end
- corner(true)
- end
- end
- end
- if x ~= 0 then
- turn(false)
- while x ~= 0 do
- robot.swing(3)
- tollCheck()
- dropIt()
- moveFd()
- end
- turn(false)
- end
- while y ~= 0 do
- robot.swing(1)
- tollCheck()
- dropIt()
- moveUp()
- end
- robot.select(trashSlots)
- robot.place(0)
- if direction ~= 0 then
- turn(false)
- turn(false)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement