goreae

CC VOTING/UI/RESULTS

Jan 3rd, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. function clearScreen()
  2.   term.clear()
  3.   term.setCursorPos(1,1)
  4. end
  5. local tArgs = {...}
  6. local command = tArgs[1]
  7. local ballot = tArgs[2]
  8. if command == "help" then
  9.   print("Availiable Commands are:")
  10.   print("list-lists all saved results.")
  11.   print("delete-deletes a results file.")
  12.   print("view-views current results on a ballot.")
  13. end
  14. if command == "delete" then
  15.   clearScreen()
  16.   print("which results file would you like deleted?")
  17.   local file = read()
  18.   while true do
  19.     print("are you sure you want to delete the "..file.." results file? this cannot be undone!")
  20.     local choice = read()
  21.     if choice == "yes" then
  22.       fs.delete("disk/results/"..file)
  23.       break
  24.     end
  25.     if choice == "no" then
  26.       break
  27.     end
  28.   end
  29. end    
  30. if command == "list" then
  31.   list = fs.list("disk/results")
  32.   for i=1,1000 do
  33.     if list[i] == nil then break end
  34.     print(list[i])
  35.   end
  36. end
  37. if command == "view" then
  38.   print("What results file do you want to view?")
  39.   local file = read()
  40.   hFile = fs.open("disk/results/"..file,"r")
  41.   results = textutils.unserialize(hFile.readLine())
  42.  
  43.   clearScreen()
  44.   print(file)
  45.   print("Yes:"..results[1])
  46.   print("no:"..results[2])
  47.   hFile.close()
  48. end
Advertisement
Add Comment
Please, Sign In to add comment