Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Redstone Pulser for Liquicrafter
- by Fooman
- v1.0
- April 20, 2013
- ]]--
- local iter
- local w,h = term.getSize()
- --Delay Between Pulses
- local mindelay = 0.2
- --Side to output signal
- local outputside = "bottom"
- --Timer of success screen before program reboots
- local reboottimer = 60
- function pulse()
- rs.setOutput(tostring(outputside), true)
- sleep(0.1)
- rs.setOutput(tostring(outputside), false)
- sleep(mindelay)
- end
- --Pretty Functions
- local function printCentered(str,ypos)
- term.setCursorPos(w/2 - #str/2, ypos)
- term.write(str)
- end
- local function printRight(str,ypos)
- term.setCursorPos(w - #str, ypos)
- term.write(str)
- end
- local function printLeft(str,ypos)
- term.setCursorPos(1 , ypos)
- term.write(str)
- end
- function drawTerminalBG()
- term.clear()
- printCentered(string.rep("-",w),1)
- printCentered("LiquiCrafter Control System", 2)
- printCentered(string.rep("-",w),3)
- printLeft("|",2)
- printRight("|",2)
- local th = 4
- for th=4,h-1 do
- printLeft("|",th)
- printRight("|",th)
- end
- printCentered("How many items would you like to craft?", 7)
- printCentered(string.rep("-",w),h)
- term.setCursorPos(w/2-1,9)
- end
- function drawTerminalProgress(prog)
- printCentered("Currently Crafting:", 11)
- term.setCursorPos(1,12)
- term.clearLine()
- printLeft("|",12)
- printRight("|",12)
- printCentered(tostring(prog),12)
- end
- function drawTerminalSuccess()
- term.setCursorPos(1,7)
- term.clearLine()
- printLeft("|",7)
- printRight("|",7)
- term.setCursorPos(1,9)
- term.clearLine()
- printLeft("|",9)
- printRight("|",9)
- term.setCursorPos(1,11)
- term.clearLine()
- printLeft("|",11)
- printRight("|",11)
- term.setCursorPos(1,12)
- term.clearLine()
- printLeft("|",12)
- printRight("|",12)
- printCentered("Success! "..tostring(iter).." items crafted.", 10)
- printCentered("Press any key to continue.",12)
- end
- --Program Start
- term.clear()
- drawTerminalBG()
- iter = tonumber(read())
- --could use stuff to ensure good input
- for i=1,iter do
- pulse()
- drawTerminalProgress(i)
- end
- --Finished
- drawTerminalSuccess()
- local autotimer = os.startTimer(tonumber(reboottimer))
- local event = os.pullEvent()
- if event == "key" then
- os.reboot()
- elseif event == "timer" then
- os.reboot()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement