Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[USER CONFIG VARIABLES]]
- MONITOR_NAME = "monitor_2" --gathered by using a wired modem; alternatively, directly connect the monitor to the computer
- WITHER_SPAWN_DELAY = 2 --in seconds
- WITHER_HEAD_CLEAR_DELAY = 300 --in seconds
- --RELAY LOCATIONS: These must either be adjacent to the computer, or connected to that side of the computer in the world with redstone
- SOUL_SAND_RELAY = "bottom" --Replace these sides with whatever side your relays are on that will control each part of construction
- HEAD_RELAY = "right"
- CLEAR_RELAY = "left"
- --[[]]
- 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 = false
- local eng = {[true] = "ON", [false] = "OFF"} --Used to translate bools to ON/OFF for user readability
- local timer = os.startTimer(WITHER_SPAWN_DELAY)
- local headsTimer = os.startTimer(0) --set to 0 to immediately clear heads when run, just in case
- local function oneThenTwo()
- rs.setOutput(SOUL_SAND_RELAY, true) --Build frame
- os.sleep(1)
- rs.setOutput(SOUL_SAND_RELAY, false)
- os.sleep(.5)
- rs.setOutput(HEAD_RELAY, true) --Build head
- os.sleep(1)
- rs.setOutput(HEAD_RELAY, false)
- end
- local function clearHeads()
- rs.setOutput(CLEAR_RELAY, true)
- os.sleep(3)
- rs.setOutput(CLEAR_RELAY, false)
- end
- local function termDraw()
- term.clear()
- term.setCursorPos(1,1)
- write("Wither Farm")
- term.setCursorPos(4, 4)
- write("\n STATUS: " .. eng[switch])
- end
- function Main() --Event handling and loop
- termDraw()
- while true do
- local e, p = os.pullEvent()
- if e == "timer" and p == timer then
- if switch then
- oneThenTwo()
- end
- timer = os.startTimer(WITHER_SPAWN_DELAY)
- elseif e == "timer" and p == headsTimer then
- if switch then
- clearHeads()
- end
- headsTimer = os.startTimer(WITHER_HEAD_CLEAR_DELAY)
- elseif e == "monitor_touch" then
- switch = not switch
- Main()
- end
- end
- end
- Main()
Advertisement
Add Comment
Please, Sign In to add comment