--Fuel Supply Switcher v2
--by SemlerPDX July2016
-- pastebin get JbXXNjrp SwitchFuel
local function fset()
term.clear()
term.setCursorPos(1,1)
end
--checks to see if door to engine room is open
--opens if it is closed
if (rs.getOutput("back"))~=true then
rs.setOutput("back",true)
end
fset()
textutils.slowPrint("Switching fuel supply from charcoal to coal...", 18)
rs.setOutput("top",true)
sleep(1.75)
fset()
print("Engines are set to burn Coal")
print("")
print("note:")
print("Coal is more abundant but not infinite")
print("Charcoal is infinite but not abundant or efficient")
print("")
print("")
print(" - press any key to switch back to Charcoal -")
-- Main Loop --
while true do
local function fcancel()
local event, key = os.pullEvent("key")
end
local function fmain()
sleep(1)
end
FunctionEnabled = parallel.waitForAny(fcancel,fmain)
if FunctionEnabled == 1 then
rs.setOutput("top",false)
fset()
textutils.slowPrint("Switching fuel supply from coal to charcoal...", 18)
sleep(2)
fset()
print("Engines are now burning Charcoal")
sleep(1)
break
end
end
-- Door Close Countdown
for n=1,20 do
local function fcancel()
local event, key = os.pullEvent("key")
end
local function fmain()
fset()
print("Engines are now burning Charcoal")
print("")
print("")
print("Closing Door in 5 seconds...")
print("")
print(" - press any key to keep Door Open -")
sleep(0.25)
end
FunctionEnabled = parallel.waitForAny(fcancel,fmain)
if FunctionEnabled == 1 then
fset()
sleep(1)
break
end
end
if FunctionEnabled == 2 then
rs.setOutput("back",false)
fset()
end
Comments