Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- c = require("component")
- t = require("term")
- shell = require("shell")
- text = require("text")
- todoList = {"Enter anything to add it to the list, enter remove to remove an item", "Finish TODO List"}
- --functions
- function getInput()
- userInput = text.trim(t.read())
- if userInput == "exit" then
- os.exit()
- elseif userInput == "remove" then
- print("Enter the number of the item you wish to remove")
- userInput = text.trim(t.read())
- if tonumber(userInput) == 1 then
- print("you cant delete that BAD 2YYS")
- return
- end
- removeItem(userInput)
- else
- table.insert(todoList, userInput)
- end
- end
- function removeItem(item)
- table.remove(todoList, tonumber(item))
- end
- function updateScreen()
- t.clear()
- for i,v in ipairs(todoList) do
- print(tostring(i) .. ". " .. tostring(v))
- end
- end
- --Main Code Block
- while true do
- updateScreen()
- getInput()
- end
Advertisement
Add Comment
Please, Sign In to add comment