DMeville

Untitled

May 12th, 2013
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. hasMon = false;
  2. list = {}
  3. i = 0;
  4. len = 0;
  5. if peripheral.isPresent("top") then
  6.     hasMon = true;
  7.     mon = peripheral.wrap("top");
  8.     print("Monitor was found!");
  9.     mon.clear();
  10.     mon.setCursorPos(1,1);
  11. end
  12.  
  13. function nl()
  14.     if hasMon == true then
  15.     local x,y = mon.getCursorPos();
  16.     mon.setCursorPos(1, y+1);
  17.     end
  18. end
  19.  
  20. function printm(str)
  21.     if type(str) ~= "string" then return end
  22.     print(str);
  23.     mon.write(str);
  24.     nl();
  25. end
  26.  
  27. function add()
  28.     print("Enter your task: ");
  29.     listAns = read();
  30.     if type(listAns) == "string" then
  31.         i = i +1;
  32.         len = len +1;
  33.         list[i] = i .. " - " .. listAns;
  34.         printm(list[i]);
  35.         print(i .. " - " .. list[i]);
  36.     end
  37. end
  38.  
  39. function remove()
  40.     print("Which task would you like to remove?");
  41.     removeAns = read();
  42.     if type(listAns) == "number" then
  43.         print("Removing: " .. listAns);
  44.     end
  45. end
  46.  
  47. function start()
  48.     while true do
  49.         print("What would you like to do?");
  50.         print(" - Type \"add\" to add an item");
  51.         print(" - Type \"remove\" to add an item");
  52.         print(" - Type \"quit\" to save and quit");
  53.         ans = read();
  54.         if type(ans) == "string" then
  55.             if ans == "add" then add() end
  56.             if ans == "remove" then remove() end
  57.             if ans == "quit" then
  58.                 printm("Goodbye!");
  59.                 os.shutdown();
  60.             end
  61.         end
  62.     end
  63. end
  64.  
  65. start();
Advertisement
Add Comment
Please, Sign In to add comment