Advertisement
skypop

Doors

Sep 14th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | None | 0 0
  1. local wi = peripheral.find("WorldInterface")
  2. local ed = peripheral.find("EntityDetector")
  3.  
  4. if not (wi and ed) then
  5.     rs.setOutput("left",true)
  6.     printError("Missing interface: "..(wi and "" or "WorldInterface ")..(ed and "" or "EntityDetector")
  7.     return
  8. end
  9.  
  10. local _,name
  11. local watch = false
  12. local _floor = math.floor
  13. local present = {
  14.     NaturalGeek = false,
  15.     SukaiPoppuGo = false,
  16. }
  17. local prox = {
  18.     NaturalGeek = false,
  19.     SukaiPoppuGo = false,
  20. }
  21.  
  22.  
  23. local function watchUpdate()
  24.     watch = false
  25.     for _,name in pairs(wi.getPlayerList()) do
  26.         if name=="NaturalGeek" then
  27.             watch = true
  28.             present.NaturalGeek = true
  29.         end
  30.         if name=="SukaiPoppuGo" then
  31.             watch = true
  32.             present.SukaiPoppuGo = true
  33.         end
  34.         if present.NaturalGeek and present.SukaiPoppuGo then
  35.             return
  36.         end
  37.     end
  38. end
  39.  
  40. local function check(playerName)
  41.     local d = ed.getPlayerDetails(playerName)
  42.     d = d[playerName]
  43.     local x,y,z =_floor(d.x),_floor(d.y),_floor(d.z)}
  44.     if y == 29
  45.     and (
  46.         (x==-588 and (z==130 or z==134 or z==135)
  47.      or (x==-589 and z==130)
  48.     ) then
  49.         rs.setOutput("left",true)
  50.     end
  51.     return d.distance < 48
  52. end
  53.  
  54. -- -588 29 135
  55. -- -588 29 134
  56. -- -588 29 130
  57. -- -589 29 130
  58.  
  59. local delay = os.startTimer(.1)
  60. while true do
  61.     os.pullEvent("timer")
  62.     watchUpdate()
  63.     if watch then
  64.         if present.NaturalGeek then
  65.             prox.NaturalGeek = check("NaturalGeek")
  66.         end
  67.         if present.SukaiPoppuGo then
  68.             prox.SukaiPoppuGo = check("SukaiPoppuGo")
  69.         end
  70.         watch = prox.NaturalGeek or prox.SukaiPoppuGo
  71.     end
  72.     delay = os.startTimer(watch and 1 or 30)
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement