Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Setup and variables
- detector = peripheral.wrap("right") --Defines the Detector on the right
- range = 32 --CHANGE ME TO 32 (2 chunks)
- redstonesides = {"left"} --Sides to output signal to.
- sleeptime = 36000 --CHANGE ME TO 36000 (ten minutes)
- chunkowner = "Bipedsnowman"
- --Functions--
- function playersNearby(var)
- local near = detector.isPlayersInRange(var)
- return near
- end
- function setSides(sides, var)
- for i=1, #sides do
- rs.setOutput(sides[i], var)
- end
- end
- function clear()
- term.setBackgroundColor(colours.black) -- Set the background colour to black.
- term.clear() -- Paint the entire display with the current background colour.
- term.setCursorPos(1,1)
- end
- function ownerOnline()
- if getPlayerPos(chunkowner) ~= nil then
- return true
- end
- return false
- end
- function growWill()
- while true do
- if playersNearby(range) or ownerOnline() then
- clear()
- print("Day " .. os.day() .. ": Player nearby. Will collection enabled.")
- setSides(redstonesides, true)
- else
- clear()
- print("Day " .. os.day() .. ": No players nearby. Will collection disabled.")
- setSides(redstonesides, false)
- end
- sleep(sleeptime)
- end
- end
- --Program body--
- growWill()
Advertisement
Add Comment
Please, Sign In to add comment