no arg in lua

This commit is contained in:
p.kosyh 2011-02-23 10:11:27 +00:00
parent 9218f58b1d
commit abbdebbf41
15 changed files with 146 additions and 130 deletions

View file

@ -27,7 +27,7 @@ stead.module_init(function()
return cmd return cmd
end end
end end
return f(s, press, mb, x, y, px, py, unpack(arg)) return f(s, press, mb, x, y, px, py, ...)
end) end)
end) end)
@ -36,15 +36,15 @@ function(f, s, cmd, x, y, ...)
if cmd == 'click' then if cmd == 'click' then
local r,v local r,v
if here().click then if here().click then
r,v = call(here(), 'click', x, y, unpack(arg)); r,v = call(here(), 'click', x, y, ...);
elseif s.click then elseif s.click then
r,v = call(s, 'click', x, y, unpack(arg)); r,v = call(s, 'click', x, y, ...);
end end
if r == nil and v == nil then if r == nil and v == nil then
return nil, true return nil, true
end end
return r,v return r,v
end end
return f(s, cmd, x, y, unpack(arg)) return f(s, cmd, x, y, ...)
end) end)
-- vim:ts=4 -- vim:ts=4

View file

@ -344,14 +344,14 @@ function (f, s, cmd, ...)
if cmd == 'use_debug' then if cmd == 'use_debug' then
return debug_tool:inv() return debug_tool:inv()
end end
return f(s, cmd, unpack(arg)) return f(s, cmd, ...)
end) end)
stead.module_init(function() stead.module_init(function()
input.key = stead.hook(input.key, input.key = stead.hook(input.key,
function(f, s, down, key, ...) function(f, s, down, key, ...)
if not here().debug and down and key == 'f7' then return 'use_debug' end if not here().debug and down and key == 'f7' then return 'use_debug' end
return f(s, down, key, unpack(arg)) return f(s, down, key, ...)
end) end)
putf('debug_tool', me()); putf('debug_tool', me());
end) end)

View file

