Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- counter = 0
- errorlol = false
- savedCounter = 0
- saveText = ""
- function love.load()
- contents = love.filesystem.read("ichdrehdurchcounter.txt")
- print(contents)
- errorlol = contents == nil
- if not errorlol then
- counter = tonumber(contents)
- end
- end
- function love.update(dt)
- end
- function love.draw()
- if errorlol then
- love.graphics.print("Error while loading the counter file", 50, 50)
- else
- love.graphics.print("Ich dreh durch: " .. tostring(counter), 50, 50)
- end
- if savedCounter > 0 then
- love.graphics.print("File " .. saveText, 100, 300)
- savedCounter = savedCounter - 1
- end
- end
- function saveFile()
- succ = love.filesystem.write("ichdrehdurchcounter.txt", counter)
- if succ then saveText = "saved!"
- else saveText = "saving failed..." end
- savedCounter = 120 * 3
- end
- function love.touchpressed( id, x, y, dx, dy, pressure )
- counter = counter + 1
- saveFile()
- end
- -- saveFile()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement