Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[User Config]]
- local selfName = "Endoflame Controller"
- local fuelBurnTime = 360
- local fuelDropTime = 6.8
- local redstoneCompareSide = "right"
- local redstoneOutputSide = "back"
- --[[]]
- local masterSwitch = false
- local switch = false
- local dict = {
- [true] = "Burning fuel..",
- [false] = "Dropping fuel..",
- ["mana"] = "Mana full. Sleeping..."
- }
- local manaFull = rs.getInput(redstoneCompareSide)
- local burnTimer
- local dropTimer
- local function checkRedstoneState()
- local newState = rs.getInput(redstoneCompareSide)
- if newState ~= manaFull then --If the state has changed
- manaFull = newState
- return true
- end
- end
- local function toggle()
- masterSwitch = not masterSwitch
- end
- local function draw(arg)
- term.clear()
- term.setCursorPos(1,1)
- write(selfName)
- write("\n\n" .. dict[arg])
- write("\n\n\n Press spacebar to drop fuel no matter the conditions, and T to toggle the controller on or off.")
- end
- local function dropManual()
- switch = false
- draw(switch)
- rs.setOutput(redstoneOutputSide, false)
- end
- local function dropOn()
- switch = false
- draw(switch)
- rs.setOutput(redstoneOutputSide, false)
- dropTimer = os.startTimer(fuelDropTime)
- end
- local function dropOff()
- switch = true
- draw(switch)
- rs.setOutput(redstoneOutputSide, true)
- burnTimer = os.startTimer(fuelBurnTime)
- end
- function EventHandler()
- local event, param1 = os.pullEvent()
- if event == "redstone" and checkRedstoneState() then
- if not manaFull then
- dropOn()
- else
- draw("mana")
- end
- elseif event == "timer" and param1 == burnTimer and masterSwitch then
- dropOn()
- elseif event == "timer" and param1 == dropTimer and masterSwitch then
- dropOff()
- elseif event == "key" and param1 == 57 then
- dropManual()
- elseif event == "key" and param1 == 20 then
- toggle()
- end
- Main()
- end
- function Main()
- draw(switch)
- EventHandler()
- end
- Main()
Advertisement
Add Comment
Please, Sign In to add comment