Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Name the peripherals for simplicity
- local pd = peripheral.wrap("playerDetector_0")
- local ri = peripheral.wrap("redstoneIntegrator_0")
- -- Set up the range parameter
- local range = 2
- function check_players()
- -- Get a list of players within range
- local players = pd.getPlayersInRange(range)
- -- Set output to true on the "east" side of the redstone integrator if a player is detected
- if #players > 0 then
- ri.setOutput("east", true)
- else
- ri.setOutput("east", false)
- end
- end
- -- Loop to check for players at regular intervals
- while true do
- check_players()
- sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement