This repository has been archived on 2019-04-06. You can view files and clone it, but cannot push or open issues or pull requests.
adventin/stead/vars.lua

31 lines
563 B
Lua
Raw Normal View History

2010-06-18 12:04:41 +03:00
isForSave = hook(isForSave,
function (f, k, v, s, ...) -- k - key, v - value, s -- parent table
local i,v
if type(s.var) == 'table' then
for i,v in ipairs(s.var) do
if v == k then
return true
end
end
end
return f(k, v, s, unpack(arg))
end)
obj = inherit(obj,
function(v)
local k,o
local vars = {}
if type(v.var) == 'table' then
for k,o in pairs(v.var) do
if tonumber(k) and type(o) == 'string' then
stead.table.insert(vars, o)
else
v[k] = o
stead.table.insert(vars, k);
end
end
v.var = vars;
end
return v
end)