Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function inspect()
- local s,n = turtle.inspect()
- if(s == true) then
- return n.name
- else
- return "No Block"
- end
- end
- function inspectDown()
- local s,n = turtle.inspectDown()
- if(s == true) then
- return n.name
- else
- return "No Block"
- end
- end
- function inspectUp()
- local s,n = turtle.inspectUp()
- if(s == true) then
- return n.name
- else
- return "No Block"
- end
- end
- function detectAround()
- local detection = {front = inspect(), down = inspectDown(), up = inspectUp()}
- turtle.turnLeft()
- detection = {front = detection.front, down = inspectDown(), up = inspectUp(), left = inspect()}
- turtle.turnLeft()
- detection = {front = detection.front, down = inspectDown(), up = inspectUp(), left = detection.left, back = inspect()}
- turtle.turnLeft()
- detection = {front = detection.front, down = inspectDown(), up = inspectUp(), left = detection.left, back = detection.back, right = inspect()}
- turtle.turnLeft()
- return detection
- end
- while true do
- local info = nil
- local id, currentOrder = rednet.receive("Drone")
- print(currentOrder)
- if(currentOrder == "w") then
- turtle.forward()
- end
- if(currentOrder == "a") then
- turtle.turnLeft()
- end
- if(currentOrder == "d") then
- turtle.turnRight()
- end
- if(currentOrder == "s") then
- turtle.turnLeft()
- turtle.turnLeft()
- end
- if(currentOrder == "1") then
- turtle.dig()
- end
- if(currentOrder == "2") then
- turtle.digUp()
- end
- if(currentOrder == "3") then
- turtle.digDown()
- end
- if(currentOrder == "Down") then
- turtle.down()
- end
- if(currentOrder == "Up") then
- turtle.up()
- end
- if(currentOrder == "Look") then
- local detection = detectAround()
- info = detection
- print("Left: " .. detection.left)
- print("Back: " .. detection.back)
- print("Right: " .. detection.right)
- end
- if(info == nil) then
- info = { front = inspect(), up = inspectUp(), down = inspectDown()}
- end
- rednet.broadcast(info, "Remote")
- if(turtle.getFuelLevel() < 80) then
- turtle.refuel(1)
- end
- end
Add Comment
Please, Sign In to add comment