@ -22,7 +22,7 @@ format = {
stead.fmt = stead.hook(stead.fmt, function(f, ...) stead.fmt = stead.hook(stead.fmt, function(f, ...)
local utf8 local utf8
local r = f(unpack(arg)) local r = f(...)
if game.codepage == 'UTF-8' or game.codepage == 'utf-8' then if game.codepage == 'UTF-8' or game.codepage == 'utf-8' then
utf8 = true utf8 = true
end end

View file

@ -117,7 +117,7 @@ function player_go(self, where) -- cmd iface
end end
function player_goto(self, where, ...) -- real work function player_goto(self, where, ...) -- real work
local v, r = stead.go(self, where, unpack(arg)); local v, r = stead.go(self, where, ...);
return v, r; return v, r;
end end
@ -139,7 +139,7 @@ end
stead.goback = goback stead.goback = goback
function goto(what, back, noenter, noexit, nodsc, ...) function goto(what, back, noenter, noexit, nodsc, ...)
return me():goto(what, back, noenter, noexit, nodsc, unpack(arg)); return me():goto(what, back, noenter, noexit, nodsc, ...);
end end
stead.goto = goto stead.goto = goto
@ -189,7 +189,7 @@ iface.fmt = function(self, cmd, st, moved, r, av, objs, pv) -- st -- changed sta
end end
stead.go = stead.hook(stead.go, function(f, ...) stead.go = stead.hook(stead.go, function(f, ...)
local r,v = f(unpack(arg)) local r,v = f(...)
if type(r) == 'string' and cctx() then if type(r) == 'string' and cctx() then
pr (r) pr (r)
end end
@ -208,7 +208,7 @@ end)
iface.cmd = stead.hook(iface.cmd, function(f, ...) iface.cmd = stead.hook(iface.cmd, function(f, ...)
NEED_SCENE = nil NEED_SCENE = nil
return f(unpack(arg)) return f(...)
end) end)
player = stead.inherit(player, function(v) player = stead.inherit(player, function(v)

View file

@ -27,8 +27,9 @@ iface.xref = function(self, str, obj, ...)
end end
local a = '' local a = ''
local i local i
for i = 1, stead.table.maxn(arg) do local varg = {...}
a = a..','..arg[i] for i = 1, stead.table.maxn(varg) do
a = a..','..varg[i]
end end
if isXaction(o) and not o.id then if isXaction(o) and not o.id then
return stead.cat('<a:'..cmd..deref(obj)..a..'>',str,'</a>'); return stead.cat('<a:'..cmd..deref(obj)..a..'>',str,'</a>');
@ -270,12 +271,15 @@ end
fmt = function(...) fmt = function(...)
local i, res local i, res
if arg == nil then local a={...}
if stead.table.maxn(a) == 0 then
return false return false
end end
for i=1,stead.table.maxn(arg) do
if type(arg[i]) == 'string' then for i=1,stead.table.maxn(a) do
local s = stead.string.gsub(arg[i],'\t', ' '):gsub('[\n]+', ' '); if type(a[i]) == 'string' then
local s = stead.string.gsub(a[i],'\t', ' '):gsub('[\n]+', ' ');
s = stead.string.gsub(s, '\\?[\\^]', { ['^'] = '\n', ['\\^'] = '^', s = stead.string.gsub(s, '\\?[\\^]', { ['^'] = '\n', ['\\^'] = '^',
['\\\\'] = '\\' }); ['\\\\'] = '\\' });
res = stead.par('', res, s); res = stead.par('', res, s);

View file

@ -3,13 +3,13 @@ room = stead.inherit(room, function(v)
if call_bool(s, 'hideinv') then if call_bool(s, 'hideinv') then
me():disable_all(); me():disable_all();
end end
return f(s, unpack(arg)) return f(s, ...)
end) end)
v.left = stead.hook(v.left, function(f, s, ...) v.left = stead.hook(v.left, function(f, s, ...)
if call_bool(s, 'hideinv') then if call_bool(s, 'hideinv') then
me():enable_all(); me():enable_all();
end end
return f(s, unpack(arg)) return f(s, ...)
end) end)
return v return v
end) end)

View file

@ -15,7 +15,7 @@ game.kbd = stead.hook(game.kbd, function(f, s, down, key, ...)
end end
return return
end end
return f(s, down, key, unpack(arg)); return f(s, down, key, ...);
end) end)
-- vim:ts=4 -- vim:ts=4

View file

@ -203,7 +203,7 @@ game.action = stead.hook(game.action, function (f, s, cmd, ...)
-- end -- end
return r,v -- nothing todo return r,v -- nothing todo
end end
return f(s, cmd, unpack(arg)) return f(s, cmd, ...)
end) end)
lookup_inp = function() lookup_inp = function()
@ -257,9 +257,9 @@ stead.module_init(function()
input.cursor = '_' input.cursor = '_'
input.key = stead.hook(input.key, input.key = stead.hook(input.key,
function(f, ...) function(f, ...)
local r = input_kbd(unpack(arg)) local r = input_kbd(...)
if r then return r end if r then return r end
return f(unpack(arg)) return f(...)
end) end)
end) end)

View file

@ -13,7 +13,7 @@ game.action = stead.hook(game.action, function(f, s, cmd, ...)
end end
return r,v return r,v
end end
return f(s, cmd, unpack(arg)); return f(s, cmd, ...);
end) end)
stead.module_init(function() stead.module_init(function()
@ -22,22 +22,24 @@ stead.module_init(function()
input.key_event = { key = key, down = down }; input.key_event = { key = key, down = down };
return 'user_kbd' return 'user_kbd'
end end
return f(s, down, key, unpack(arg)) return f(s, down, key, ...)
end) end)
input._key_hooks = {} input._key_hooks = {}
end) end)
function hook_keys(...) function hook_keys(...)
local i local i
for i = 1, stead.table.maxn(arg) do local a = {...};
input._key_hooks[tostring(arg[i])] = true; for i = 1, stead.table.maxn(a) do
input._key_hooks[tostring(a[i])] = true;
end end
end end
function unhook_keys(...) function unhook_keys(...)
local i local i
for i = 1, stead.table.maxn(arg) do local a = {...};
input._key_hooks[tostring(arg[i])] = nil; for i = 1, stead.table.maxn(a) do
input._key_hooks[tostring(a[i])] = nil;
end end
end end

View file

