Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- local mySensor = sensor.wrap("top")
- local Player = false
- local Monster = false
- local pos = {}
- -- These are the things to change for yourself
- local door_direction = "right"
- local dispenser_direction = "back"
- local Y_max = 1
- local Y_min = -2
- local X_max = 3
- local X_min = -2
- local Z_max = -4
- local Z_min = -7
- while 1>0 do
- Player = false
- Monster = false
- os.sleep(0.5)
- for k,v in pairs(mySensor.getTargets()) do
- if v ~= nil and v["IsPlayer"] == true then
- pos = v["Position"]
- 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
- Player = true
- end
- elseif v~= nil and v["IsPlayer"] == false then
- pos = v["Position"]
- if pos["Z"] < Z_max and pos["Z"] > Z_min and pos["Y"] > Y_min and pos["Y"] < Y_max and pos["X"] > X_min and pos["X"] < X_max then
- Monster = true
- end
- end
- end
- if Player == true then
- redstone.setAnalogOutput(door_direction,15)
- else
- redstone.setAnalogOutput(door_direction,0)
- end
- if Monster == true and Player == false then
- redstone.setAnalogOutput(dispenser_direction,15)
- else
- redstone.setAnalogOutput(dispenser_direction,0)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement