Mike: created ability to do 'table = GameState.load(SAVE_FILE)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user