DMeville

Untitled

May 12th, 2013
139
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.     listAns = read();
  29.     if type(listAns) == "string" then
  30.         i = i +1;
  31.         len = len +1;
  32.         list[i] = i .. " - " .. listAns;
  33.         printm(list[i]);
  34.         print(i .. " - " .. list[i]);
  35.     end
  36. end
  37.  
  38. function remove()
  39.     print("removing");
  40. end
  41.  
  42. function start()
  43.     while true do
  44.         print("What would you like to do?");
  45.         print(" - Type \"add\" to add an item");
  46.         print(" - Type \"remove\" to add an item");
  47.         print(" - Type \"quit\" to save and quit");
  48.         ans = read();
  49.         if type(ans) == "string" then
  50.             if ans == "add" then add() end
  51.             if ans == "remove" then remove() end
  52.             if ans == "quit" then
  53.                 printm("Goodbye!");
  54.                 os.shutdown();
  55.             end
  56.         end
  57.     end
  58. end
  59.  
  60. start();
Advertisement
Add Comment
Please, Sign In to add comment