kovakovi2000

CC: Remote restarter - rser

Apr 18th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.81 KB | None | 0 0
  1. os.loadAPI("rnc2")
  2. os.loadAPI("ldb2")
  3.  
  4. local prg = shell.getRunningProgram()
  5. local label = os.getComputerLabel()
  6. print(prg)
  7. if label == nil then
  8.     return
  9. end
  10.  
  11. rnc2.setTimeOut(prg, 99)
  12. rnc2.setPort(prg, 1000)
  13. rnc2.setIdenty(prg, 100)
  14.  
  15. while true do
  16.     rnc2.setIdenty(100)
  17.     local res = rnc2.resive(prg)
  18.     if res == "r." .. label then
  19.         rnc2.setIdenty(prg, 101)
  20.         rnc2.send(prg,label .. "> Restarted!")
  21.         rnc2.setIdenty(prg, 100)
  22.         os.reboot()
  23.     elseif res == "l." .. label then
  24.         local x,y,z = gps.locate(2, false)
  25.         local lmsg = label .. "> x:" .. x .. " | y:" .. y ..  " | z:" .. z
  26.         rnc2.setIdenty(prg, 101)
  27.         rnc2.send(prg, lmsg)
  28.         rnc2.setIdenty(prg, 100)
  29.     elseif res ~= nil then
  30.         print("res:" .. res)
  31.     end
  32. end
  33.  
  34. sleep(10)
Add Comment
Please, Sign In to add comment