diff --git a/stead/click.lua b/stead/click.lua index 8e72a51..1f04bef 100644 --- a/stead/click.lua +++ b/stead/click.lua @@ -75,15 +75,15 @@ function(f, s, cmd, press, mb, x, y, px, py, ...) if s.click then if click.press then if click.button then - r,v = call(s, 'click', press, mb, tonumber(x), tonumber(y), x2, y2, ...); + r,v = stead.call(s, 'click', press, mb, tonumber(x), tonumber(y), x2, y2, ...); else - r,v = call(s, 'click', press, tonumber(x), tonumber(y), x2, y2, ...); + r,v = stead.call(s, 'click', press, tonumber(x), tonumber(y), x2, y2, ...); end else if click.button then - r,v = call(s, 'click', mb, tonumber(x), tonumber(y), x2, y2, ...); + r,v = stead.call(s, 'click', mb, tonumber(x), tonumber(y), x2, y2, ...); else - r,v = call(s, 'click', tonumber(x), tonumber(y), x2, y2, ...); + r,v = stead.call(s, 'click', tonumber(x), tonumber(y), x2, y2, ...); end end end diff --git a/stead/dbg.lua b/stead/dbg.lua index c5b594d..d20a7c4 100644 --- a/stead/dbg.lua +++ b/stead/dbg.lua @@ -31,8 +31,8 @@ function ordered_n(t) return false end if isObject(a.v) and isObject(b.v) then - local n = call(a.v, 'nam'); - local m = call(b.v, 'nam'); + local n = stead.call(a.v, 'nam'); + local m = stead.call(b.v, 'nam'); if type(n) ~= 'string' and type(m) ~= 'string' then return false end @@ -104,7 +104,7 @@ dump_obj = function(w) if rc ~='' then rc = rc..'^' end local n = ''; if type(o) ~= 'function' and isObject(ref(o)) then - n = call(ref(o), 'nam'); + n = stead.call(ref(o), 'nam'); if type(n) ~= 'string' then n = '' else n = ' : '..n; end end rc = stead.cat(rc, stead.par(' ', tostring(i)..' : '..t..n)); @@ -139,13 +139,13 @@ end list_objects = function() local i,o local rc = stead.par(' ', 'Room:'..tostring(deref(dbg_here())), - 'Nam:'..tostring(call(dbg_here(),'nam'))); + 'Nam:'..tostring(stead.call(dbg_here(),'nam'))); for i,o in opairs(objs(dbg_here())) do rc = rc..'^'; o = ref(o) rc = stead.cat(rc, stead.par(' ', 'Id:'..tostring(o.id), 'Obj:'..tostring(deref(o)), - 'Nam:'..tostring(call(o, 'nam')), + 'Nam:'..tostring(stead.call(o, 'nam')), 'Disabled:'..tostring(isDisabled(o)))); end -- seen('disp')._txt = rc @@ -159,7 +159,7 @@ list_inv = function() if rc ~='' then rc = rc..'^' end o = ref(o) rc = stead.cat(rc, stead.par(' ', 'Id:'..tostring(o.id), 'Obj:'..tostring(deref(o)), - 'Nam:'..tostring(call(o, 'nam')), + 'Nam:'..tostring(stead.call(o, 'nam')), 'Disabled:'..tostring(isDisabled(o)), 'Taken:'..tostring(taken(o)))); end @@ -227,7 +227,7 @@ choose_location = dlg { objs(s):zap(); for k,v,kk in spairs(_G) do if isRoom(v) and not v.debug then - local n = tostring(call(v, 'nam')); + local n = tostring(stead.call(v, 'nam')); local o = kk; if type(o) == 'string' then n = n..' : '..o; @@ -251,7 +251,7 @@ choose_object = dlg { objs(s):zap(); for k,v,kk in spairs(_G) do if isObject(v) and not isPhrase(v) and not isRoom(v) and not isPlayer(v) and not v.debug and not have(v) and not isStatus(v) then - local n = tostring(call(v, 'nam')); + local n = tostring(stead.call(v, 'nam')); local o = kk; if type(o) == 'string' then n = n..' : '..o; @@ -276,7 +276,7 @@ drop_object = dlg { for k,v in ipairs(inv()) do v = ref(v); if not v.debug then - local n = tostring(call(v, 'nam')); + local n = tostring(stead.call(v, 'nam')); local o = deref(v); if type(o) == 'string' then n = n..' : '..o; @@ -292,7 +292,7 @@ drop_object = dlg { function dbg_exit() local r if stead.api_version < "1.2.0" then - r = call(dbg_here(), 'dsc'); + r = stead.call(dbg_here(), 'dsc'); end game.lifes:cat(debug_tool.lifes); timer:set(debug_tool._timer); diff --git a/stead/format.lua b/stead/format.lua index a87aa2a..34c49c0 100644 --- a/stead/format.lua +++ b/stead/format.lua @@ -30,16 +30,16 @@ stead.fmt = stead.hook(stead.fmt, function(f, ...) if type(format.filter) == 'function' and stead.state then r = format.filter(r); end - if call_bool(format, 'dash') and utf8 then + if stead.call_bool(format, 'dash') and utf8 then r = r:gsub('([^-])%-%-([^-])', '%1—%2'); r = r:gsub('^%-%-([^-])', '—%1'); end - if call_bool(format, 'quotes') and utf8 then + if stead.call_bool(format, 'quotes') and utf8 then r = r:gsub('_"','«'):gsub('"_',"»"); r = r:gsub('"([^"]*)"','«%1»'); r = r:gsub(',,','„'):gsub("''",'”'); end - if call_bool(format, 'para') then + if stead.call_bool(format, 'para') then r = r:gsub('\n([^\n])', '<¶>%1'):gsub('<¶>[ \t]*'..format.nopara,'\n'):gsub('<¶>[ \t]*', '\n'..txtnb(format.para_space)); r = r:gsub('^[ \t]*', '<¶>'):gsub('<¶>[ \t]*'..format.nopara,''):gsub('<¶>[ \t]*', txtnb(format.para_space)); end diff --git a/stead/goto.lua b/stead/goto.lua index 5a2d6fd..38018d7 100644 --- a/stead/goto.lua +++ b/stead/goto.lua @@ -31,7 +31,7 @@ go = function (self, where, back, noenter, noexit, nodsc) if not isVroom(ref(where)) and not stead.in_exit_call and not noexit then stead.in_exit_call = true -- to break recurse - v,r = call(ref(self.where), 'exit', ref(where)); + v,r = stead.call(ref(self.where), 'exit', ref(where)); stead.in_exit_call = nil if r == false or (stead.api_version >= "1.3.0" and v == false and r == nil) then return v, ret(r) @@ -50,7 +50,7 @@ go = function (self, where, back, noenter, noexit, nodsc) end if not jump and not noenter then - v, r = call(ref(where), 'enter', ref(was)); + v, r = stead.call(ref(where), 'enter', ref(was)); if r == false or (stead.api_version >= "1.3.0" and v == false and r == nil) then self.where = was; return par('^^', res, v), ret(r) @@ -80,7 +80,7 @@ go = function (self, where, back, noenter, noexit, nodsc) if not noexit then self.where = was stead.in_onexit_call = true - v = call(ref(was), 'left', ref(to)); + v = stead.call(ref(was), 'left', ref(to)); stead.in_onexit_call = false res = par('^^',res,v); end @@ -89,7 +89,7 @@ go = function (self, where, back, noenter, noexit, nodsc) if not noenter then stead.in_entered_call = true - v = call(ref(to), 'entered', ref(was)); + v = stead.call(ref(to), 'entered', ref(was)); stead.in_entered_call = false res = par('^^',res,v); end diff --git a/stead/gui.lua b/stead/gui.lua index 3ebf8f3..fd4b507 100644 --- a/stead/gui.lua +++ b/stead/gui.lua @@ -175,10 +175,10 @@ instead.get_ways = get_ways; function get_title() local s if stead.api_version >= "1.2.0" then - s = call(here(), 'disp'); + s = stead.call(here(), 'disp'); end if type(s) ~= 'string' then - s = call(here(), 'nam'); + s = stead.call(here(), 'nam'); end if type(s) == 'string' and s ~= '' then stead.state = false @@ -234,7 +234,7 @@ function menu(v) if v.inv == nil then v.inv = function(s) local r,v - r,v = call(s, 'menu'); + r,v = stead.call(s, 'menu'); if v == nil then v = true end if r == nil then obj_tag(me(), MENU_TAG_ID); -- retag menu field @@ -245,7 +245,7 @@ function menu(v) if v.act == nil then v.act = function(s) local r,v - r,v = call(s, 'menu'); + r,v = stead.call(s, 'menu'); if v == nil then v = true end if r == nil then obj_tag(me(), MENU_TAG_ID); -- retag menu field @@ -288,7 +288,7 @@ stead.fmt = fmt game.fading = function(s) local rc = false - local p = call(here(), 'pic'); + local p = stead.call(here(), 'pic'); if stead.cmd == 'load' then game.lastpic = p; return true @@ -313,14 +313,14 @@ function isFading() --to check fading from sdl gui if not isRoom(h) then return false end - r, v = call_value(h, 'fading'); - if r or r == false then + r,v = stead.call_value(h, 'fading'); + if r then if tonumber(r) and v == nil then return true, tonumber(r) end return r, v end - g, v = call_value(game, 'fading', h); + g,v = stead.call_value(game, 'fading', h); if tonumber(g) and v == nil then return true, tonumber(g) end diff --git a/stead/hideinv.lua b/stead/hideinv.lua index 92034e4..01532ed 100644 --- a/stead/hideinv.lua +++ b/stead/hideinv.lua @@ -1,12 +1,12 @@ room = stead.inherit(room, function(v) v.entered = stead.hook(v.entered, function(f, s, ...) - if call_bool(s, 'hideinv') then + if stead.call_bool(s, 'hideinv') then me():disable_all(); end return f(s, ...) end) v.left = stead.hook(v.left, function(f, s, ...) - if call_bool(s, 'hideinv') then + if stead.call_bool(s, 'hideinv') then me():enable_all(); end return f(s, ...) diff --git a/stead/hotkeys.lua b/stead/hotkeys.lua index e5c598a..74fd8cf 100644 --- a/stead/hotkeys.lua +++ b/stead/hotkeys.lua @@ -10,7 +10,7 @@ game.kbd = stead.hook(game.kbd, function(f, s, down, key, ...) if key == '0' then key = '10' end local p = seen(key); if p then - return call(p, 'act'); + return stead.call(p, 'act'); end end return diff --git a/stead/input.lua b/stead/input.lua index 08b3ac8..0c1fa22 100644 --- a/stead/input.lua +++ b/stead/input.lua @@ -194,9 +194,9 @@ game.action = stead.hook(game.action, function (f, s, cmd, ...) if cmd == 'kbd_enter' then local r,v if here().inp_enter then - r,v = call(here(), 'inp_enter'); + r,v = stead.call(here(), 'inp_enter'); elseif s.inp_enter then - r,v = call(s, 'inp_enter'); + r,v = stead.call(s, 'inp_enter'); end return r,v -- nothing todo end diff --git a/stead/kbd.lua b/stead/kbd.lua index 84fecc4..d4646df 100644 --- a/stead/kbd.lua +++ b/stead/kbd.lua @@ -2,10 +2,10 @@ game.action = stead.hook(game.action, function(f, s, cmd, ...) if cmd == 'user_kbd' then local r,v; if here().kbd then - r,v = call(here(), 'kbd', + r,v = stead.call(here(), 'kbd', input.key_event.down, input.key_event.key); elseif s.kbd then - r,v = call(s, 'kbd', + r,v = stead.call(s, 'kbd', input.key_event.down, input.key_event.key); end if r == nil and v == nil and stead.api_version < "1.3.5" then diff --git a/stead/object.lua b/stead/object.lua index 36b3380..74cfe71 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, ...); --player_do(self, what, ...); + return stead.call(game, 'action', what, ...); --player_do(self, what, ...); end v, r = player_take(self, what, ...); if not v then - v, r = call(obj, 'act', ...); + v, r = stead.call(obj, 'act', ...); if not v and r ~= true then - v, r = call(game, 'act', obj, ...); + v, r = stead.call(game, 'act', obj, ...); end end return v, r; @@ -34,10 +34,10 @@ function player_use(self, what, onwhat, ...) if scene_use_mode then return self:action(what, ...); -- call act else - v, r = call(ref(obj),'inv', ...); -- call inv + v, r = stead.call(ref(obj),'inv', ...); -- call inv end if not v and r ~= true then - v, r = call(game, 'inv', obj, ...); + v, r = stead.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, ...); + v, r = stead.call(obj, 'use', obj2, ...); if r ~= false then - vv = call(obj2, 'used', obj, ...); + vv = stead.call(obj2, 'used', obj, ...); end end if not v and not vv then - v, r = call(game, 'use', obj, obj2, ...); + v, r = stead.call(game, 'use', obj, obj2, ...); end if not v and not vv then return @@ -90,17 +90,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, ...); + return stead.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, ...); + return stead.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, ...); + return stead.call(ref(r),'use', self.nam, ...); end function vobj(name, dsc, w) @@ -218,10 +218,10 @@ function list_str(self) if isObject(o) and not isDisabled(o) then vv = nil if game.gui then - vv = call(o, 'disp'); + vv = stead.call(o, 'disp'); end if type(vv) ~= 'string' then - vv = call(o, 'nam'); + vv = stead.call(o, 'nam'); end vv = xref(vv, o); v = stead.par(stead.delim, v, vv); @@ -243,10 +243,10 @@ function obj_str(self) if isObject(o) and not isDisabled(o) then vv = nil if game.gui then - vv = call(o, 'disp'); + vv = stead.call(o, 'disp'); end if type(vv) ~= 'string' then - vv = call(o, 'nam'); + vv = stead.call(o, 'nam'); end vv = xref(vv, o); v = stead.par(stead.delim, v, vv, obj_str(o)); diff --git a/stead/stead.lua b/stead/stead.lua index cff67d5..079e2b6 100644 --- a/stead/stead.lua +++ b/stead/stead.lua @@ -406,7 +406,7 @@ function obj_look(self) if isDisabled(self) then return end - local v = call(self,'dsc'); + local v = stead.call(self,'dsc'); if game.hinting then v = self:xref(v); elseif v then @@ -477,7 +477,7 @@ function obj_str(self) for i,o in opairs(self.obj) do o = ref(o); if o~= nil and not isDisabled(o) then -- isObject is better, but compat layer must be ok - vv = call(o, 'nam'); + vv = stead.call(o, 'nam'); vv = xref(vv, o); v = stead.par(',', v, vv, obj_str(o)); end @@ -594,7 +594,7 @@ function list_str(self) for i,o in opairs(self) do o = ref(o); if o~= nil and not isDisabled(o) then - vv = call(o, 'nam'); + vv = stead.call(o, 'nam'); vv = xref(vv, o); v = stead.par(',', v, vv); end @@ -674,7 +674,7 @@ function list_name(self, name, dis) for n,o,ii in opairs(self) do o = ref(o); if isObject(o) then - local nam = call(o,'nam') ; + local nam = stead.call(o,'nam') ; if ( not isDisabled(o) or dis ) and name == tostring(nam) then return ii; end @@ -839,6 +839,7 @@ function call(v, n, ...) end error ("Method not string nor function:"..tostring(n), 2); end +stead.call = call function call_bool(v, n, ...) if type(v) ~= 'table' then @@ -861,6 +862,7 @@ function call_bool(v, n, ...) end return true; -- not nil end +stead.call_bool = call_bool function call_value(v, n, ...) if type(v) ~= 'table' then @@ -879,11 +881,12 @@ function call_value(v, n, ...) stead.callpop(); return r,v; end +stead.call_value = call_value function room_scene(self) local v; - v = iface:title(call(self,'nam')); - v = stead.par('^^', v, call(self,'dsc')); --obj_look(self)); + v = iface:title(stead.call(self,'nam')); + v = stead.par('^^', v, stead.call(self,'dsc')); --obj_look(self)); return stead.cat(v,' '); end @@ -960,8 +963,8 @@ end function dialog_scene(self) local v - v = iface:title(call(self,'nam')); - v = stead.par('^^', v, call(self, 'dsc')); --obj_look(self)); + v = iface:title(stead.call(self,'nam')); + v = stead.par('^^', v, stead.call(self, 'dsc')); --obj_look(self)); return v; end @@ -1118,7 +1121,7 @@ function phrase_action(self) -- here it is ph:disable(); -- /* disable it!!! */ - local last = call(ph, 'ans'); + local last = stead.call(ph, 'ans'); if type(ph.do_act) == 'string' then local f = loadstring(ph.do_act); @@ -1168,7 +1171,7 @@ function phrase_look(self, n) if isDisabled(self) then return end - local v = call(self, 'dsc'); + local v = stead.call(self, 'dsc'); if type(v) ~= 'string' then return; end if game.hinting then return self:xref('{'..v..'}'); @@ -1253,13 +1256,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, ...); --player_do(self, what, ...); + return stead.call(ref(game), 'action', what, ...); --player_do(self, what, ...); end v, r = player_take(self, what, ...); if not v then - v, r = call(ref(obj), 'act', ...); + v, r = stead.call(ref(obj), 'act', ...); if not v and r ~= true then - v, r = call(ref(game), 'act', obj, ...); + v, r = stead.call(ref(game), 'act', obj, ...); end end return v, r; @@ -1271,7 +1274,7 @@ function player_take(self, what, ...) if not obj then return nil, false; end - v,r = call(ref(obj), 'tak', ...); + v,r = stead.call(ref(obj), 'tak', ...); if v and r ~= false then take(obj, w); end @@ -1294,10 +1297,10 @@ function player_use(self, what, onwhat, ...) if scene_use_mode then return self:action(what, ...); -- call act else - v, r = call(ref(obj),'inv', ...); -- call inv + v, r = stead.call(ref(obj),'inv', ...); -- call inv end if not v and r ~= true then - v, r = call(game, 'inv', obj, ...); + v, r = stead.call(game, 'inv', obj, ...); end return v, r; end @@ -1309,13 +1312,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, ...); + v, r = stead.call(ref(obj), 'use', obj2, ...); if r ~= false then - vv = call(ref(obj2), 'used', obj, ...); + vv = stead.call(ref(obj2), 'used', obj, ...); end end if not v and not vv then - v, r = call(game, 'use', obj, obj2, ...); + v, r = stead.call(game, 'use', obj, obj2, ...); end return stead.par(' ', v, vv); end @@ -1358,7 +1361,7 @@ function go(self, where, back) local v, r; if not isVroom(ref(where)) and not stead.in_exit_call then stead.in_exit_call = true -- to break recurse - v,r = call(ref(self.where), 'exit', where); + v,r = stead.call(ref(self.where), 'exit', where); stead.in_exit_call = nil if r == false then return v, ret(r) @@ -1369,7 +1372,7 @@ function go(self, where, back) v = nil; if not back or not isDialog(ref(self.where)) or isDialog(ref(where)) then - v, r = call(ref(where), 'enter', self.where); + v, r = stead.call(ref(where), 'enter', self.where); if r == false then return v, ret(r) end @@ -1471,7 +1474,7 @@ function game_life(self) o = ref(o); if not isDisabled(o) then PLAYER_MOVED = false - vv,pre = call(o,'life'); + vv,pre = stead.call(o, 'life'); if pre or (PLAYER_MOVED and pre ~= false) then av = stead.par(' ', av, vv); else @@ -1541,7 +1544,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', ...)); + v = stead.par('', v, stead.call(o, 'ini', ...)); end math.randomseed(os.time(os.date("*t"))) rnd(1); rnd(2); rnd(3); -- Lua bug? @@ -1569,8 +1572,8 @@ stead.do_ini = do_ini function game_ini(self) local v,vv v = stead.do_ini(self); - vv = iface:title(call(self,'nam')); - vv = stead.par('^^', vv, call(self,'dsc')); + vv = iface:title(stead.call(self,'nam')); + vv = stead.par('^^', vv, stead.call(self,'dsc')); if type(init) == 'function' then init(); end @@ -1629,14 +1632,14 @@ function isEnableSave() if game.enable_save == nil or get_autosave() then return true end - return call_bool(game, 'enable_save'); + return stead.call_bool(game, 'enable_save'); end function isEnableAutosave() if game.enable_autosave == nil then return true end - return call_bool(game, 'enable_autosave'); + return stead.call_bool(game, 'enable_autosave'); end function for_each(o, n, f, fv, ...) @@ -1870,7 +1873,7 @@ function game_save(self, name, file) if not h then return nil, false end - local n = call(here(),'nam'); + local n = stead.call(here(),'nam'); if type(n) == 'string' and n ~= "" then h:write("-- $Name: "..n:gsub("\n","\\n").."$\n"); end @@ -1929,21 +1932,21 @@ end function isForcedsc(v) local r,g - r = call_bool(v, 'forcedsc'); + r = stead.call_bool(v, 'forcedsc'); if r then return true end - g = call_bool(game, 'forcedsc', v); + g = stead.call_bool(game, 'forcedsc', v); return g and r ~= false end function isSceneUse(v) local o,g - o = call_bool(v, 'scene_use'); + o = stead.call_bool(v, 'scene_use'); if o then return true end - g = call_bool(game, 'scene_use', v); + g = stead.call_bool(game, 'scene_use', v); return g and o ~= false end @@ -2309,12 +2312,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, ...); + return stead.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, ...); + return stead.call(ref(r),'used', self.key, ...); end function vobj(key, name, dsc, w) @@ -2571,15 +2574,15 @@ function movef(obj, there, from) end function get_picture() - local s = call(here(),'pic'); + local s = stead.call(here(),'pic'); if not s then - s = call(game, 'pic'); + s = stead.call(game, 'pic'); end return s; end function get_title() - local s = call(here(),'nam'); + local s = stead.call(here(),'nam'); return s; end @@ -2794,7 +2797,7 @@ stead.hook = hook function nameof(v) if isObject(v) then - local r = call(v, 'nam'); + local r = stead.call(v, 'nam'); return r end end diff --git a/stead/timer.lua b/stead/timer.lua index da53379..0be676e 100644 --- a/stead/timer.lua +++ b/stead/timer.lua @@ -2,9 +2,9 @@ game.action = stead.hook(game.action, function(f, s, cmd, ...) if cmd == 'user_timer' then local r,v if here().timer then - r,v = call(here(), 'timer'); + r,v = stead.call(here(), 'timer'); elseif s.timer then - r,v = call(s, 'timer'); + r,v = stead.call(s, 'timer'); end if r == nil and v == nil and stead.api_version < "1.3.5" then return nil, true diff --git a/stead/xact.lua b/stead/xact.lua index 6b20881..ec03aae 100644 --- a/stead/xact.lua +++ b/stead/xact.lua @@ -110,7 +110,7 @@ function xdsc(n) error("Wrong parameter to xdsc.", 2); end v.dsc = function(s) - return call(here(), s.disp); + return stead.call(here(), s.disp); end v.save = function(self, name, h, need) if need then @@ -123,7 +123,7 @@ end xroom = stead.inherit(room, function(v) v.look = stead.hook(v.look, function(f, s,...) - local xdsc = call(s, 'xdsc'); + local xdsc = stead.call(s, 'xdsc'); return par(' ', xdsc, f(s, ...)); end) return v