Advertisement
PaffcioStudio

Turtle - Klient

Feb 2nd, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. rednet.open("back") --Open rednet, make clearing the screen a single function
  2. function clear() term.clear() term.setCursorPos(1, 1) end
  3. while true do
  4. clear()
  5. print("Polaczono, ID: ", os.computerID(), ". Szukam turtle...")
  6. print("Upewnij sie ze turtle ma wlaczony serwer.")
  7. id, msg = rednet.receive() --Wait for a turtle to say it is "Listening"
  8. if msg == "Listening" then
  9.   rednet.send(id, "goto") --When a waiting turtle is found send the command (goto) to its ID so it can ready for the transmision of coordinates
  10.   clear()
  11.   print("Turtle znaleziony, wprowadz koordynaty...")
  12.   print("Upewnij sie, ze posiadasz satelite GPS.")
  13.   print("Podaj pozycje X")
  14.   local gox = tonumber(io.read()) --Get the coordinates from the player, they could be aquired by another means if needed
  15.   clear()
  16.   print("Podaj pozycje Y")
  17.   local goy = tonumber(io.read())
  18.   clear()
  19.   print("Podaj pozycje Z")
  20.   local goz = tonumber(io.read())
  21.   clear()
  22.   print("Koordynaty to: ")
  23.   print("X: ",x)
  24.   print("Y: ",y)
  25.   print("Z: ",z)
  26.   print("Koordynaty wyslane do turtla.")
  27.   rednet.send(id, tostring(gox)) --Convert the coordinates to strings (as rednet only sends strings) and send them to the waiting turtle
  28.   sleep(0.5)
  29.   rednet.send(id, tostring(goy))
  30.   sleep(0.5)
  31.   rednet.send(id, tostring(goz))
  32. end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement