Hi,
I have the following code in the “init” of the title screen:
(code saves game options and high scores)
local GameOptionsAndHighScoresTable = {}
table.insert(GameOptionsAndHighScoresTable, MusicVolume)
table.insert(GameOptionsAndHighScoresTable, SoundVolume)
table.insert(GameOptionsAndHighScoresTable, GameMode)
for mode = 0, 2 do
for rank = 0, 9 do
table.insert(GameOptionsAndHighScoresTable, HighScoresName[mode][rank])
table.insert(GameOptionsAndHighScoresTable, HighScoresLevel[mode][rank])
table.insert(GameOptionsAndHighScoresTable, HighScoresScore[mode][rank])
end
end
local my_file_path = sys.get_save_file("RedLightRacer", "RLR_PreAlpha1.cfg")
if not sys.save(my_file_path, GameOptionsAndHighScoresTable) then
print("Save Failed!")
end
If I run the game it does produce a “RLR_PreAlpha1.cfg” in folder “RedLightRacer”,
but the data has strange characters and is unreadable by the game?
Code builds with no errors, and as said above it it creating a game data save file…
Thanks!
J.
Also…
Here is the load game data code:
local my_file_path = sys.get_save_file("RedLightRacer", "RLR_PreAlpha1.cfg")
local GameOptionsAndHighScoresTable = sys.load(my_file_path)
if not next(GameOptionsAndHighScoresTable) then
print("Game data file not found.")
end
MusicVolume = table.remove(GameOptionsAndHighScoresTable, 0)
EffectsVolume = table.remove(GameOptionsAndHighScoresTable, 0)
GameMode = table.remove(GameOptionsAndHighScoresTable, 0)
for mode = 0, 2 do
for rank = 0, 9 do
HighScoresName[mode][rank] = table.remove(GameOptionsAndHighScoresTable, 0)
HighScoresLevel[mode][rank] = table.remove(GameOptionsAndHighScoresTable, 0)
HighScoresScore[mode][rank] = table.remove(GameOptionsAndHighScoresTable, 0)
end
end