Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Writing and reading files — Gideros Forum

Writing and reading files

WickedWicked Member
edited February 2014 in Game & application design
Hello everyone :) ,
(Sorry about another question , just trying to work this out and have no clue no matter what i have looked at)

local function LoadHighscore()
local file = io.open("|D|settings.txt","r")
if not file then
highscore = 0
else
highscore = tonumber(file:read("*line"))
file:close()
end
end

Firstly i have That code to load the highscore on startup and if it dosent exist then put the highscore as 0 then later on when the game ends i have

local function saveScore()
local file=io.open("|D|settings.txt","w+")
file:write(highscore .. "\n")
file:close()
end

That called so it saves the score but when a new game starts the highscore isnt there why is this?

Thanks in advance
Wicked

Comments

Sign In or Register to comment.