Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local robot = require("robot")
- local moving = require("smartMoving")
- local geo = component.geolyzer
- local ic = component.inventory_controller
- print("Положите сундук в первый слот инвентаря.\n\nВведите число от 1 до 32,\nэто будет радиус шахты.\nТо есть по столько в каждую сторону.")
- local size = io.read()
- local invSize = robot.inventorySize()
- local iter = 0
- local tab = {}
- local tab2 = {}
- local center = (size * 2 + 1) * size + size + 1
- local function scan(tab3, u)
- for z = -size, size do
- for x = -size, size do
- local scanTable = (geo.scan(x, z))
- local isNeed = false
- local height = 0
- iter = iter + 1
- if u == 1 then
- for i = 28, 38 do
- if scanTable[i] > 2.5 and scanTable[i] < 3.5 then
- isNeed = true
- height = 10-(i-28)
- break
- end
- end
- end
- if u == 2 then
- for i = 38, 28, -1 do
- if scanTable[i] > 2.5 and scanTable[i] < 3.5 then
- isNeed = true
- height = 10-(i-28)
- break
- end
- end
- end
- if isNeed then
- tab3[iter] = height
- else
- tab3[iter] = -1
- end
- io.write(" ", tostring(tab3[iter]))
- end
- print("\nСканируется ".. math.floor(iter * 100 /(size*2+1)^2) .. "%...")
- end
- iter = 0
- end
- local function drop()
- if ic.getInventorySize(0) ~= nil then
- for i = invSize, 1, -1 do
- robot.select(i)
- robot.dropDown()
- end
- else
- for i = invSize, 1, -1 do
- local t = ic.getStackInInternalSlot(i)
- if t ~= nil and (t.name == "minecraft:cobblestone" or t.name == "minecraft:dirt" or t.name == "minecraft:gravel") then
- robot.select(i)
- robot.drop()
- end
- end
- end
- robot.select(1)
- end
- local function maining()
- iter = 0
- goY(5) -- переделать!!!!!
- for z = -size, size do
- for x = -size, size do
- iter = iter + 1
- if tab[iter] ~= -1 then
- if not (goZ(z) and goX(x)) then
- goDown()
- goZ(z)
- goX(x)
- end
- goY(5 - tab[iter])
- goY(5)
- end
- if tab2[iter] ~= -1 then
- if not (goZ(z) and goX(x)) then
- goUp()
- goZ(z)
- goX(x)
- end
- goY(16 - tab2[iter])
- goY(5)
- end
- if ic.getStackInInternalSlot(invSize) then
- if not (goZ(0) and goX(0)) then
- goDown()
- goZ(0)
- goX(0)
- end
- drop()
- goY(0)
- drop()
- goY(5)
- end
- end
- end
- if not (goX(0) and goZ(0)) then
- goDown()
- goX(0)
- goZ(0)
- end
- drop()
- goY(0)
- drop()
- end
- scan(tab, 1)
- tab[center] = -1
- robot.swingDown()
- robot.placeDown()
- if not goY(11) then
- goEast()
- goY(11)
- goX(0)
- goZ(0)
- turnNorth()
- print("Хозяин, ты куда меня послал? Дурень!")
- end
- scan(tab2, 2)
- maining()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement