Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Open rednet, make clearing the screen a single function
- rednet.open("right")
- function clear() term.clear() term.setCursorPos(1, 1) end
- while true do
- clear()
- print("Connected, ID: ", os.computerID(), ". Listening for requests.")
- rednet.broadcast("Listening") --Tell all other computers in the area that this turtle is ready and waiting for orders
- local id, msg = rednet.receive(10) --Wait for a return message for 10 seconds, then repeat
- if msg == "goto" then --If the incoming message is a goto request then prepare for coordinates (other commands can be added in this if statement in the future
- print("Goto request from ", id, ", getting coordinates...")
- local id, msg = rednet.receive()
- gox = tonumber(msg) --Because only strings can be send over rednet the coordinates are changed to and from strings on each side of the message
- local id, msg = rednet.receive()
- goy = tonumber(msg)
- local id, msg = rednet.receive()
- goz = tonumber(msg)
- print("Coordinates received, going to ", gox, " ", goy, " ", goz)
- shell.run("goto.lua", gox, goy, goz) --Run the goto program with the received coordinates
- end
- --additional functions can be added
- if msg == "gohome" then -- my go home command
- print("Goto request from ", id, ", going HOME!")
- shell.run("gohome.lua") -- run my gohome.lua
- end
- if msg == "gocomp" then -- my go to computer command
- print("Goto request from ", id, ", going to Main Computer!")
- shell.run("gotopc.lua") -- run my gohome.lua
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement