Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clearScreen()
- term.clear()
- term.setCursorPos(1,1)
- end
- local tArgs = {...}
- local command = tArgs[1]
- local ballot = tArgs[2]
- if command == "help" then
- print("Availiable Commands are:")
- print("list-lists all saved results.")
- print("delete-deletes a results file.")
- print("view-views current results on a ballot.")
- end
- if command == "delete" then
- clearScreen()
- print("which results file would you like deleted?")
- local file = read()
- while true do
- print("are you sure you want to delete the "..file.." results file? this cannot be undone!")
- local choice = read()
- if choice == "yes" then
- fs.delete("disk/results/"..file)
- break
- end
- if choice == "no" then
- break
- end
- end
- end
- if command == "list" then
- list = fs.list("disk/results")
- for i=1,1000 do
- if list[i] == nil then break end
- print(list[i])
- end
- end
- if command == "view" then
- print("What results file do you want to view?")
- local file = read()
- hFile = fs.open("disk/results/"..file,"r")
- results = textutils.unserialize(hFile.readLine())
- clearScreen()
- print(file)
- print("Yes:"..results[1])
- print("no:"..results[2])
- hFile.close()
- end
Advertisement
Add Comment
Please, Sign In to add comment