@ -5,13 +5,13 @@ function player_action(self, what, ...)
obj = ref(self.where):srch(what); obj = ref(self.where):srch(what);
end end
if not obj then if not obj then
return call(game, 'action', what, unpack(arg)); --player_do(self, what, unpack(arg)); return call(game, 'action', what, ...); --player_do(self, what, ...);
end end
v, r = player_take(self, what, unpack(arg)); v, r = player_take(self, what, ...);
if not v then if not v then
v, r = call(obj, 'act', unpack(arg)); v, r = call(obj, 'act', ...);
if not v and r ~= true then if not v and r ~= true then
v, r = call(game, 'act', obj, unpack(arg)); v, r = call(game, 'act', obj, ...);
end end
end end
return v, r; return v, r;
@ -32,12 +32,12 @@ function player_use(self, what, onwhat, ...)
end end
if onwhat == nil then -- only one? if onwhat == nil then -- only one?
if scene_use_mode then if scene_use_mode then
return self:action(what, unpack(arg)); -- call act return self:action(what, ...); -- call act
else else
v, r = call(ref(obj),'inv', unpack(arg)); -- call inv v, r = call(ref(obj),'inv', ...); -- call inv
end end
if not v and r ~= true then if not v and r ~= true then
v, r = call(game, 'inv', obj, unpack(arg)); v, r = call(game, 'inv', obj, ...);
end end
return v, r; return v, r;
end end
@ -53,13 +53,13 @@ function player_use(self, what, onwhat, ...)
obj2 = ref(obj2) obj2 = ref(obj2)
if not scene_use_mode or isSceneUse(obj) then if not scene_use_mode or isSceneUse(obj) then
v, r = call(obj, 'use', obj2, unpack(arg)); v, r = call(obj, 'use', obj2, ...);
if r ~= false then if r ~= false then
vv = call(obj2, 'used', obj, unpack(arg)); vv = call(obj2, 'used', obj, ...);
end end
end end
if not v and not vv then if not v and not vv then
v, r = call(game, 'use', obj, obj2, unpack(arg)); v, r = call(game, 'use', obj, obj2, ...);
end end
return stead.par(' ', v, vv); return stead.par(' ', v, vv);
end end
@ -83,17 +83,17 @@ function vobj_act(self, ...)
if ref(o) and ref(o).where then if ref(o) and ref(o).where then
return goto(ref(o).where); return goto(ref(o).where);
end end
return call(ref(r),'act', self.nam, unpack(arg)); return call(ref(r),'act', self.nam, ...);
end end
function vobj_used(self, ...) function vobj_used(self, ...)
local o, r = here():srch(self.nam); local o, r = here():srch(self.nam);
return call(ref(r),'used', self.nam, unpack(arg)); return call(ref(r),'used', self.nam, ...);
end end
function vobj_use(self, ...) function vobj_use(self, ...)
local o, r = here():srch(self.nam); local o, r = here():srch(self.nam);
return call(ref(r),'use', self.nam, unpack(arg)); return call(ref(r),'use', self.nam, ...);
end end
function vobj(name, dsc, w) function vobj(name, dsc, w)

View file

