Mike: created ability to do 'table = GameState.load(SAVE_FILE)

This commit is contained in:
2017-07-30 21:03:49 -07:00
parent d75e61bba9
commit b91883b3b8
3 changed files with 9 additions and 5 deletions

View File

@@ -1,16 +1,18 @@
GameState = {}
-- Supply the table then the name of the table in string format
function GameState.save(tbl, table_name)
saved_table = print_table(tbl, table_name)
function GameState.save(tbl)
saved_table = print_table(tbl)
return saved_table
end
function GameState.load(SAVE_FILE)
-- Pretty sure doing this slash will break it on winblows
-- placeholder is the name of our placeholder variable
-- so we can do things like "actors = GameState.load"
dofile(love.filesystem.getSaveDirectory().. "/" .. SAVE_FILE)
return placeholder
end
function printf (s, ...)
@@ -19,7 +21,8 @@ end
function print_table(tbl, table_name, only_once)
if only_once == nil then
printf("%s = { ", table_name)
table_name = "placeholder"
printf("local %s = { ", table_name)
saved_table = table_name .. " = { "
end
for key,value in pairs(tbl) do