Advertisement
E-Kemp

Valley master test

Feb 1st, 2023 (edited)
887
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.59 KB | None | 0 0
  1. driveLoc = disk.getMountPath("left")
  2.  
  3. stats = {
  4.   weather = 0
  5. }
  6.  
  7. -- Load stats
  8. file = fs.open(driveLoc.."/stats.txt","r")
  9. if file ~= nil then
  10.   serialised = file.readAll()
  11.   file.close()
  12.   readStats = textutils.unserialise(serialised)
  13.   if readStats ~= nil and readStats.weather ~= nil then  
  14.     stats.weather = readStats.weather
  15.   end
  16. end
  17.  
  18. stats.weather = stats.weather + 1
  19. local newStats = textutils.serialise(stats)
  20. local newFile = fs.open(driveLoc.."/stats.txt",fs.exists(driveLoc.."/stats.txt") and "a" or "w")
  21. newFile.write(newStats)
  22. newFile.close()
  23.  
  24. print(stats.weather)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement