First draft of a "variables carrying over between levels" system, seems to work ok, not tested in standalone.
Winzone that saves the variables to a .dat file in savegames folder:
function iid_winzone_save_variables_main(e)
if g_Entity[e]['plrinzone']==1 then
f=io.open ("savegames\\SavedVariables.dat","w+")
f:write(g_Var1 .. "\n")
f:write(g_Var2 .. "\n")
f:write(g_Var3 .. "\n")
f:write(g_Var4 .. "\n")
f:write(g_Var5 .. "\n")
f:close()
JumpToLevelIfUsed(e)
end
end
Zone for loading the variables on next level, destroyed when run once.
function getVariable(n)
local f = io.open("savegames\\SavedVariables.dat", "r")
local count = 1
for line in f:lines() do
if count == n then
f:close()
return line
end
count = count + 1
end
f:close()
end
function iid_load_variables_main(e)
if g_Entity[e]['plrinzone']==1 then
g_Var1= getVariable(1)
g_Var2 = getVariable(2)
g_Var3 = getVariable(3)
g_Var4 = getVariable(4)
g_Var5 = getVariable(5)
Destroy(e)
end
end
EDIT, spotted an error, fixed.