DMeville

Untitled

May 12th, 2013
138
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(removeAns) == "string" then
  43.         removeAns = tonumber(removeAns);
  44.         print("Removing: " .. removeAns);
  45.     end
  46.     print("Nothing");
  47. end
  48.  
  49. function start()
  50.     while true do
  51.         print("What would you like to do?");
  52.         print(" - Type \"add\" to add an item");
  53.         print(" - Type \"remove\" to add an item");
  54.         print(" - Type \"quit\" to save and quit");
  55.         ans = read();
  56.         if type(ans) == "string" then
  57.             if ans == "add" then add() end
  58.             if ans == "remove" then remove() end
  59.             if ans == "quit" then
  60.                 printm("Goodbye!");
  61.                 os.shutdown();
  62.             end
  63.         end
  64.     end
  65. end
  66.  
  67. start();
Advertisement
Add Comment
Please, Sign In to add comment