mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-28 09:09:31 +00:00
Only check for major version number when loading saves; don't save undefined arguments
This commit is contained in:
parent
dde89502da
commit
c6dc614c32
1 changed files with 9 additions and 2 deletions
11
anselme.lua
11
anselme.lua
|
|
@ -293,16 +293,23 @@ local vm_mt = {
|
||||||
--- save/load script state
|
--- save/load script state
|
||||||
-- only saves variables full names and values, so make sure to not change important variables, paragraphs and functions names between a save and a load
|
-- only saves variables full names and values, so make sure to not change important variables, paragraphs and functions names between a save and a load
|
||||||
load = function(self, data)
|
load = function(self, data)
|
||||||
assert(data.anselme_version == anselme.version, ("trying to load a save from Anselme %s but current Anselme version is %s"):format(data.anselme_version, anselme.version))
|
local saveMajor, currentMajor = data.anselme_version:match("^[^%.]*"), anselme.version:match("^[^%.]*")
|
||||||
|
assert(saveMajor == currentMajor, ("trying to load data from an incompatible version of Anselme; save was done using %s but current version is %s"):format(data.anselme_version, anselme.version))
|
||||||
for k, v in pairs(data.variables) do
|
for k, v in pairs(data.variables) do
|
||||||
self.state.variables[k] = v
|
self.state.variables[k] = v
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
save = function(self)
|
save = function(self)
|
||||||
|
local vars = {}
|
||||||
|
for k, v in pairs(self.state.variables) do
|
||||||
|
if v.type ~= "undefined argument" then
|
||||||
|
vars[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
return {
|
return {
|
||||||
anselme_version = anselme.version,
|
anselme_version = anselme.version,
|
||||||
variables = self.state.variables
|
variables = vars
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue