Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local radars = {'radar_0', 'radar_2'}
- local currentSecond = 0
- local rsDoorSide = 'back'
- local allowedVisitors = { 'csmit195', 'YorickNL', 'blackfiredesigns' }
- function initiate()
- local newRadars = {}
- for _, radar in ipairs(radars) do
- newRadars[_] = peripheral.wrap(radar)
- end
- radars = newRadars
- while true do
- loop()
- currentSecond = currentSecond + 1
- sleep(1)
- end
- end
- function loop()
- -- Every 2 Seconds to reduce amount of sensor calls and potentially limit lag
- if ( currentSecond % 2 == 0 ) then
- -- Probe Sensors
- local isVerified
- for _, radar in ipairs(radars) do
- for index, player in ipairs(radar.getPlayers()) do
- for __, whitelistedPlayer in ipairs(allowedVisitors) do
- if ( player.name == whitelistedPlayer ) then
- setDoorState(true)
- isVerified = true
- end
- end
- end
- end
- if ( not isVerified ) then
- setDoorState(false)
- end
- end
- end
- function setDoorState(state)
- rs.setOutput(rsDoorSide, state)
- end
- initiate()
Advertisement
Add Comment
Please, Sign In to add comment