Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = wrap("top")
- monh = 2
- monl = 4
- monh = monh*5
- monl = monl*7
- lines = {}
- function updatemonitor()
- mon.clear()
- for i, v in ipairs(lines) do
- mon.setCursorPos(i,0)
- mon.write(v)
- end
- end
- function fixtable()
- local tmptable = {}
- for i, v in ipairs(lines) do
- table.insert(tmptable, #tmptable, v)
- end
- lines = tmptable
- end
- function chkline(line)
- if not #lines+1 > monh then
- if not string.len(line) > monl then
- return true
- else
- return false, "Entry too long, Max of "..monl.." characters."
- end
- else
- return false, "No Space. Delete an Entry."
- end
- end
- function add(line)
- local chkl, f = chkline(line)
- if chkl == true then
- table.insert(lines, #lines+1, line)
- updatemonitor()
- else
- print(f)
- end
- end
- function matchline(line)
- for i, v in ipairs(lines) do
- if v:lower() == line:lower() then
- return i
- end
- end
- end
- function rm(inp, cl)
- if type(inp) == "number" then
- table.remove(lines, inp)
- elseif type(inp) == "string" then
- local ml = matchline(inp)
- if ml then
- table.remove(lines, ml)
- else
- print("Invalid line")
- end
- else
- print("Line not specifified")
- end
- fixtable()
- if not cl then
- updatemonitor()
- end
- end
- function clear()
- for i, v in ipairs(lines) do
- rm(i, true)
- end
- updatemonitor()
- end
- while true do
- input = read()
- input = string.lower(input)
- if input == "clear" then
- clear()
- elseif string.sub(input, 1, 3) = "rm " then
- rm(string.sub(input, 4)
- elseif string.sub(input, 1, 4) == "add " then
- add(string.sub(input, 5)
- else
- print("Invalid Command")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement