Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This is the code for the Turtle. It works in CC 1.74 and requieres a wireless mining turtle.
- local moves = {}
- local function connect()
- rednet.open("right")
- print(">> Connecting")
- TrgtID,msg1,prt = rednet.receive("Ask")
- rednet.send(TrgtID,"Ping","Ans")
- print(">> Connected to "..TrgtID.."\n")
- end
- local function save(move)
- moves[table.getn(moves) + 1] = move
- local nMove = table.getn(moves)
- print(">> "..moves[nMove])
- end
- local function recall()
- local length = table.getn(moves)
- for i=length,1,-1 do
- local recall = moves[i]
- if recall =="forward" then
- turtle.back()
- elseif recall =="back" then
- turtle.forward()
- elseif recall =="left" then
- turtle.turnRight()
- elseif recall =="right" then
- turtle.turnLeft()
- elseif recall =="up" then
- turtle.down()
- elseif recall =="down" then
- turtle.up()
- else
- print("Program Failed!")
- end
- end
- end
- local function send(sInput)
- rednet.send(TrgtID,sInput,"Ans")
- end
- local function update()
- local bln,top = turtle.inspectUp()
- if bln then
- rednet.send(TrgtID,"Top: [X]| "..top.name,"BLS")
- else
- rednet.send(TrgtID,"Top: [ ]| minecraft:air","BLS")
- end
- local bln,top = turtle.inspect()
- if bln then
- rednet.send(TrgtID,"Mid: [X]| "..top.name,"BLS")
- else
- rednet.send(TrgtID,"Mid: [ ]| minecraft:air","BLS")
- end
- local bln,top = turtle.inspectDown()
- if bln then
- rednet.send(TrgtID,"Dow: [X]| "..top.name,"BLS")
- else
- rednet.send(TrgtID,"Dow: [ ]| minecraft:air","BLS")
- end
- rednet.send(TrgtID,turtle.getFuelLevel(),"FL")
- rednet.send(TrgtID,turtle.getItemCount(1),"FL")
- end
- local function get()
- sID,msg,prt = rednet.receive("CMD")
- rednet.send(TrgtID,"RCV","Ans")
- end
- connect()
- print("Please put fuel into first slot")
- while true do
- get()
- if msg =="forward" then
- if turtle.forward() then
- update()
- save("forward")
- else
- update()
- end
- elseif msg =="back" then
- if turtle.back() then
- update()
- save("back")
- else
- update()
- end
- elseif msg =="turnLeft" then
- turtle.turnLeft()
- update()
- save("left")
- elseif msg =="turnRight" then
- turtle.turnRight()
- update()
- save("right")
- elseif msg =="up" then
- if turtle.up() then
- update()
- save("up")
- else
- update()
- end
- elseif msg =="down" then
- if turtle.down() then
- update()
- save("down")
- else
- update()
- end
- elseif msg =="inspect" then
- update()
- elseif msg =="end" then
- print("\n>> Connection terminated")
- print(">> Moving back to starting point...")
- recall()
- break
- elseif msg =="dig" then
- turtle.dig()
- update()
- elseif msg =="digD" then
- turtle.digDown()
- update()
- elseif msg =="digU" then
- turtle.digUp()
- update()
- elseif msg =="refuel" then
- turtle.refuel(1)
- update()
- elseif msg =="Nope" then
- print("Not implemented")
- update()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement