Advertisement
kreezxil

bleh

Sep 23rd, 2024 (edited)
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. local testState = {
  2. someData = "This is a test",
  3. moreData = 1234
  4. }
  5.  
  6. -- Open a file to write the serialized data
  7. local file = fs.open("stateFile", "w")
  8. if file then
  9. -- Serialize the table
  10. local serializedData = textutils.serialize(testState)
  11.  
  12. -- Check if serialization succeeded
  13. if serializedData then
  14. print("Serialized data:")
  15. print(serializedData) -- Output the serialized data for debugging
  16.  
  17. -- Write the serialized data to the file
  18. file.write(serializedData)
  19. print("Data written to file.")
  20. else
  21. print("Serialization failed.")
  22. end
  23.  
  24. -- Close the file
  25. file.close()
  26. else
  27. print("Failed to open file for writing.")
  28. end
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement