Lua API: Better error checking when converting a location set to a WML variable

This commit is contained in:
Celtic Minstrel 2021-07-02 13:23:26 -04:00
parent c6f4e8db28
commit 695eb8356d

View file

@ -265,8 +265,12 @@ function methods:to_wml_var(name)
local i = 0
wml.variables[name] = nil
self:stable_iter(function(x, y, v)
if type(v) == 'table' then
if wml.valid(v) then
wml.variables[string.format("%s[%d]", name, i)] = v
elseif wml.valid{value = v} then
wml.variables[string.format("%s[%d]", name, i)] = {value = v}
elseif type(v) ~= 'boolean' then
warning('Location set value could not be converted to a WML variable:', v)
end
wml.variables[string.format("%s[%d].x", name, i)] = x
wml.variables[string.format("%s[%d].y", name, i)] = y