Jump to content

Saving the game


AlexGCC
 Share

Recommended Posts

You would have to write your settings/save data to a file. This could be any kind of file. For instance like savegame.json or .xml.

--Load the save game file
local path = "mysavegame.data" 
local stream = FileSystem:WriteFile(path) 
if (stream==nil) then Debug:Error("Failed to write save game.") end

--Write save game data
stream:WriteLine("LevelFinished:1") 
stream:Release() 

--Load the save game
stream = FileSystem:ReadFile(path) 
if (stream==nil)then Debug:Error("Failed to read file.") end

--Loop over save game lines
while (not stream:EOF()) do
	System:Print(stream:ReadLine()) 
end

stream:Release()

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...