Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local rs = peripheral.find("redstoneIntegrator")
- if not rs then error("No redstone integrator") end
- local dandelifeon = "south"
- local destructor = "north"
- local constructor = "up"
- local placer = "east"
- local lever = "west"
- local cancellationPending = false
- local function pulse(direction, duration)
- if not duration then duration = 1 end
- rs.setOutput(direction, true)
- sleep(duration)
- rs.setOutput(direction, false)
- end
- local function initOutput(direction)
- rs.setOutput(direction, false)
- end
- initOutput(dandelifeon)
- initOutput(destructor)
- initOutput(constructor)
- initOutput(placer)
- local function main()
- print("Cellular Block Farm")
- while not cancellationPending do
- if rs.getInput(lever) then
- print("Running Dandelifeon...")
- pulse(placer)
- pulse(dandelifeon, 50 + 2)
- print("Dandelifon cycle finished")
- else
- pulse(destructor)
- pulse(constructor)
- pulse(dandelifeon, 2)
- end
- end
- print("Okay, finished cleanup, goodbye...")
- end
- local function canceller()
- local oldPullEvent = os.pullEvent
- os.pullEvent = os.pullEventRaw
- print("Program is running now, hold Ctrl+T (terminate) to shutdown.")
- while true do
- local event = os.pullEventRaw("terminate")
- if event == "terminate" then
- os.pullEvent = oldPullEvent
- print("Cancellation was requested, finishing up safely...")
- cancellationPending = true
- return
- end
- end
- end
- parallel.waitForAll(main, canceller)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement