Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- driveLoc = disk.getMountPath("left")
- stats = {
- weather = 0
- }
- -- Load stats
- file = fs.open(driveLoc.."/stats.txt","r")
- if file ~= nil then
- serialised = file.readAll()
- file.close()
- readStats = textutils.unserialise(serialised)
- if readStats ~= nil and readStats.weather ~= nil then
- stats.weather = readStats.weather
- end
- end
- stats.weather = stats.weather + 1
- local newStats = textutils.serialise(stats)
- local newFile = fs.open(driveLoc.."/stats.txt",fs.exists(driveLoc.."/stats.txt") and "a" or "w")
- newFile.write(newStats)
- newFile.close()
- print(stats.weather)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement