Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[USER CONFIG VARIABLES]]
- MONITOR_NAME = "monitor_0" --gathered by using a wired modem; alternatively, directly connect the monitor to the computer
- WITHER_OFF_TIME = 5 --in seconds; how long the cooldown is before spawner turns on
- WITHER_ON_TIME = 10 --in seconds; how long the spawner stays on per cycle
- RS_OUT = "right" --string relative side
- START_ON = true
- --[[----------------------------------------------------------------]]
- local monitor = peripheral.wrap(MONITOR_NAME) --Initialize monitor
- if not monitor then --Check if monitor is wired, adjacent, or missing
- monitor = peripheral.find("monitor")
- if not monitor then
- error("Monitor not found! Double check peripheral name.")
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- term.write("Running!") --Give an output to computer before swapping print output to monitor
- term.redirect(monitor)
- local switch = START_ON
- local userSwitch = START_ON
- rs.setOutput(RS_OUT, switch)
- local eng = {
- [true] = {"ON", "Running..."},
- [false] = {"OFF", "Collecting drops"}
- } --Used to translate bools to ON/OFF for user readability
- local offTimer = os.startTimer(WITHER_ON_TIME)
- local onTimer --to be initialized later
- local function termDraw()
- term.clear()
- term.setCursorPos(1,1)
- write("Wither Skeleton Farm")
- term.setCursorPos(4, 4)
- write("\n STATUS: " .. eng[switch][2] .. "\n\n User Control: " .. eng[switch][1])
- end
- function Main() --Event handling and loop
- termDraw()
- rs.setOutput(RS_OUT, switch)
- while true do
- local e, p = os.pullEvent()
- if e == "timer" and p == offTimer then
- if switch and userSwitch then
- switch = false
- onTimer = os.startTimer(WITHER_OFF_TIME)
- Main()
- end
- elseif e == "timer" and p == onTimer then
- if not switch and userSwitch then
- switch = true
- offTimer = os.startTimer(WITHER_ON_TIME)
- Main()
- end
- elseif e == "monitor_touch" then
- switch = not switch
- userSwitch = switch
- Main()
- end
- end
- end
- Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement