ColdIV

doorOpener

Jul 12th, 2021 (edited)
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. local args = {...}
  2. local protocol = "doorOpener"
  3. local hostname = "doorLock"
  4.  
  5. if args[1] == "update" then
  6.     if args[2] == "run" then
  7.         shell.run("pastebin", "run", "FuQ3WvPs 3iLiWjzs doorOpener run")
  8.     else
  9.         shell.run("pastebin", "run", "FuQ3WvPs 3iLiWjzs doorOpener")
  10.     end
  11. else
  12.     rednet.open("back")
  13.    
  14.     local hosts = rednet.lookup(protocol, hostname)
  15.     if tonumber(hosts) then
  16.         local tmpHosts = hosts
  17.         hosts = {}
  18.         hosts[1] = tmpHosts
  19.     end
  20.    
  21.     for i = 1, 2, 1 do
  22.         local m = {}
  23.         m.x, m.y, m.z = gps.locate()
  24.        
  25.         for i = 1, #hosts, 1 do
  26.             if not rednet.send(hosts[i], textutils.serialize(m), protocol)  then
  27.                 error("Could not send message.")
  28.             else
  29. --              print("Send: " .. textutils.serialize(m))
  30.             end
  31.         end
  32.        
  33.         sleep(1)
  34.     end
  35.    
  36.     rednet.close("back")
  37. end
Add Comment
Please, Sign In to add comment