Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Main function*
- local renderTimer;
- local bExit = false; -- TODO: move this up
- local events = {}
- local timerEvents = {}
- local activeTimers = {}
- local function registerTimer(fFunct, nDelay)
- local timerT = os.startTimer(nDelay)
- timerEvents[fFunct] = nDelay
- activeTimers[timerT] = fFunct
- return timerT
- end
- function events.timer(timerT)
- if activeTimers[timerT] then
- print("We has!")
- if activeTimers[timerT]() then
- print("It wants MOAR!")
- activeTimers[os.startTimer(timerEvents[activeTimers[timerT]])] = activeTimers[timerT] -- Problem?
- activeTimers[timerT] = nil
- else
- print("STOP! HAMM0R TIEM!")
- end
- end
- end
- function events.char(sChar)
- if sChar == "x" then
- bExit = true
- term.clear()
- term.setCursorPos(1, 1)
- print("Goodbye!")
- end
- end
- setmetatable(events, {__index = function(_, k) return function(...) print("Event: " .. k .. "; Args: ", unpack(arg)) end end})
- local function main(cmdArg)
- --local opt = unnamed_function(cmdArg) -- TODO: find function name for this.
- showSplash()
- --loadConfig() --TODO: Impliment this
- -- Start render timer -- NEED TO DO BELOW getNode; until getNode uses not http.get
- -- Get pluginz.
- plib.getNode(config["sMasterLink"], pasteTree, true)
- registerTimer(render, 0.1)
- -- Could cache this, too.
- term.setCursorPos(1,1)
- while not bExit do
- local sEvent, param1, param2 = os.pullEvent()
- local eRes = events[sEvent] and events[sEvent](param1, param2)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment