Advertisement
Archchancellor64

Door Host

May 22nd, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.49 KB | None | 0 0
  1. os.loadAPI("Toolkit")
  2.  
  3. rednet.open("back")
  4.  
  5. pos = {}
  6. offset = {}
  7. offset.x, offset.y, offset.z = 0, -3, 0
  8. pos.x, pos.y, pos.z = gps.locate()
  9. posOff = {}
  10. posOff.x = pos.x + offset.x
  11. posOff.y = pos.y + offset.y
  12. posOff.z = pos.z + offset.z
  13.  
  14. while true do
  15.     state = true
  16.     id, message, protocol = rednet.receive()
  17.     if protocol == "door" then
  18.         distance = Toolkit.distanceTo(message, posOff)
  19.         if distance < 5 then
  20.             state = false
  21.         end
  22.     end
  23.     redstone.setOutput("bottom", state)
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement