Advertisement
Dima99

new

Oct 5th, 2014
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.60 KB | None | 0 0
  1. function writeFile()
  2. if fs.exists("new.count") then
  3.  fs.delete("new.count")
  4. end
  5. h = fs.open("new.count", "w")
  6. h.write("last file "..tostring(count))
  7. h.close()
  8. end
  9.  
  10. function readFile()
  11. if fs.exists("new.count") then
  12.  first = false
  13.  h = fs.open("new.count", "r")
  14.  count = h.readAll()
  15.  h.close()
  16.  count = string.gsub(count, "last file ", "")
  17.  count = tonumber(count)
  18. end
  19. end
  20.  
  21. first = true
  22. readFile()
  23. if first then
  24.  count = 1
  25.  h = fs.open("file", "w")
  26.  h.close()
  27.  writeFile()
  28.  elseif not first then
  29.  h = fs.open("file"..tostring(count), "w")
  30.  h.close()
  31.  count = count + 1
  32.  writeFile()
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement