Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- turtle --
- -- configuration --
- controller =
- modemSide = "left"
- function mainFunction()
- rednet.open(modemSide)
- listenForCommands()
- end
- function listenForCommands()
- while true do
- cmd = getCMD()
- useCMD(cmd)
- end
- end
- function getCMD()
- while true do
- id, msg = rednet.receive()
- if id == controller then
- break;
- else
- end
- end
- return msg
- end
- function useCMD(command)
- if command == "shutdown" then
- os.shutdown()
- elseif command == "go forward" then
- turtle.forward()
- elseif command == "go back" then
- turtle.back()
- elseif command == "turn left" then
- turtle.turnLeft()
- elseif command == "turn right" then
- turtle.turnRight()
- elseif command == "go up" then
- turtle.up()
- elseif command == "go down" then
- turtle.down()
- elseif command == "place up" then
- turtle.placeUp()
- elseif command == "dig up" then
- turtle.digUp()
- elseif command == "inspect up" then
- sleep(0.2)
- b,dat = turtle.inspectUp()
- if b then
- rednet.send(controller, dat.name)
- else
- rednet.send(controller, "nothing above")
- end
- elseif command == "place down" then
- turtle.placeDown()
- elseif command == "dig down" then
- turtle.digDown()
- elseif command == "inspect down" then
- sleep(0.2)
- b,dat = turtle.inspectDown()
- if b then
- rednet.send(controller, dat.name)
- else
- rednet.send(controller, "nothing above")
- end
- elseif command == "place" then
- turtle.place()
- elseif command == "dig" then
- turtle.dig()
- elseif command == "inspect" then
- sleep(0.2)
- b,dat = turtle.inspect()
- if b then
- rednet.send(controller, dat.name)
- else
- rednet.send(controller, "nothing above")
- end
- elseif command == "send fuel" then
- sleep(0.1)
- rednet.send(controller, "fuel: "..tostring(turtle.getFuelLevel()).." or "..tostring(math.floor(turtle.getFuelLevel() / 1000)).."%")
- elseif command == "get slot" then
- ssl = tonumber(getCMD())
- it = turtle.getItemDetail(ssl)
- if it == nil then
- rednet.send(controller, ssl..":nothing")
- else
- rednet.send(controller, tostring(ssl)..":"..it.count.."x"..it.name)
- end
- end
- mainFunction()
Add Comment
Please, Sign In to add comment