Advertisement
aynoblo

door host

Apr 8th, 2020
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. --main door host V2
  2. local rChannel=102
  3. local hChannel=103
  4. local osName=door
  5. local change=0
  6. local x,y,z=gps.locate()
  7.  
  8. modem=peripheral.wrap("back")
  9. modem.open(rChannel)
  10. modem.open(hChannel)
  11. print("modem status:",modem.isOpen(rChannel))
  12. print("modem status:",modem.isOpen(hChannel))
  13.  
  14. while true do
  15.     local event, osef, osef, osef, recieved, osef = os.pullEvent("modem_message")
  16.     command=textutils.unserialize(recieved)
  17.     command.cy=command.cy-69
  18.     if command~=#table then
  19.         if command.cx==nil or command.cy==nil or command.cz==nil then
  20.             print("nil")
  21.         else
  22.             if command.cx>=-4 and command.cx<=10 and command.cy>=60 and command.cy<=67 and command.cz>=119 and command.cz<=142 then
  23.                 if command.cx>=-1 and command.cx<=7 and command.cy>=60 and command.cy<=67 and command.cz>=129 and command.cz<=132 then
  24.                     print("-----------------------")
  25.                     redstone.setOutput("top",true)
  26.                     redstone.setOutput("front",true)
  27.                     sleep(1)
  28.                     redstone.setOutput("front",false)
  29.                     doorState="open"
  30.                     print("door opened")
  31.                     print(command.cx)
  32.                     print(command.cy)
  33.                     print(command.cz)
  34.                 else
  35.                     print("-----------------------")
  36.                     redstone.setOutput("top",false)
  37.                     redstone.setOutput("front",true)
  38.                     sleep(1)
  39.                     redstone.setOutput("front",false)
  40.                     doorState="close"
  41.                     print("door closed")
  42.                     print(command.cx)
  43.                     print(command.cy)
  44.                     print(command.cz)
  45.                 end
  46.             end
  47.         end
  48.     end
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement