Advertisement
WhamyKaBlamy

ComputerCraft / Tekkit Security Gatehouse More Succinct

Jul 31st, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2.  
  3. local mySensor = sensor.wrap("top")
  4. local Player = false
  5. local Monster = false
  6. local pos = {}
  7. -- These are the things to change for yourself
  8. local door_direction = "right"
  9. local dispenser_direction = "back"
  10. local Y_max = 1
  11. local Y_min = -2
  12. local X_max = 3
  13. local X_min = -2
  14. local Z_max = -4
  15. local Z_min = -7
  16.  
  17.  
  18. while 1>0 do
  19.   Player = false
  20.   Monster = false
  21.   os.sleep(0.5)
  22.   for k,v in pairs(mySensor.getTargets()) do
  23.     if v ~= nil then
  24.       pos = v["Position"]
  25.       if pos["X"] > X_min and pos["X"] < X_max and pos["Y"] > Y_min and pos["Y"] < Y_max and pos["Z"] > Z_min and pos["Z"] < Z_max then
  26.         if v["IsPlayer"] == true then
  27.            Player = true
  28.         else
  29.           Monster = true
  30.         end
  31.       end
  32.     end
  33.   end
  34.   if Player == true then
  35.     redstone.setAnalogOutput(door_direction,15)
  36.   else
  37.     redstone.setAnalogOutput(door_direction,0)
  38.   end
  39.   if Monster == true and Player == false then
  40.     redstone.setAnalogOutput(dispenser_direction,15)
  41.   else
  42.     redstone.setAnalogOutput(dispenser_direction,0)
  43.   end
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement