- Guardar/Carregar estat funciona a nivell bàsic
This commit is contained in:
@@ -65,9 +65,10 @@ game={
|
|||||||
if file then
|
if file then
|
||||||
io.output(file)
|
io.output(file)
|
||||||
io.write("level="..game.level.."\n")
|
io.write("level="..game.level.."\n")
|
||||||
local hero = actors.search("jailer")
|
local hero = actors.search(actors.main.name)
|
||||||
io.write("x="..hero.x.."\n")
|
io.write("x="..hero.x.."\n")
|
||||||
io.write("y="..hero.y.."\n")
|
io.write("y="..hero.y.."\n")
|
||||||
|
io.write("o="..hero.o.."\n")
|
||||||
io.write("[FLAGS]\n")
|
io.write("[FLAGS]\n")
|
||||||
for k,v in pairs(flags) do
|
for k,v in pairs(flags) do
|
||||||
io.write(k.."="..v.."\n")
|
io.write(k.."="..v.."\n")
|
||||||
@@ -84,15 +85,36 @@ game={
|
|||||||
load=function()
|
load=function()
|
||||||
local i=1
|
local i=1
|
||||||
file = io.open(configfolder().."slot"..i..".txt", "r")
|
file = io.open(configfolder().."slot"..i..".txt", "r")
|
||||||
|
local level_name = ""
|
||||||
|
local new_flags={}
|
||||||
|
local new_objects={}
|
||||||
if file then
|
if file then
|
||||||
io.input(file)
|
io.input(file)
|
||||||
|
local k,v=getkeyval(io.read())
|
||||||
|
level_name=v
|
||||||
|
local k,v=getkeyval(io.read()) actors.main.x=tonumber(v)
|
||||||
|
local k,v=getkeyval(io.read()) actors.main.y=tonumber(v)
|
||||||
|
local k,v=getkeyval(io.read()) actors.main.o=v
|
||||||
|
io.read() -- ignore "[FLAGS]" line
|
||||||
|
local line = io.read()
|
||||||
|
while line ~= "[OBJECTS]" do
|
||||||
|
local k,v=getkeyval(line)
|
||||||
|
new_flags[k]=v
|
||||||
|
line = io.read()
|
||||||
|
end
|
||||||
|
line = io.read()
|
||||||
|
while line do
|
||||||
|
table.insert(new_objects, line)
|
||||||
|
line = io.read()
|
||||||
|
end
|
||||||
io.close(file)
|
io.close(file)
|
||||||
end
|
end
|
||||||
fade.fadeout()
|
fade.fadeout()
|
||||||
--game.resume()
|
--game.resume()
|
||||||
actors.main.x=10
|
--actors.main.x=10
|
||||||
actors.main.y=8
|
--actors.main.y=8
|
||||||
game.init("test")
|
|
||||||
|
game.init(level_name,new_flags,new_objects)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
|
|||||||
@@ -50,3 +50,8 @@ function menu_update()
|
|||||||
color(1)
|
color(1)
|
||||||
prnt("JAIL'S ADVENTURE 2",10,10)
|
prnt("JAIL'S ADVENTURE 2",10,10)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function getkeyval(str)
|
||||||
|
local c1,c2=string.find(str,"=")
|
||||||
|
return string.sub(str,1,c1-1), string.sub(str,c2+1)
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user