vars module added

This commit is contained in:
p.kosyh 2010-06-18 09:04:41 +00:00
parent 2c8c66b4d7
commit 080120de2b
2 changed files with 31 additions and 1 deletions

2
debian/changelog vendored
View file

@ -12,7 +12,7 @@ instead (1.2.0) unstable; urgency=low
* hook and inherit;
* entered/left human friendly actions;
* stead.cmd, stead.args added;
* require added (modules: goto, xobj, input, click, dbg);
* require added (modules: goto, xobj, input, click, vars, dbg);
* time of save slots;
* check_version added;
* taketo/takef added;

30
stead/vars.lua Normal file
View file

@ -0,0 +1,30 @@
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)