@ -5,8 +5,9 @@ stead.make_snapshot = function(nr)
h.txt = '' h.txt = ''
h.write = function(s, ...) h.write = function(s, ...)
local i local i
for i = 1, stead.table.maxn(arg) do local a = {...};
s.txt = s.txt .. tostring(arg[i]); for i = 1, stead.table.maxn(a) do
s.txt = s.txt .. tostring(a[i]);
end end
end end
local old = game._snapshots; game._snapshots = nil local old = game._snapshots; game._snapshots = nil
@ -65,7 +66,7 @@ function delete_snapshot(nr)
end end
iface.cmd = stead.hook(iface.cmd, function(f, ...) iface.cmd = stead.hook(iface.cmd, function(f, ...)
local r,v = f(unpack(arg)); local r,v = f(...);
if MAKE_SNAPSHOT ~= nil then if MAKE_SNAPSHOT ~= nil then
stead.make_snapshot(MAKE_SNAPSHOT); stead.make_snapshot(MAKE_SNAPSHOT);
MAKE_SNAPSHOT = nil MAKE_SNAPSHOT = nil

View file

@ -23,11 +23,11 @@ stead = {
end end
if event == 'kbd' then if event == 'kbd' then
if type(input.key) == 'function' then if type(input.key) == 'function' then
return input:key(unpack(arg)); -- pressed, event return input:key(...); -- pressed, event
end end
elseif event == 'mouse' then elseif event == 'mouse' then
if type(input.click) == 'function' then if type(input.click) == 'function' then
return input:click(unpack(arg)); -- pressed, x, y, mb return input:click(...); -- pressed, x, y, mb
end end
end end
return return
@ -97,16 +97,16 @@ end
function callpush(v, ...) function callpush(v, ...)
stead.call_top = stead.call_top + 1; stead.call_top = stead.call_top + 1;
stead.cctx[stead.call_top] = { txt = nil, self = v, action = false }; stead.cctx[stead.call_top] = { txt = nil, self = v, action = false };
args = arg args = {...};
arg1 = arg[1] arg1 = args[1]
arg2 = arg[2] arg2 = args[2]
arg3 = arg[3] arg3 = args[3]
arg4 = arg[4] arg4 = args[4]
arg5 = arg[5] arg5 = args[5]
arg6 = arg[6] arg6 = args[6]
arg7 = arg[7] arg7 = args[7]
arg8 = arg[8] arg8 = args[8]
arg9 = arg[9] arg9 = args[9]
-- dirty but clean and fast :) -- dirty but clean and fast :)
self = v self = v
end end
@ -146,35 +146,38 @@ end
stead.pget = pget stead.pget = pget
function p(...) function p(...)
local i local i
for i = 1, stead.table.maxn(arg) do local a = {...}
cctx().txt = stead.par('',cctx().txt, tostring(arg[i])); for i = 1, stead.table.maxn(a) do
cctx().txt = stead.par('',cctx().txt, tostring(a[i]));
end end
cctx().txt = stead.cat(cctx().txt, ' '); cctx().txt = stead.cat(cctx().txt, ' ');
end end
stead.p = p stead.p = p
function pr(...) function pr(...)
local i local i
for i = 1, stead.table.maxn(arg) do local a = {...}
cctx().txt = stead.par('',cctx().txt, tostring(arg[i])); for i = 1, stead.table.maxn(a) do
cctx().txt = stead.par('',cctx().txt, tostring(a[i]));
end end
end end
stead.pr = pr stead.pr = pr
function pn(...) function pn(...)
p(unpack(arg)); p(...);
cctx().txt = stead.par('',cctx().txt,'^'); cctx().txt = stead.par('',cctx().txt,'^');
end end
stead.pn = pn stead.pn = pn
-- merge strings with "space" as separator -- merge strings with "space" as separator
function par(space,...) function par(space,...)
local i, res local i, res
for i = 1, stead.table.maxn(arg) do local a = {...};
if type(arg[i]) == 'string' then for i = 1, stead.table.maxn(a) do
if type(a[i]) == 'string' then
if res == nil then if res == nil then
res = "" res = ""
else else
res = res..space; res = res..space;
end end
res = res..arg[i]; res = res..a[i];
end end
end end
return res; return res;
@ -187,9 +190,10 @@ function cat(v,...)
return nil return nil
end end
res = v; res = v;
for i = 1, stead.table.maxn(arg) do local a = {...}
if type(arg[i]) == 'string' then for i = 1, stead.table.maxn(a) do
res = res..arg[i]; if type(a[i]) == 'string' then
res = res..a[i];
end end
end end
return res; return res;
@ -282,12 +286,13 @@ end
fmt = function(...) fmt = function(...)
local i, res local i, res
if arg == nil then local a = {...};
if stead.table.maxn(a) == 0 then
return false return false
end end
for i=1,stead.table.maxn(arg) do for i=1,stead.table.maxn(a) do
if type(arg[i]) == 'string' then if type(a[i]) == 'string' then
local s = stead.string.gsub(arg[i],'[\t ]+',' '); local s = stead.string.gsub(a[i],'[\t ]+',' ');
s = stead.string.gsub(s, '[\n]+', ' '); s = stead.string.gsub(s, '[\n]+', ' ');
s = stead.string.gsub(s, '\\?[\\^]', { ['^'] = '\n', ['\\^'] = '^', ['\\\\'] = '\\'} ); s = stead.string.gsub(s, '\\?[\\^]', { ['^'] = '\n', ['\\^'] = '^', ['\\\\'] = '\\'} );
res = stead.par('', res, s); res = stead.par('', res, s);
@ -804,8 +809,8 @@ function call(v, n, ...)
return v[n]; return v[n];
end end
if type(v[n]) == 'function' then if type(v[n]) == 'function' then
callpush(v, unpack(arg)) callpush(v, ...)
local a,b = v[n](v, unpack(arg)); local a,b = v[n](v, ...);
-- boolean, nil -- boolean, nil
if type(a) == 'boolean' and b == nil then if type(a) == 'boolean' and b == nil then
b, a = a, stead.pget() b, a = a, stead.pget()
@ -847,8 +852,8 @@ function call_bool(v, n, ...)
end end
if type(v[n]) == 'function' then if type(v[n]) == 'function' then
callpush(v, unpack(arg)) callpush(v, ...)
local r,v = v[n](v, unpack(arg)); local r,v = v[n](v, ...);
callpop(); callpop();
return r,v; return r,v;
end end
@ -867,8 +872,8 @@ function call_value(v, n, ...)
if type(v[n]) ~= 'function' then if type(v[n]) ~= 'function' then
return v[n]; return v[n];
end end
callpush(v, unpack(arg)) callpush(v, ...)
local r,v = v[n](v, unpack(arg)); local r,v = v[n](v, ...);
callpop(); callpop();
return r,v; return r,v;
end end
@ -1003,11 +1008,12 @@ end
function phrase_seen(s, enb, ...) function phrase_seen(s, enb, ...)
local i, ph local i, ph
if stead.table.maxn(arg) == 0 then local a = {...}
stead.table.insert(arg, self); if stead.table.maxn(a) == 0 then
stead.table.insert(a, self);
end end
for i=1,stead.table.maxn(arg) do for i=1,stead.table.maxn(a) do
ph = dialog_phrase(s, arg[i]); ph = dialog_phrase(s, a[i]);
local r = not isPhrase(ph) or isRemoved(ph) or ph:disabled(); local r = not isPhrase(ph) or isRemoved(ph) or ph:disabled();
if not enb then r = not r end if not enb then r = not r end
if r then return false end if r then return false end
@ -1017,20 +1023,21 @@ end
function dialog_pseen(s, ...) function dialog_pseen(s, ...)
return phrase_seen(s, true, unpack(arg)); return phrase_seen(s, true, ...);
end end
function dialog_punseen(s, ...) function dialog_punseen(s, ...)
return phrase_seen(s, false, unpack(arg)); return phrase_seen(s, false, ...);
end end
function ponoff(s, on, ...) function ponoff(s, on, ...)
local i, ph local i, ph
if stead.table.maxn(arg) == 0 then local a = {...}
stead.table.insert(arg, self); if stead.table.maxn(a) == 0 then
stead.table.insert(a, self);
end end
for i=1,stead.table.maxn(arg) do for i=1,stead.table.maxn(a) do
ph = dialog_phrase(s, arg[i]); ph = dialog_phrase(s, a[i]);
if isPhrase(ph) and not isRemoved(ph) then if isPhrase(ph) and not isRemoved(ph) then
if on then if on then
ph:enable(); ph:enable();
@ -1043,11 +1050,12 @@ end
function dialog_prem(s, ...) function dialog_prem(s, ...)
local i, ph local i, ph
if stead.table.maxn(arg) == 0 then local a = {...}
stead.table.insert(arg, self); if stead.table.maxn(a) == 0 then
stead.table.insert(a, self);
end end
for i=1,stead.table.maxn(arg) do for i=1,stead.table.maxn(a) do
ph = dialog_phrase(s, arg[i]); ph = dialog_phrase(s, a[i]);
if isPhrase(ph) then if isPhrase(ph) then
ph:remove(); ph:remove();
end end
@ -1055,11 +1063,11 @@ function dialog_prem(s, ...)
end end
function dialog_pon(self,...) function dialog_pon(self,...)
return ponoff(self, true, unpack(arg)); return ponoff(self, true, ...);
end end
function dialog_poff(self,...) function dialog_poff(self,...)
return ponoff(self, false, unpack(arg)); return ponoff(self, false, ...);
end end
function dlg(v) --constructor function dlg(v) --constructor
@ -1243,13 +1251,13 @@ function player_action(self, what, ...)
local v,r,obj local v,r,obj
obj = ref(self.where):srch(what); obj = ref(self.where):srch(what);
if not obj then if not obj then
return call(ref(game), 'action', what, unpack(arg)); --player_do(self, what, unpack(arg)); return call(ref(game), 'action', what, ...); --player_do(self, what, ...);
end end
v, r = player_take(self, what, unpack(arg)); v, r = player_take(self, what, ...);
if not v then if not v then
v, r = call(ref(obj), 'act', unpack(arg)); v, r = call(ref(obj), 'act', ...);
if not v and r ~= true then if not v and r ~= true then
v, r = call(ref(game), 'act', obj, unpack(arg)); v, r = call(ref(game), 'act', obj, ...);
end end
end end
return v, r; return v, r;
@ -1261,7 +1269,7 @@ function player_take(self, what, ...)
if not obj then if not obj then
return nil, false; return nil, false;
end end
v,r = call(ref(obj), 'tak', unpack(arg)); v,r = call(ref(obj), 'tak', ...);
if v and r ~= false then if v and r ~= false then
take(obj, w); take(obj, w);
end end
@ -1282,12 +1290,12 @@ function player_use(self, what, onwhat, ...)
end end
if onwhat == nil then -- only one? if onwhat == nil then -- only one?
if scene_use_mode then if scene_use_mode then
return self:action(what, unpack(arg)); -- call act return self:action(what, ...); -- call act
else else
v, r = call(ref(obj),'inv', unpack(arg)); -- call inv v, r = call(ref(obj),'inv', ...); -- call inv
end end
if not v and r ~= true then if not v and r ~= true then
v, r = call(game, 'inv', obj, unpack(arg)); v, r = call(game, 'inv', obj, ...);
end end
return v, r; return v, r;
end end
@ -1299,13 +1307,13 @@ function player_use(self, what, onwhat, ...)
return game.err, false; return game.err, false;
end end
if not scene_use_mode or isSceneUse(ref(obj)) then if not scene_use_mode or isSceneUse(ref(obj)) then
v, r = call(ref(obj), 'use', obj2, unpack(arg)); v, r = call(ref(obj), 'use', obj2, ...);
if r ~= false then if r ~= false then
vv = call(ref(obj2), 'used', obj, unpack(arg)); vv = call(ref(obj2), 'used', obj, ...);
end end
end end
if not v and not vv then if not v and not vv then
v, r = call(game, 'use', obj, obj2, unpack(arg)); v, r = call(game, 'use', obj, obj2, ...);
end end
return stead.par(' ', v, vv); return stead.par(' ', v, vv);
end end
@ -1387,7 +1395,7 @@ function go(self, where, back)
end end
function player_goto(self, where, ...) function player_goto(self, where, ...)
local v, r = go(self, where, unpack(arg)); local v, r = go(self, where, ...);
return v, r; return v, r;
end end
@ -1519,7 +1527,7 @@ function for_everything(f, ...)
local is_ok = function(s) local is_ok = function(s)
return true return true
end end
for_each(_G, '_G', f, is_ok, unpack(arg)) for_each(_G, '_G', f, is_ok, ...)
end end
function do_ini(self, load) function do_ini(self, load)
@ -1531,7 +1539,7 @@ function do_ini(self, load)
stead.functions[o].key_name = k; stead.functions[o].key_name = k;
end end
local function call_ini(k, o, ...) local function call_ini(k, o, ...)
v = stead.par('', v, call(o, 'ini'), unpack(arg)); v = stead.par('', v, call(o, 'ini'), ...);
end end
math.randomseed(tonumber(os.date("%m%d%H%M%S"))) math.randomseed(tonumber(os.date("%m%d%H%M%S")))
@ -1639,7 +1647,7 @@ function for_each(o, n, f, fv, ...)
nn = n.."."..k; nn = n.."."..k;
end end
end end
f(k, v, unpack(arg)); f(k, v, ...);
end end
end end
end end
@ -1648,23 +1656,23 @@ function isCode(s)
return type(s) == 'function' and type(stead.functions[s]) == 'table' return type(s) == 'function' and type(stead.functions[s]) == 'table'
end end
function for_each_codeblock(f,...) function for_each_codeblock(f,...)
for_each(_G, '_G', f, isCode, unpack(arg)) for_each(_G, '_G', f, isCode, ...)
end end
function for_each_object(f,...) function for_each_object(f,...)
for_each(_G, '_G', f, isObject, unpack(arg)) for_each(_G, '_G', f, isObject, ...)
end end
function for_each_player(f,...) function for_each_player(f,...)
for_each(_G, '_G', f, isPlayer, unpack(arg)) for_each(_G, '_G', f, isPlayer, ...)
end end
function for_each_room(f,...) function for_each_room(f,...)
for_each(_G, '_G', f, isRoom, unpack(arg)) for_each(_G, '_G', f, isRoom, ...)
end end
function for_each_list(f,...) function for_each_list(f,...)
for_each(_G, '_G', f, isList, unpack(arg)) for_each(_G, '_G', f, isList, ...)
end end
function clearvar (v) function clearvar (v)
@ -2170,40 +2178,40 @@ end
function xref(str, obj, ...) function xref(str, obj, ...)
if type(str) ~= 'string' then return nil; end; if type(str) ~= 'string' then return nil; end;
return iface:xref(str, obj, unpack(arg)); return iface:xref(str, obj, ...);
end end
function pseen(...) function pseen(...)
if not isDialog(here()) then if not isDialog(here()) then
return return
end end
return here():pseen(unpack(arg)); return here():pseen(...);
end end
function punseen(...) function punseen(...)
if not isDialog(here()) then if not isDialog(here()) then
return return
end end
return here():punseen(unpack(arg)); return here():punseen(...);
end end
function pon(...) function pon(...)
if not isDialog(here()) then if not isDialog(here()) then
return return
end end
here():pon(unpack(arg)); here():pon(...);
end end
function poff(...) function poff(...)
if not isDialog(here()) then if not isDialog(here()) then
return return
end end
here():poff(unpack(arg)); here():poff(...);
end end
function prem(...) function prem(...)
if not isDialog(here()) then if not isDialog(here()) then
return return
end end
here():prem(unpack(arg)); here():prem(...);
end end
function lifeon(what) function lifeon(what)
@ -2279,12 +2287,12 @@ function vobj_act(self, ...)
if ref(o) and ref(o).where then if ref(o) and ref(o).where then
return goto(ref(o).where); return goto(ref(o).where);
end end
return call(ref(r),'act', self.key, unpack(arg)); return call(ref(r),'act', self.key, ...);
end end
function vobj_used(self, ...) function vobj_used(self, ...)
local o, r = here():srch(self.nam); local o, r = here():srch(self.nam);
return call(ref(r),'used', self.key, unpack(arg)); return call(ref(r),'used', self.key, ...);
end end
function vobj(key, name, dsc, w) function vobj(key, name, dsc, w)
@ -2700,7 +2708,7 @@ end
function inherit(o, f) function inherit(o, f)
return function(...) return function(...)
return f(o(unpack(arg))) return f(o(...))
end end
end end
stead.inherit = inherit stead.inherit = inherit
@ -2715,7 +2723,7 @@ function hook(o, f)
else else
ff = o ff = o
end end
return f(ff, unpack(arg)) return f(ff, ...)
end end
end end
stead.hook = hook stead.hook = hook

View file

@ -11,7 +11,7 @@ game.action = stead.hook(game.action, function(f, s, cmd, ...)
end end
return r,v return r,v
end end
return f(s, cmd, unpack(arg)); return f(s, cmd, ...);
end) end)
stead.module_init(function() stead.module_init(function()

View file

@ -81,7 +81,7 @@ vars_object = obj {
obj = stead.hook(obj, obj = stead.hook(obj,
function(f, v, ...) function(f, v, ...)
__vars_fill(v) __vars_fill(v)
return f(v, unpack(arg)) return f(v, ...)
end) end)
stead.module_init(function() stead.module_init(function()

View file

@ -82,9 +82,10 @@ end
stead.fmt = stead.hook(stead.fmt, function(f, ...) stead.fmt = stead.hook(stead.fmt, function(f, ...)
local i, res, s local i, res, s
for i=1,stead.table.maxn(arg) do local a = {...}
if type(arg[i]) == 'string' then for i=1,stead.table.maxn(a) do
s = __do_xact(arg[i]); if type(a[i]) == 'string' then
s = __do_xact(a[i]);
res = stead.par('', res, s):gsub('\\?[\\{}]', { [ '\\{' ] = '{', [ '\\}' ] = '}' }); res = stead.par('', res, s):gsub('\\?[\\{}]', { [ '\\{' ] = '{', [ '\\}' ] = '}' });
end end
end end
@ -123,7 +124,7 @@ end
xroom = stead.inherit(room, function(v) xroom = stead.inherit(room, function(v)
v.look = stead.hook(v.look, function(f, s,...) v.look = stead.hook(v.look, function(f, s,...)
local xdsc = call(s, 'xdsc'); local xdsc = call(s, 'xdsc');
return par(' ', xdsc, f(s, unpack(arg))); return par(' ', xdsc, f(s, ...));
end) end)
return v return v
end) end)