TwitchBlade

todoList_0.0.7

Sep 11th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. c       = require("component")
  2. t       = require("term")
  3. shell   = require("shell")
  4. text    = require("text")
  5.  
  6. todoList = {"Enter anything to add it to the list, enter remove to remove an item", "Finish TODO List"}
  7.  
  8.  
  9. --functions
  10.  
  11. function getInput()
  12.   userInput = text.trim(t.read())
  13.   if userInput == "exit" then
  14.     os.exit()
  15.   elseif userInput == "remove" then
  16.     print("Enter the number of the item you wish to remove")
  17.     userInput = text.trim(t.read())
  18.     if tonumber(userInput) == 1 then
  19.       print("you cant delete that BAD 2YYS")
  20.       return
  21.     end
  22.     removeItem(userInput)
  23.   else
  24.     table.insert(todoList, userInput)
  25.   end
  26. end
  27.  
  28. function removeItem(item)
  29.   table.remove(todoList, tonumber(item))
  30. end
  31.  
  32. function updateScreen()
  33.   t.clear()
  34.   for i,v in ipairs(todoList) do
  35.     print(tostring(i) .. ". " .. tostring(v))
  36.   end
  37. end
  38.  
  39. --Main Code Block
  40. while true do
  41.   updateScreen()
  42.   getInput()
  43. end
Advertisement
Add Comment
Please, Sign In to add comment