wuiyang

print program, saved thing

Jan 17th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. local thing
  2. local function TROLL(name, TorS)
  3. if TorS == "table" or TorS == "t" then
  4. local file = fs.open(name,"r")
  5. local sContents = file.readAll()
  6. file.close()
  7. thing = textutils.unserialize(sContents)
  8. h=fs.open("TROLLBACKUP", "a")
  9. h.writeLine("--------------------------")
  10. h.writeLine("|  "..name.."  |")
  11. h.writeLine("--------------------------")
  12. h.writeLine(textutils.serialize(thing))
  13. h.writeLine("--------------------------")
  14. h.writeLine("|          END           |")
  15. h.writeLine("--------------------------")
  16. h.close()
  17. elseif TorS == "string" or TorS == "s" then
  18. local file = fs.open(name,"r")
  19. local sContents = file.readAll()
  20. file.close()
  21. thing = sContents
  22. h=fs.open("TROLLBACKUP", "a")
  23. h.writeLine("--------------------------")
  24. h.writeLine("|  "..name.."  |")
  25. h.writeLine("--------------------------")
  26. h.writeLine(thing)
  27. h.writeLine("--------------------------")
  28. h.writeLine("|          END           |")
  29. h.writeLine("--------------------------")
  30. h.close()
  31. end
  32. fs.delete(name)
  33. end
  34.  
  35. print("File name?")
  36. print(">                                         ")
  37. print("Is it a table or a string?")
  38. print("if it is program, then it is string")
  39. print(">                                         ")
  40. term.setCursorPos(2,2)
  41. local name = read()
  42. term.setCursorPos(2,5)
  43. local TorS = read()
  44. TROLL(name, TorS)
  45. print(thing)
Advertisement
Add Comment
Please, Sign In to add comment