itssnowing

Untitled

Jul 18th, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. --Setup and variables
  2. detector = peripheral.wrap("right") --Defines the Detector on the right
  3. range = 32 --CHANGE ME TO 32 (2 chunks)
  4. redstonesides = {"left"} --Sides to output signal to.
  5. sleeptime = 36000 --CHANGE ME TO 36000 (ten minutes)
  6. chunkowner = "Bipedsnowman"
  7.  
  8. --Functions--
  9. function playersNearby(var)
  10. local near = detector.isPlayersInRange(var)
  11. return near
  12. end
  13.  
  14. function setSides(sides, var)
  15. for i=1, #sides do
  16. rs.setOutput(sides[i], var)
  17. end
  18. end
  19.  
  20. function clear()
  21. term.setBackgroundColor(colours.black) -- Set the background colour to black.
  22. term.clear() -- Paint the entire display with the current background colour.
  23. term.setCursorPos(1,1)
  24. end
  25.  
  26. function ownerOnline()
  27. if getPlayerPos(chunkowner) ~= nil then
  28. return true
  29. end
  30. return false
  31. end
  32.  
  33. function growWill()
  34. while true do
  35. if playersNearby(range) or ownerOnline() then
  36. clear()
  37. print("Day " .. os.day() .. ": Player nearby. Will collection enabled.")
  38. setSides(redstonesides, true)
  39. else
  40. clear()
  41. print("Day " .. os.day() .. ": No players nearby. Will collection disabled.")
  42. setSides(redstonesides, false)
  43. end
  44. sleep(sleeptime)
  45. end
  46. end
  47.  
  48. --Program body--
  49. growWill()
  50.  
  51.  
  52.  
  53.  
Advertisement
Add Comment
Please, Sign In to add comment