Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function init()
- rednet.open("back")
- if (rednet.isOpen(modemSide)) then
- print("[OK] Wi-fi activated")
- showCommands()
- else
- print("Wi-fi activation error. Maybe wrong side?")
- return false
- end
- end
- function showCommands()
- print("\n~~~~\nVvedite komandu dlya cherepaxi:\n1. Online\n2. GPS\n~~~~\n")
- local command = read()
- if (command == "Online") then
- checkTurtleOnline()
- elseif( command == "GPS" ) then
- sendGPStoTurtle()
- else
- end
- end
- function checkTurtleOnline()
- rednet.broadcast("Who is online?", "loader-1")
- local senderId, message, protocol = rednet.receive()
- print(tostring(senderId), " is online.")
- showCommands()
- end
- function sendGPSCommand(message)
- print(message)
- local command = read()
- rednet.broadcast(command, "loader-1")
- end
- function sendGPStoTurtle()
- rednet.broadcast("Move to the point by XYZ", "loader-1")
- local senderId, message, protocol = rednet.receive()
- if (message == "Vvedite X") then
- sendGPSCommand(message)
- end
- senderId, message, protocol = rednet.receive()
- if (message == "Vvedite Y") then
- sendGPSCommand(message)
- end
- senderId, message, protocol = rednet.receive()
- if (message == "Vvedite Z") then
- sendGPSCommand(message)
- end
- senderId, message, protocol = rednet.receive()
- if (message == "Ne rabotaet GPS. Proverte vashi GPS vishki.") then
- print("Izvinite, cherepaxa naxoditsa vne radiusa vishek ili vishki viklucheni.")
- showCommands()
- end
- if (message == "Ya na meste naznacheniya") then
- sendGPSCommand(message)
- showCommands()
- end
- end
- return { init = init }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement