diff --git a/stead/click.lua b/stead/click.lua index fe77bb2..56d845a 100644 --- a/stead/click.lua +++ b/stead/click.lua @@ -27,7 +27,7 @@ stead.module_init(function() return cmd end end - return f(s, press, mb, x, y, px, py, unpack(arg)) + return f(s, press, mb, x, y, px, py, ...) end) end) @@ -36,15 +36,15 @@ function(f, s, cmd, x, y, ...) if cmd == 'click' then local r,v if here().click then - r,v = call(here(), 'click', x, y, unpack(arg)); + r,v = call(here(), 'click', x, y, ...); elseif s.click then - r,v = call(s, 'click', x, y, unpack(arg)); + r,v = call(s, 'click', x, y, ...); end if r == nil and v == nil then return nil, true end return r,v end - return f(s, cmd, x, y, unpack(arg)) + return f(s, cmd, x, y, ...) end) -- vim:ts=4 diff --git a/stead/dbg.lua b/stead/dbg.lua index f7a4403..c5b594d 100644 --- a/stead/dbg.lua +++ b/stead/dbg.lua @@ -344,14 +344,14 @@ function (f, s, cmd, ...) if cmd == 'use_debug' then return debug_tool:inv() end - return f(s, cmd, unpack(arg)) + return f(s, cmd, ...) end) stead.module_init(function() input.key = stead.hook(input.key, function(f, s, down, key, ...) 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) putf('debug_tool', me()); end) diff --git a/stead/format.lua b/stead/format.lua index 182292f..451826d 100644 --- a/stead/format.lua +++ b/stead/format.lua @@ -22,7 +22,7 @@ format = { stead.fmt = stead.hook(stead.fmt, function(f, ...) local utf8 - local r = f(unpack(arg)) + local r = f(...) if game.codepage == 'UTF-8' or game.codepage == 'utf-8' then utf8 = true end diff --git a/stead/goto.lua b/stead/goto.lua index 5f8e9b2..7470d19 100644 --- a/stead/goto.lua +++ b/stead/goto.lua @@ -117,7 +117,7 @@ function player_go(self, where) -- cmd iface end 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; end @@ -139,7 +139,7 @@ end stead.goback = goback 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 stead.goto = goto @@ -189,7 +189,7 @@ iface.fmt = function(self, cmd, st, moved, r, av, objs, pv) -- st -- changed sta end 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 pr (r) end @@ -208,7 +208,7 @@ end) iface.cmd = stead.hook(iface.cmd, function(f, ...) NEED_SCENE = nil - return f(unpack(arg)) + return f(...) end) player = stead.inherit(player, function(v) diff --git a/stead/gui.lua b/stead/gui.lua index 6f2fa42..8a41c51 100644 --- a/stead/gui.lua +++ b/stead/gui.lua @@ -27,8 +27,9 @@ iface.xref = function(self, str, obj, ...) end local a = '' local i - for i = 1, stead.table.maxn(arg) do - a = a..','..arg[i] + local varg = {...} + for i = 1, stead.table.maxn(varg) do + a = a..','..varg[i] end if isXaction(o) and not o.id then return stead.cat('',str,''); @@ -270,12 +271,15 @@ end fmt = function(...) local i, res - if arg == nil then + local a={...} + + if stead.table.maxn(a) == 0 then return false end - for i=1,stead.table.maxn(arg) do - if type(arg[i]) == 'string' then - local s = stead.string.gsub(arg[i],'\t', ' '):gsub('[\n]+', ' '); + + for i=1,stead.table.maxn(a) do + if type(a[i]) == 'string' then + local s = stead.string.gsub(a[i],'\t', ' '):gsub('[\n]+', ' '); s = stead.string.gsub(s, '\\?[\\^]', { ['^'] = '\n', ['\\^'] = '^', ['\\\\'] = '\\' }); res = stead.par('', res, s); diff --git a/stead/hideinv.lua b/stead/hideinv.lua index f01f6dc..92034e4 100644 --- a/stead/hideinv.lua +++ b/stead/hideinv.lua @@ -3,13 +3,13 @@ room = stead.inherit(room, function(v) if call_bool(s, 'hideinv') then me():disable_all(); end - return f(s, unpack(arg)) + return f(s, ...) end) v.left = stead.hook(v.left, function(f, s, ...) if call_bool(s, 'hideinv') then me():enable_all(); end - return f(s, unpack(arg)) + return f(s, ...) end) return v end) diff --git a/stead/hotkeys.lua b/stead/hotkeys.lua index 5c6c8aa..e5c598a 100644 --- a/stead/hotkeys.lua +++ b/stead/hotkeys.lua @@ -15,7 +15,7 @@ game.kbd = stead.hook(game.kbd, function(f, s, down, key, ...) end return end - return f(s, down, key, unpack(arg)); + return f(s, down, key, ...); end) -- vim:ts=4 diff --git a/stead/input.lua b/stead/input.lua index 1bfec37..8c1f883 100644 --- a/stead/input.lua +++ b/stead/input.lua @@ -203,7 +203,7 @@ game.action = stead.hook(game.action, function (f, s, cmd, ...) -- end return r,v -- nothing todo end - return f(s, cmd, unpack(arg)) + return f(s, cmd, ...) end) lookup_inp = function() @@ -257,9 +257,9 @@ stead.module_init(function() input.cursor = '_' input.key = stead.hook(input.key, function(f, ...) - local r = input_kbd(unpack(arg)) + local r = input_kbd(...) if r then return r end - return f(unpack(arg)) + return f(...) end) end) diff --git a/stead/kbd.lua b/stead/kbd.lua index e407576..f29f874 100644 --- a/stead/kbd.lua +++ b/stead/kbd.lua @@ -13,7 +13,7 @@ game.action = stead.hook(game.action, function(f, s, cmd, ...) end return r,v end - return f(s, cmd, unpack(arg)); + return f(s, cmd, ...); end) stead.module_init(function() @@ -22,22 +22,24 @@ stead.module_init(function() input.key_event = { key = key, down = down }; return 'user_kbd' end - return f(s, down, key, unpack(arg)) + return f(s, down, key, ...) end) input._key_hooks = {} end) function hook_keys(...) local i - for i = 1, stead.table.maxn(arg) do - input._key_hooks[tostring(arg[i])] = true; + local a = {...}; + for i = 1, stead.table.maxn(a) do + input._key_hooks[tostring(a[i])] = true; end end function unhook_keys(...) local i - for i = 1, stead.table.maxn(arg) do - input._key_hooks[tostring(arg[i])] = nil; + local a = {...}; + for i = 1, stead.table.maxn(a) do + input._key_hooks[tostring(a[i])] = nil; end end diff --git a/stead/object.lua b/stead/object.lua index 5278a0b..f2539a8 100644 --- a/stead/object.lua +++ b/stead/object.lua @@ -5,13 +5,13 @@ function player_action(self, what, ...) obj = ref(self.where):srch(what); end 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 - v, r = player_take(self, what, unpack(arg)); + v, r = player_take(self, what, ...); if not v then - v, r = call(obj, 'act', unpack(arg)); + v, r = call(obj, 'act', ...); if not v and r ~= true then - v, r = call(game, 'act', obj, unpack(arg)); + v, r = call(game, 'act', obj, ...); end end return v, r; @@ -32,12 +32,12 @@ function player_use(self, what, onwhat, ...) end if onwhat == nil then -- only one? if scene_use_mode then - return self:action(what, unpack(arg)); -- call act + return self:action(what, ...); -- call act else - v, r = call(ref(obj),'inv', unpack(arg)); -- call inv + v, r = call(ref(obj),'inv', ...); -- call inv end if not v and r ~= true then - v, r = call(game, 'inv', obj, unpack(arg)); + v, r = call(game, 'inv', obj, ...); end return v, r; end @@ -53,13 +53,13 @@ function player_use(self, what, onwhat, ...) obj2 = ref(obj2) 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 - vv = call(obj2, 'used', obj, unpack(arg)); + vv = call(obj2, 'used', obj, ...); end end if not v and not vv then - v, r = call(game, 'use', obj, obj2, unpack(arg)); + v, r = call(game, 'use', obj, obj2, ...); end return stead.par(' ', v, vv); end @@ -83,17 +83,17 @@ function vobj_act(self, ...) if ref(o) and ref(o).where then return goto(ref(o).where); end - return call(ref(r),'act', self.nam, unpack(arg)); + return call(ref(r),'act', self.nam, ...); end function vobj_used(self, ...) local o, r = here():srch(self.nam); - return call(ref(r),'used', self.nam, unpack(arg)); + return call(ref(r),'used', self.nam, ...); end function vobj_use(self, ...) local o, r = here():srch(self.nam); - return call(ref(r),'use', self.nam, unpack(arg)); + return call(ref(r),'use', self.nam, ...); end function vobj(name, dsc, w) diff --git a/stead/snapshots.lua b/stead/snapshots.lua index f7f0831..8869759 100644 --- a/stead/snapshots.lua +++ b/stead/snapshots.lua @@ -5,8 +5,9 @@ stead.make_snapshot = function(nr) h.txt = '' h.write = function(s, ...) local i - for i = 1, stead.table.maxn(arg) do - s.txt = s.txt .. tostring(arg[i]); + local a = {...}; + for i = 1, stead.table.maxn(a) do + s.txt = s.txt .. tostring(a[i]); end end local old = game._snapshots; game._snapshots = nil @@ -65,7 +66,7 @@ function delete_snapshot(nr) end iface.cmd = stead.hook(iface.cmd, function(f, ...) - local r,v = f(unpack(arg)); + local r,v = f(...); if MAKE_SNAPSHOT ~= nil then stead.make_snapshot(MAKE_SNAPSHOT); MAKE_SNAPSHOT = nil diff --git a/stead/stead.lua b/stead/stead.lua index 03d0f97..47be61e 100644 --- a/stead/stead.lua +++ b/stead/stead.lua @@ -23,11 +23,11 @@ stead = { end if event == 'kbd' then if type(input.key) == 'function' then - return input:key(unpack(arg)); -- pressed, event + return input:key(...); -- pressed, event end elseif event == 'mouse' 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 return @@ -97,16 +97,16 @@ end function callpush(v, ...) stead.call_top = stead.call_top + 1; stead.cctx[stead.call_top] = { txt = nil, self = v, action = false }; - args = arg - arg1 = arg[1] - arg2 = arg[2] - arg3 = arg[3] - arg4 = arg[4] - arg5 = arg[5] - arg6 = arg[6] - arg7 = arg[7] - arg8 = arg[8] - arg9 = arg[9] + args = {...}; + arg1 = args[1] + arg2 = args[2] + arg3 = args[3] + arg4 = args[4] + arg5 = args[5] + arg6 = args[6] + arg7 = args[7] + arg8 = args[8] + arg9 = args[9] -- dirty but clean and fast :) self = v end @@ -146,35 +146,38 @@ end stead.pget = pget function p(...) local i - for i = 1, stead.table.maxn(arg) do - cctx().txt = stead.par('',cctx().txt, tostring(arg[i])); + local a = {...} + for i = 1, stead.table.maxn(a) do + cctx().txt = stead.par('',cctx().txt, tostring(a[i])); end cctx().txt = stead.cat(cctx().txt, ' '); end stead.p = p function pr(...) local i - for i = 1, stead.table.maxn(arg) do - cctx().txt = stead.par('',cctx().txt, tostring(arg[i])); + local a = {...} + for i = 1, stead.table.maxn(a) do + cctx().txt = stead.par('',cctx().txt, tostring(a[i])); end end stead.pr = pr function pn(...) - p(unpack(arg)); + p(...); cctx().txt = stead.par('',cctx().txt,'^'); end stead.pn = pn -- merge strings with "space" as separator function par(space,...) local i, res - for i = 1, stead.table.maxn(arg) do - if type(arg[i]) == 'string' then + local a = {...}; + for i = 1, stead.table.maxn(a) do + if type(a[i]) == 'string' then if res == nil then res = "" else res = res..space; end - res = res..arg[i]; + res = res..a[i]; end end return res; @@ -187,9 +190,10 @@ function cat(v,...) return nil end res = v; - for i = 1, stead.table.maxn(arg) do - if type(arg[i]) == 'string' then - res = res..arg[i]; + local a = {...} + for i = 1, stead.table.maxn(a) do + if type(a[i]) == 'string' then + res = res..a[i]; end end return res; @@ -282,12 +286,13 @@ end fmt = function(...) local i, res - if arg == nil then + local a = {...}; + if stead.table.maxn(a) == 0 then return false end - for i=1,stead.table.maxn(arg) do - if type(arg[i]) == 'string' then - local s = stead.string.gsub(arg[i],'[\t ]+',' '); + for i=1,stead.table.maxn(a) do + if type(a[i]) == 'string' then + local s = stead.string.gsub(a[i],'[\t ]+',' '); s = stead.string.gsub(s, '[\n]+', ' '); s = stead.string.gsub(s, '\\?[\\^]', { ['^'] = '\n', ['\\^'] = '^', ['\\\\'] = '\\'} ); res = stead.par('', res, s); @@ -804,8 +809,8 @@ function call(v, n, ...) return v[n]; end if type(v[n]) == 'function' then - callpush(v, unpack(arg)) - local a,b = v[n](v, unpack(arg)); + callpush(v, ...) + local a,b = v[n](v, ...); -- boolean, nil if type(a) == 'boolean' and b == nil then b, a = a, stead.pget() @@ -847,8 +852,8 @@ function call_bool(v, n, ...) end if type(v[n]) == 'function' then - callpush(v, unpack(arg)) - local r,v = v[n](v, unpack(arg)); + callpush(v, ...) + local r,v = v[n](v, ...); callpop(); return r,v; end @@ -867,8 +872,8 @@ function call_value(v, n, ...) if type(v[n]) ~= 'function' then return v[n]; end - callpush(v, unpack(arg)) - local r,v = v[n](v, unpack(arg)); + callpush(v, ...) + local r,v = v[n](v, ...); callpop(); return r,v; end @@ -1003,11 +1008,12 @@ end function phrase_seen(s, enb, ...) local i, ph - if stead.table.maxn(arg) == 0 then - stead.table.insert(arg, self); + local a = {...} + if stead.table.maxn(a) == 0 then + stead.table.insert(a, self); end - for i=1,stead.table.maxn(arg) do - ph = dialog_phrase(s, arg[i]); + for i=1,stead.table.maxn(a) do + ph = dialog_phrase(s, a[i]); local r = not isPhrase(ph) or isRemoved(ph) or ph:disabled(); if not enb then r = not r end if r then return false end @@ -1017,20 +1023,21 @@ end function dialog_pseen(s, ...) - return phrase_seen(s, true, unpack(arg)); + return phrase_seen(s, true, ...); end function dialog_punseen(s, ...) - return phrase_seen(s, false, unpack(arg)); + return phrase_seen(s, false, ...); end function ponoff(s, on, ...) local i, ph - if stead.table.maxn(arg) == 0 then - stead.table.insert(arg, self); + local a = {...} + if stead.table.maxn(a) == 0 then + stead.table.insert(a, self); end - for i=1,stead.table.maxn(arg) do - ph = dialog_phrase(s, arg[i]); + for i=1,stead.table.maxn(a) do + ph = dialog_phrase(s, a[i]); if isPhrase(ph) and not isRemoved(ph) then if on then ph:enable(); @@ -1043,11 +1050,12 @@ end function dialog_prem(s, ...) local i, ph - if stead.table.maxn(arg) == 0 then - stead.table.insert(arg, self); + local a = {...} + if stead.table.maxn(a) == 0 then + stead.table.insert(a, self); end - for i=1,stead.table.maxn(arg) do - ph = dialog_phrase(s, arg[i]); + for i=1,stead.table.maxn(a) do + ph = dialog_phrase(s, a[i]); if isPhrase(ph) then ph:remove(); end @@ -1055,11 +1063,11 @@ function dialog_prem(s, ...) end function dialog_pon(self,...) - return ponoff(self, true, unpack(arg)); + return ponoff(self, true, ...); end function dialog_poff(self,...) - return ponoff(self, false, unpack(arg)); + return ponoff(self, false, ...); end function dlg(v) --constructor @@ -1243,13 +1251,13 @@ function player_action(self, what, ...) local v,r,obj obj = ref(self.where):srch(what); 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 - v, r = player_take(self, what, unpack(arg)); + v, r = player_take(self, what, ...); 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 - v, r = call(ref(game), 'act', obj, unpack(arg)); + v, r = call(ref(game), 'act', obj, ...); end end return v, r; @@ -1261,7 +1269,7 @@ function player_take(self, what, ...) if not obj then return nil, false; end - v,r = call(ref(obj), 'tak', unpack(arg)); + v,r = call(ref(obj), 'tak', ...); if v and r ~= false then take(obj, w); end @@ -1282,12 +1290,12 @@ function player_use(self, what, onwhat, ...) end if onwhat == nil then -- only one? if scene_use_mode then - return self:action(what, unpack(arg)); -- call act + return self:action(what, ...); -- call act else - v, r = call(ref(obj),'inv', unpack(arg)); -- call inv + v, r = call(ref(obj),'inv', ...); -- call inv end if not v and r ~= true then - v, r = call(game, 'inv', obj, unpack(arg)); + v, r = call(game, 'inv', obj, ...); end return v, r; end @@ -1299,13 +1307,13 @@ function player_use(self, what, onwhat, ...) return game.err, false; end 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 - vv = call(ref(obj2), 'used', obj, unpack(arg)); + vv = call(ref(obj2), 'used', obj, ...); end end if not v and not vv then - v, r = call(game, 'use', obj, obj2, unpack(arg)); + v, r = call(game, 'use', obj, obj2, ...); end return stead.par(' ', v, vv); end @@ -1387,7 +1395,7 @@ function go(self, where, back) end function player_goto(self, where, ...) - local v, r = go(self, where, unpack(arg)); + local v, r = go(self, where, ...); return v, r; end @@ -1519,7 +1527,7 @@ function for_everything(f, ...) local is_ok = function(s) return true end - for_each(_G, '_G', f, is_ok, unpack(arg)) + for_each(_G, '_G', f, is_ok, ...) end function do_ini(self, load) @@ -1531,7 +1539,7 @@ function do_ini(self, load) stead.functions[o].key_name = k; end local function call_ini(k, o, ...) - v = stead.par('', v, call(o, 'ini'), unpack(arg)); + v = stead.par('', v, call(o, 'ini'), ...); end math.randomseed(tonumber(os.date("%m%d%H%M%S"))) @@ -1639,7 +1647,7 @@ function for_each(o, n, f, fv, ...) nn = n.."."..k; end end - f(k, v, unpack(arg)); + f(k, v, ...); end end end @@ -1648,23 +1656,23 @@ function isCode(s) return type(s) == 'function' and type(stead.functions[s]) == 'table' end function for_each_codeblock(f,...) - for_each(_G, '_G', f, isCode, unpack(arg)) + for_each(_G, '_G', f, isCode, ...) end function for_each_object(f,...) - for_each(_G, '_G', f, isObject, unpack(arg)) + for_each(_G, '_G', f, isObject, ...) end function for_each_player(f,...) - for_each(_G, '_G', f, isPlayer, unpack(arg)) + for_each(_G, '_G', f, isPlayer, ...) end function for_each_room(f,...) - for_each(_G, '_G', f, isRoom, unpack(arg)) + for_each(_G, '_G', f, isRoom, ...) end function for_each_list(f,...) - for_each(_G, '_G', f, isList, unpack(arg)) + for_each(_G, '_G', f, isList, ...) end function clearvar (v) @@ -2170,40 +2178,40 @@ end function xref(str, obj, ...) if type(str) ~= 'string' then return nil; end; - return iface:xref(str, obj, unpack(arg)); + return iface:xref(str, obj, ...); end function pseen(...) if not isDialog(here()) then return end - return here():pseen(unpack(arg)); + return here():pseen(...); end function punseen(...) if not isDialog(here()) then return end - return here():punseen(unpack(arg)); + return here():punseen(...); end function pon(...) if not isDialog(here()) then return end - here():pon(unpack(arg)); + here():pon(...); end function poff(...) if not isDialog(here()) then return end - here():poff(unpack(arg)); + here():poff(...); end function prem(...) if not isDialog(here()) then return end - here():prem(unpack(arg)); + here():prem(...); end function lifeon(what) @@ -2279,12 +2287,12 @@ function vobj_act(self, ...) if ref(o) and ref(o).where then return goto(ref(o).where); end - return call(ref(r),'act', self.key, unpack(arg)); + return call(ref(r),'act', self.key, ...); end function vobj_used(self, ...) local o, r = here():srch(self.nam); - return call(ref(r),'used', self.key, unpack(arg)); + return call(ref(r),'used', self.key, ...); end function vobj(key, name, dsc, w) @@ -2700,7 +2708,7 @@ end function inherit(o, f) return function(...) - return f(o(unpack(arg))) + return f(o(...)) end end stead.inherit = inherit @@ -2715,7 +2723,7 @@ function hook(o, f) else ff = o end - return f(ff, unpack(arg)) + return f(ff, ...) end end stead.hook = hook diff --git a/stead/timer.lua b/stead/timer.lua index 993ec68..d178c93 100644 --- a/stead/timer.lua +++ b/stead/timer.lua @@ -11,7 +11,7 @@ game.action = stead.hook(game.action, function(f, s, cmd, ...) end return r,v end - return f(s, cmd, unpack(arg)); + return f(s, cmd, ...); end) stead.module_init(function() diff --git a/stead/vars.lua b/stead/vars.lua index 8c147f5..7636d95 100644 --- a/stead/vars.lua +++ b/stead/vars.lua @@ -81,7 +81,7 @@ vars_object = obj { obj = stead.hook(obj, function(f, v, ...) __vars_fill(v) - return f(v, unpack(arg)) + return f(v, ...) end) stead.module_init(function() diff --git a/stead/xact.lua b/stead/xact.lua index 267212f..53b00e1 100644 --- a/stead/xact.lua +++ b/stead/xact.lua @@ -82,9 +82,10 @@ end stead.fmt = stead.hook(stead.fmt, function(f, ...) local i, res, s - for i=1,stead.table.maxn(arg) do - if type(arg[i]) == 'string' then - s = __do_xact(arg[i]); + local a = {...} + for i=1,stead.table.maxn(a) do + if type(a[i]) == 'string' then + s = __do_xact(a[i]); res = stead.par('', res, s):gsub('\\?[\\{}]', { [ '\\{' ] = '{', [ '\\}' ] = '}' }); end end @@ -123,7 +124,7 @@ end xroom = stead.inherit(room, function(v) v.look = stead.hook(v.look, function(f, s,...) local xdsc = call(s, 'xdsc'); - return par(' ', xdsc, f(s, unpack(arg))); + return par(' ', xdsc, f(s, ...)); end) return v end)