Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- remoteID = 13
- --the ID of the remote computer
- rednet.open("right")
- while true do
- sendID, msg, prot = rednet.receive()
- function digBlock()
- while turtle.detect() do
- turtle.dig()
- end
- end
- function move(direction)
- if direction == "up" then
- while turtle.up() == false do
- turtle.digUp()
- turtle.attackUp()
- end
- elseif direction == "down" then
- while turtle.down() == false do
- turtle.digDown()
- turtle.attackDown()
- end
- elseif direction == "forward" then
- while turtle.forward() == false do
- turtle.dig()
- turtle.attack()
- end
- end
- end
- function itemDump()
- for slot=1,16 do
- if turtle.getItemCount(slot) > 0 then
- turtle.select(slot)
- turtle.drop()
- end
- end
- end
- if msg[1] == "cube" then
- rednet.send(remoteID, "ill mine out a " .. msg[2] .. " x " .. msg[3] .. " x " .. msg[4] .. " cuboid")
- frontBlocks = msg[2]
- rightBlocks = msg[3]
- upBlocks = msg[4]
- turtle.dig()
- move("forward")
- function line()
- for i=1,frontBlocks -1 do
- turtle.dig()
- move("forward")
- end
- end
- function panel()
- line()
- for i=1,upBlocks -1 do
- turtle.digUp()
- move("up")
- turtle.turnRight()
- turtle.turnRight()
- line()
- end
- end
- function turn()
- digBlock()
- turtle.select(1)
- turtle.place()
- itemDump()
- turtle.select(1)
- turtle.dig()
- move("forward")
- turtle.turnLeft()
- end
- function cuboid()
- panel()
- m = 0
- for i=1,rightBlocks -1 do
- m = m + 1
- if m == 1 and upBlocks%2 == 1 then
- m = 0
- turtle.turnRight()
- turtle.turnRight()
- for i=1,frontBlocks - 1 do
- move("forward")
- end
- for i=1,upBlocks - 1 do
- move("down")
- end
- turtle.turnLeft()
- turn()
- panel()
- elseif math.fmod(upBlocks,2) ~= 1 then
- turtle.turnLeft()
- for i=1,upBlocks - 1 do
- move("down")
- end
- turn()
- panel()
- end
- end
- end
- cuboid()
- if math.fmod(upBlocks,2) ~= 1 then
- turtle.turnRight()
- for i=1,upBlocks - 1 do
- move("down")
- end
- for i=1,rightBlocks - 1 do
- move("forward")
- end
- else
- turtle.turnRight()
- turtle.turnRight()
- for i=1,frontBlocks - 1 do
- move("forward")
- end
- turtle.turnRight()
- for i=1,upBlocks - 1 do
- move("down")
- end
- for i=1,rightBlocks - 1 do
- move("forward")
- end
- end
- turtle.turnLeft()
- turtle.dig()
- turtle.select(1)
- turtle.place()
- itemDump()
- turtle.select(1)
- turtle.dig()
- elseif msg[1] == "tree" then
- rednet.send(remoteID, "i'll cut down this tree")
- move("forward")
- moved = 0
- while turtle.digUp() == true do
- move("up")
- moved = moved + 1
- end
- while moved > 0 do
- move("down")
- moved = moved - 1
- end
- elseif msg[1] == "move" then
- rednet.send(remoteID, "i'll move " .. msg[2] .. " " .. msg[3] .. " blocks")
- moveBlocks = tonumber(msg[3])
- moveTo = msg[2]
- if moveTo == "right" then
- turtle.turnRight()
- moveTo = "forward"
- elseif moveTo == "left" then
- turtle.turnLeft()
- moveTo = "forward"
- elseif moveTo == "back" then
- for i=1,2 do
- turtle.turnRight()
- end
- moveTo = "forward"
- end
- while moveBlocks > 0 do
- if moveTo == "up" then
- move("up")
- elseif moveTo == "down" then
- move("down")
- elseif moveTo == "forward" then
- move("forward")
- end
- moveBlocks = moveBlocks - 1
- end
- elseif msg[1] == "dumpItems" then
- rednet.send(remoteID, "dumping items into enderchest...")
- digBlock()
- turtle.select(1)
- turtle.place()
- itemDump()
- turtle.select(1)
- turtle.dig()
- else
- rednet.send(remoteID, "unknown program type help for options")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement