Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CONFIGURATION
- local detector = peripheral.wrap("bottom") -- adjust as needed
- local outputSide = "back"
- -- Whitelist of allowed usernames
- local whitelist = {
- ["CottonLeSergal"] = true,
- ["CartUniverse"] = true
- }
- -- Bounding box coordinates (inclusive)
- local minX, maxX = -26, -24
- local minY, maxY = 77, 77
- local minZ, maxZ = 24, 27
- -- Delay between checks (in seconds)
- local delay = .1
- -- Helper: Check if position is inside bounding box
- local function isInBounds(pos)
- if not pos or not pos.x or not pos.y or not pos.z then
- return false
- end
- return pos.x >= minX and pos.x <= maxX
- and pos.y >= minY and pos.y <= maxY
- and pos.z >= minZ and pos.z <= maxZ
- end
- -- Helper: Check if any whitelisted player is in range & within bounds
- local function validPlayerNearby()
- local players = detector.getOnlinePlayers()
- for _, name in ipairs(players) do
- if whitelist[name] then
- local pos = detector.getPlayerPos(name)
- if isInBounds(pos) then
- return true
- end
- end
- end
- return false
- end
- -- Main Loop
- while true do
- if validPlayerNearby() then
- redstone.setOutput(outputSide, true)
- sleep(5) -- pulse duration
- else
- redstone.setOutput(outputSide, false)
- sleep(delay)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment