Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hasMon = false;
- list = {}
- i = 1;
- len = 0;
- if peripheral.isPresent("top") then
- hasMon = true;
- mon = peripheral.wrap("top");
- print("Monitor was found!");
- mon.clear();
- mon.setCursorPos(1,1);
- end
- function nl()
- if hasMon == true then
- local x,y = mon.getCursorPos();
- mon.setCursorPos(1, y+1);
- end
- end
- function printm(str)
- if type(str) ~= "string" then return end
- mon.write(str);
- nl();
- end
- function drawScreen()
- if hasMon == true then
- mon.setCursorPos(1,1);
- mon.clear();
- for j = 1,len do
- printm(list[j]);
- end
- end
- end
- function add()
- print("Enter your task: ");
- listAns = read();
- if type(listAns) == "string" then
- list[i] = i .. " - " .. listAns;
- printm(list[i]);
- print(i .. " - " .. list[i]);
- i = i +1;
- len = len +1;
- end
- end
- function removeFromList(n)
- table.remove(list, n);
- end
- function remove()
- print("Which task would you like to remove?");
- removeAns = read();
- if type(removeAns) == "string" then
- removeAns = tonumber(removeAns);
- if removeAns <= len then
- removeFromList(removeAns);
- end
- end
- drawScreen();
- end
- function start()
- while true do
- print("What would you like to do?");
- print(" - Type \"add\" to add an item");
- print(" - Type \"remove\" to add an item");
- print(" - Type \"quit\" to save and quit");
- ans = read();
- if type(ans) == "string" then
- if ans == "add" then add() end
- if ans == "remove" then remove() end
- if ans == "quit" then
- printm("Goodbye!");
- os.shutdown();
- end
- end
- end
- end
- start();
Advertisement
Add Comment
Please, Sign In to add comment