Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local robot = require("robot")
- local component = require("component")
- local geo = component.geolyzer
- local term = require("term")
- local computer = require("computer")
- local currX = 0
- local currZ = 0
- local currY = 0
- function scan()
- for i = 0, 5 do
- local block = geo.analyze(i)
- local blockName = block["name"]
- local ores = require("lib/ores")
- for k,v in pairs(ores) do
- if blockName == v then
- if i == 4 then
- robot.turnRight()
- robot.swing(0)
- robot.turnLeft()
- elseif i == 5 then
- robot.turnLeft()
- robot.swing(0)
- robot.turnRight()
- end
- end
- end
- --for k, v in pairs(block) do
- -- print(k,":",v)
- --end
- end
- end
- function statusCheck()
- local power = computer.energy()
- local maxPower = computer.maxEnergy()
- print("Current power: ", power)
- if(power < 20500) then
- print("Refueling!")
- print("X: ",currX," Z: ",currZ," Y ",currY)
- end
- end
- function digDown(distY)
- local move
- for i = 1, distY do
- move = nil
- currY = currY - 1
- while(move == nil) do
- robot.swingDown()
- move = robot.down()
- end
- end
- end
- function digUp(distY)
- local move
- for i = 1, distY do
- currY = curr + 1
- move = nil
- while(move == nil) do
- robot.swingUp()
- move = robot.up()
- end
- end
- end
- function digForward(distX, axis)
- local move
- for i = 1, distX do
- if axis == "+x" then
- currX = currX + 1
- elseif axis == "-x" then
- currX = currX - 1
- elseif axis == "+z" then
- currZ = currZ + 1
- elseif axis == "-z" then
- currZ = currZ - 1
- end
- move = nil
- while(move == nil) do
- robot.swing(0)
- move = robot.forward()
- statusCheck()
- end
- scan()
- end
- end
- function row(distX)
- robot.turnLeft()
- digForward(distX, "+x")
- robot.turnAround()
- digForward(distX, "-x")
- robot.turnLeft()
- end
- function plane(distX, distZ)
- row(distX)
- for i = 1, distZ do
- digForward(1, "+z")
- if(i % 3 == 0) then
- row(distX)
- end
- end
- robot.turnAround()
- digForward(distZ, "-z")
- robot.turnAround()
- end
- function start(distX, distZ, distY)
- distY = distY - 1
- distX = distX - 1
- distZ = distZ - 1
- digDown(1)
- robot.turnRight()
- plane(distX, distZ)
- for i = 1, distY do
- digDown(1)
- plane(distX, distZ)
- end
- robot.turnLeft()
- digUp(distY+1)
- end
- term.write("X: ")
- x = term.read()
- term.write("Z: ")
- z = term.read()
- term.write("Y: ")
- y = term.read()
- start(x,z,y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement