call to stead.call

This commit is contained in:
p.kosyh 2011-07-27 10:21:20 +00:00
parent c6e660ee5a
commit c114ac42ff
13 changed files with 96 additions and 93 deletions

View file

@ -75,15 +75,15 @@ function(f, s, cmd, press, mb, x, y, px, py, ...)
if s.click then if s.click then
if click.press then if click.press then
if click.button 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 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 end
else else
if click.button then 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 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 end
end end

View file

@ -31,8 +31,8 @@ function ordered_n(t)
return false return false
end end
if isObject(a.v) and isObject(b.v) then if isObject(a.v) and isObject(b.v) then
local n = call(a.v, 'nam'); local n = stead.call(a.v, 'nam');
local m = call(b.v, 'nam'); local m = stead.call(b.v, 'nam');
if type(n) ~= 'string' and type(m) ~= 'string' then if type(n) ~= 'string' and type(m) ~= 'string' then
return false return false
end end
@ -104,7 +104,7 @@ dump_obj = function(w)
if rc ~='' then rc = rc..'^' end if rc ~='' then rc = rc..'^' end
local n = ''; local n = '';
if type(o) ~= 'function' and isObject(ref(o)) then 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 if type(n) ~= 'string' then n = '' else n = ' : '..n; end
end end
rc = stead.cat(rc, stead.par(' ', tostring(i)..' : '..t..n)); rc = stead.cat(rc, stead.par(' ', tostring(i)..' : '..t..n));
@ -139,13 +139,13 @@ end
list_objects = function() list_objects = function()
local i,o local i,o
local rc = stead.par(' ', 'Room:'..tostring(deref(dbg_here())), 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 for i,o in opairs(objs(dbg_here())) do
rc = rc..'^'; rc = rc..'^';
o = ref(o) o = ref(o)
rc = stead.cat(rc, stead.par(' ', 'Id:'..tostring(o.id), rc = stead.cat(rc, stead.par(' ', 'Id:'..tostring(o.id),
'Obj:'..tostring(deref(o)), 'Obj:'..tostring(deref(o)),
'Nam:'..tostring(call(o, 'nam')), 'Nam:'..tostring(stead.call(o, 'nam')),
'Disabled:'..tostring(isDisabled(o)))); 'Disabled:'..tostring(isDisabled(o))));
end end
-- seen('disp')._txt = rc -- seen('disp')._txt = rc
@ -159,7 +159,7 @@ list_inv = function()
if rc ~='' then rc = rc..'^' end if rc ~='' then rc = rc..'^' end
o = ref(o) o = ref(o)
rc = stead.cat(rc, stead.par(' ', 'Id:'..tostring(o.id), 'Obj:'..tostring(deref(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)), 'Disabled:'..tostring(isDisabled(o)),
'Taken:'..tostring(taken(o)))); 'Taken:'..tostring(taken(o))));
end end
@ -227,7 +227,7 @@ choose_location = dlg {
objs(s):zap(); objs(s):zap();
for k,v,kk in spairs(_G) do for k,v,kk in spairs(_G) do
if isRoom(v) and not v.debug then if isRoom(v) and not v.debug then
local n = tostring(call(v, 'nam')); local n = tostring(stead.call(v, 'nam'));
local o = kk; local o = kk;
if type(o) == 'string' then if type(o) == 'string' then
n = n..' : '..o; n = n..' : '..o;
@ -251,7 +251,7 @@ choose_object = dlg {
objs(s):zap(); objs(s):zap();
for k,v,kk in spairs(_G) do 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 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; local o = kk;
if type(o) == 'string' then if type(o) == 'string' then
n = n..' : '..o; n = n..' : '..o;
@ -276,7 +276,7 @@ drop_object = dlg {
for k,v in ipairs(inv()) do for k,v in ipairs(inv()) do
v = ref(v); v = ref(v);
if not v.debug then if not v.debug then
local n = tostring(call(v, 'nam')); local n = tostring(stead.call(v, 'nam'));
local o = deref(v); local o = deref(v);
if type(o) == 'string' then if type(o) == 'string' then
n = n..' : '..o; n = n..' : '..o;
@ -292,7 +292,7 @@ drop_object = dlg {
function dbg_exit() function dbg_exit()
local r local r
if stead.api_version < "1.2.0" then if stead.api_version < "1.2.0" then
r = call(dbg_here(), 'dsc'); r = stead.call(dbg_here(), 'dsc');
end end
game.lifes:cat(debug_tool.lifes); game.lifes:cat(debug_tool.lifes);
timer:set(debug_tool._timer); timer:set(debug_tool._timer);

View file

@ -30,16 +30,16 @@ stead.fmt = stead.hook(stead.fmt, function(f, ...)
if type(format.filter) == 'function' and stead.state then if type(format.filter) == 'function' and stead.state then
r = format.filter(r); r = format.filter(r);
end 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—%2');
r = r:gsub('^%-%-([^-])', '—%1'); r = r:gsub('^%-%-([^-])', '—%1');
end 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('_"','«'):gsub('"_',"»");
r = r:gsub('"([^"]*)"','«%1»'); r = r:gsub('"([^"]*)"','«%1»');
r = r:gsub(',,',''):gsub("''",''); r = r:gsub(',,',''):gsub("''",'');
end end
if call_bool(format, 'para') then if stead.call_bool(format, 'para') then
r = r:gsub('\n([^\n])', '<&para;>%1'):gsub('<&para;>[ \t]*'..format.nopara,'\n'):gsub('<&para;>[ \t]*', '\n'..txtnb(format.para_space)); r = r:gsub('\n([^\n])', '<&para;>%1'):gsub('<&para;>[ \t]*'..format.nopara,'\n'):gsub('<&para;>[ \t]*', '\n'..txtnb(format.para_space));
r = r:gsub('^[ \t]*', '<&para;>'):gsub('<&para;>[ \t]*'..format.nopara,''):gsub('<&para;>[ \t]*', txtnb(format.para_space)); r = r:gsub('^[ \t]*', '<&para;>'):gsub('<&para;>[ \t]*'..format.nopara,''):gsub('<&para;>[ \t]*', txtnb(format.para_space));
end end

View file

@ -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 if not isVroom(ref(where)) and not stead.in_exit_call and not noexit then
stead.in_exit_call = true -- to break recurse 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 stead.in_exit_call = nil
if r == false or (stead.api_version >= "1.3.0" and v == false and r == nil) then if r == false or (stead.api_version >= "1.3.0" and v == false and r == nil) then
return v, ret(r) return v, ret(r)
@ -50,7 +50,7 @@ go = function (self, where, back, noenter, noexit, nodsc)
end end
if not jump and not noenter then 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 if r == false or (stead.api_version >= "1.3.0" and v == false and r == nil) then
self.where = was; self.where = was;
return par('^^', res, v), ret(r) return par('^^', res, v), ret(r)
@ -80,7 +80,7 @@ go = function (self, where, back, noenter, noexit, nodsc)
if not noexit then if not noexit then
self.where = was self.where = was
stead.in_onexit_call = true 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 stead.in_onexit_call = false
res = par('^^',res,v); res = par('^^',res,v);
end end
@ -89,7 +89,7 @@ go = function (self, where, back, noenter, noexit, nodsc)
if not noenter then if not noenter then
stead.in_entered_call = true 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 stead.in_entered_call = false
res = par('^^',res,v); res = par('^^',res,v);
end end

View file

@ -175,10 +175,10 @@ instead.get_ways = get_ways;
function get_title() function get_title()
local s local s
if stead.api_version >= "1.2.0" then if stead.api_version >= "1.2.0" then
s = call(here(), 'disp'); s = stead.call(here(), 'disp');
end end
if type(s) ~= 'string' then if type(s) ~= 'string' then
s = call(here(), 'nam'); s = stead.call(here(), 'nam');
end end
if type(s) == 'string' and s ~= '' then if type(s) == 'string' and s ~= '' then
stead.state = false stead.state = false
@ -234,7 +234,7 @@ function menu(v)
if v.inv == nil then if v.inv == nil then
v.inv = function(s) v.inv = function(s)
local r,v local r,v
r,v = call(s, 'menu'); r,v = stead.call(s, 'menu');
if v == nil then v = true end if v == nil then v = true end
if r == nil then if r == nil then
obj_tag(me(), MENU_TAG_ID); -- retag menu field obj_tag(me(), MENU_TAG_ID); -- retag menu field
@ -245,7 +245,7 @@ function menu(v)
if v.act == nil then if v.act == nil then
v.act = function(s) v.act = function(s)
local r,v local r,v
r,v = call(s, 'menu'); r,v = stead.call(s, 'menu');
if v == nil then v = true end if v == nil then v = true end
if r == nil then if r == nil then
obj_tag(me(), MENU_TAG_ID); -- retag menu field obj_tag(me(), MENU_TAG_ID); -- retag menu field
@ -288,7 +288,7 @@ stead.fmt = fmt
game.fading = function(s) game.fading = function(s)
local rc = false local rc = false
local p = call(here(), 'pic'); local p = stead.call(here(), 'pic');
if stead.cmd == 'load' then if stead.cmd == 'load' then
game.lastpic = p; game.lastpic = p;
return true return true
@ -313,14 +313,14 @@ function isFading() --to check fading from sdl gui
if not isRoom(h) then if not isRoom(h) then
return false return false
end end
r, v = call_value(h, 'fading'); r,v = stead.call_value(h, 'fading');
if r or r == false then if r then
if tonumber(r) and v == nil then if tonumber(r) and v == nil then
return true, tonumber(r) return true, tonumber(r)
end end
return r, v return r, v
end end
g, v = call_value(game, 'fading', h); g,v = stead.call_value(game, 'fading', h);
if tonumber(g) and v == nil then if tonumber(g) and v == nil then
return true, tonumber(g) return true, tonumber(g)
end end

View file

@ -1,12 +1,12 @@
room = stead.inherit(room, function(v) room = stead.inherit(room, function(v)
v.entered = stead.hook(v.entered, function(f, s, ...) 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(); me():disable_all();
end end
return f(s, ...) 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 stead.call_bool(s, 'hideinv') then
me():enable_all(); me():enable_all();
end end
return f(s, ...) return f(s, ...)

View file

@ -10,7 +10,7 @@ game.kbd = stead.hook(game.kbd, function(f, s, down, key, ...)
if key == '0' then key = '10' end if key == '0' then key = '10' end
local p = seen(key); local p = seen(key);
if p then if p then
return call(p, 'act'); return stead.call(p, 'act');
end end
end end
return return

View file

@ -194,9 +194,9 @@ game.action = stead.hook(game.action, function (f, s, cmd, ...)
if cmd == 'kbd_enter' then if cmd == 'kbd_enter' then
local r,v local r,v
if here().inp_enter then if here().inp_enter then
r,v = call(here(), 'inp_enter'); r,v = stead.call(here(), 'inp_enter');
elseif s.inp_enter then elseif s.inp_enter then
r,v = call(s, 'inp_enter'); r,v = stead.call(s, 'inp_enter');
end end
return r,v -- nothing todo return r,v -- nothing todo
end end

View file

@ -2,10 +2,10 @@ game.action = stead.hook(game.action, function(f, s, cmd, ...)
if cmd == 'user_kbd' then if cmd == 'user_kbd' then
local r,v; local r,v;
if here().kbd then if here().kbd then
r,v = call(here(), 'kbd', r,v = stead.call(here(), 'kbd',
input.key_event.down, input.key_event.key); input.key_event.down, input.key_event.key);
elseif s.kbd then elseif s.kbd then
r,v = call(s, 'kbd', r,v = stead.call(s, 'kbd',
input.key_event.down, input.key_event.key); input.key_event.down, input.key_event.key);
end end
if r == nil and v == nil and stead.api_version < "1.3.5" then if r == nil and v == nil and stead.api_version < "1.3.5" then

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, ...); --player_do(self, what, ...); return stead.call(game, 'action', what, ...); --player_do(self, what, ...);
end end
v, r = player_take(self, what, ...); v, r = player_take(self, what, ...);
if not v then if not v then
v, r = call(obj, 'act', ...); v, r = stead.call(obj, 'act', ...);
if not v and r ~= true then if not v and r ~= true then
v, r = call(game, 'act', obj, ...); v, r = stead.call(game, 'act', obj, ...);
end end
end end
return v, r; return v, r;
@ -34,10 +34,10 @@ function player_use(self, what, onwhat, ...)
if scene_use_mode then if scene_use_mode then
return self:action(what, ...); -- call act return self:action(what, ...); -- call act
else else
v, r = call(ref(obj),'inv', ...); -- call inv v, r = stead.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, ...); v, r = stead.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, ...); v, r = stead.call(obj, 'use', obj2, ...);
if r ~= false then if r ~= false then
vv = call(obj2, 'used', obj, ...); vv = stead.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, ...); v, r = stead.call(game, 'use', obj, obj2, ...);
end end
if not v and not vv then if not v and not vv then
return return
@ -90,17 +90,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, ...); return stead.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, ...); return stead.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, ...); return stead.call(ref(r),'use', self.nam, ...);
end end
function vobj(name, dsc, w) function vobj(name, dsc, w)
@ -218,10 +218,10 @@ function list_str(self)
if isObject(o) and not isDisabled(o) then if isObject(o) and not isDisabled(o) then
vv = nil vv = nil
if game.gui then if game.gui then
vv = call(o, 'disp'); vv = stead.call(o, 'disp');
end end
if type(vv) ~= 'string' then if type(vv) ~= 'string' then
vv = call(o, 'nam'); vv = stead.call(o, 'nam');
end end
vv = xref(vv, o); vv = xref(vv, o);
v = stead.par(stead.delim, v, vv); v = stead.par(stead.delim, v, vv);
@ -243,10 +243,10 @@ function obj_str(self)
if isObject(o) and not isDisabled(o) then if isObject(o) and not isDisabled(o) then
vv = nil vv = nil
if game.gui then if game.gui then
vv = call(o, 'disp'); vv = stead.call(o, 'disp');
end end
if type(vv) ~= 'string' then if type(vv) ~= 'string' then
vv = call(o, 'nam'); vv = stead.call(o, 'nam');
end end
vv = xref(vv, o); vv = xref(vv, o);
v = stead.par(stead.delim, v, vv, obj_str(o)); v = stead.par(stead.delim, v, vv, obj_str(o));

View file

@ -406,7 +406,7 @@ function obj_look(self)
if isDisabled(self) then if isDisabled(self) then
return return
end end
local v = call(self,'dsc'); local v = stead.call(self,'dsc');
if game.hinting then if game.hinting then
v = self:xref(v); v = self:xref(v);
elseif v then elseif v then
@ -477,7 +477,7 @@ function obj_str(self)
for i,o in opairs(self.obj) do for i,o in opairs(self.obj) do
o = ref(o); o = ref(o);
if o~= nil and not isDisabled(o) then -- isObject is better, but compat layer must be ok 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); vv = xref(vv, o);
v = stead.par(',', v, vv, obj_str(o)); v = stead.par(',', v, vv, obj_str(o));
end end
@ -594,7 +594,7 @@ function list_str(self)
for i,o in opairs(self) do for i,o in opairs(self) do
o = ref(o); o = ref(o);
if o~= nil and not isDisabled(o) then if o~= nil and not isDisabled(o) then
vv = call(o, 'nam'); vv = stead.call(o, 'nam');
vv = xref(vv, o); vv = xref(vv, o);
v = stead.par(',', v, vv); v = stead.par(',', v, vv);
end end
@ -674,7 +674,7 @@ function list_name(self, name, dis)
for n,o,ii in opairs(self) do for n,o,ii in opairs(self) do
o = ref(o); o = ref(o);
if isObject(o) then 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 if ( not isDisabled(o) or dis ) and name == tostring(nam) then
return ii; return ii;
end end
@ -839,6 +839,7 @@ function call(v, n, ...)
end end
error ("Method not string nor function:"..tostring(n), 2); error ("Method not string nor function:"..tostring(n), 2);
end end
stead.call = call
function call_bool(v, n, ...) function call_bool(v, n, ...)
if type(v) ~= 'table' then if type(v) ~= 'table' then
@ -861,6 +862,7 @@ function call_bool(v, n, ...)
end end
return true; -- not nil return true; -- not nil
end end
stead.call_bool = call_bool
function call_value(v, n, ...) function call_value(v, n, ...)
if type(v) ~= 'table' then if type(v) ~= 'table' then
@ -879,11 +881,12 @@ function call_value(v, n, ...)
stead.callpop(); stead.callpop();
return r,v; return r,v;
end end
stead.call_value = call_value
function room_scene(self) function room_scene(self)
local v; local v;
v = iface:title(call(self,'nam')); v = iface:title(stead.call(self,'nam'));
v = stead.par('^^', v, call(self,'dsc')); --obj_look(self)); v = stead.par('^^', v, stead.call(self,'dsc')); --obj_look(self));
return stead.cat(v,' '); return stead.cat(v,' ');
end end
@ -960,8 +963,8 @@ end
function dialog_scene(self) function dialog_scene(self)
local v local v
v = iface:title(call(self,'nam')); v = iface:title(stead.call(self,'nam'));
v = stead.par('^^', v, call(self, 'dsc')); --obj_look(self)); v = stead.par('^^', v, stead.call(self, 'dsc')); --obj_look(self));
return v; return v;
end end
@ -1118,7 +1121,7 @@ function phrase_action(self)
-- here it is -- here it is
ph:disable(); -- /* disable it!!! */ ph:disable(); -- /* disable it!!! */
local last = call(ph, 'ans'); local last = stead.call(ph, 'ans');
if type(ph.do_act) == 'string' then if type(ph.do_act) == 'string' then
local f = loadstring(ph.do_act); local f = loadstring(ph.do_act);
@ -1168,7 +1171,7 @@ function phrase_look(self, n)
if isDisabled(self) then if isDisabled(self) then
return return
end end
local v = call(self, 'dsc'); local v = stead.call(self, 'dsc');
if type(v) ~= 'string' then return; end if type(v) ~= 'string' then return; end
if game.hinting then if game.hinting then
return self:xref('{'..v..'}'); return self:xref('{'..v..'}');
@ -1253,13 +1256,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, ...); --player_do(self, what, ...); return stead.call(ref(game), 'action', what, ...); --player_do(self, what, ...);
end end
v, r = player_take(self, what, ...); v, r = player_take(self, what, ...);
if not v then if not v then
v, r = call(ref(obj), 'act', ...); v, r = stead.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, ...); v, r = stead.call(ref(game), 'act', obj, ...);
end end
end end
return v, r; return v, r;
@ -1271,7 +1274,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', ...); v,r = stead.call(ref(obj), 'tak', ...);
if v and r ~= false then if v and r ~= false then
take(obj, w); take(obj, w);
end end
@ -1294,10 +1297,10 @@ function player_use(self, what, onwhat, ...)
if scene_use_mode then if scene_use_mode then
return self:action(what, ...); -- call act return self:action(what, ...); -- call act
else else
v, r = call(ref(obj),'inv', ...); -- call inv v, r = stead.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, ...); v, r = stead.call(game, 'inv', obj, ...);
end end
return v, r; return v, r;
end end
@ -1309,13 +1312,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, ...); v, r = stead.call(ref(obj), 'use', obj2, ...);
if r ~= false then if r ~= false then
vv = call(ref(obj2), 'used', obj, ...); vv = stead.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, ...); v, r = stead.call(game, 'use', obj, obj2, ...);
end end
return stead.par(' ', v, vv); return stead.par(' ', v, vv);
end end
@ -1358,7 +1361,7 @@ function go(self, where, back)
local v, r; local v, r;
if not isVroom(ref(where)) and not stead.in_exit_call then if not isVroom(ref(where)) and not stead.in_exit_call then
stead.in_exit_call = true -- to break recurse 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 stead.in_exit_call = nil
if r == false then if r == false then
return v, ret(r) return v, ret(r)
@ -1369,7 +1372,7 @@ function go(self, where, back)
v = nil; v = nil;
if not back or not isDialog(ref(self.where)) or isDialog(ref(where)) then 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 if r == false then
return v, ret(r) return v, ret(r)
end end
@ -1471,7 +1474,7 @@ function game_life(self)
o = ref(o); o = ref(o);
if not isDisabled(o) then if not isDisabled(o) then
PLAYER_MOVED = false PLAYER_MOVED = false
vv,pre = call(o,'life'); vv,pre = stead.call(o, 'life');
if pre or (PLAYER_MOVED and pre ~= false) then if pre or (PLAYER_MOVED and pre ~= false) then
av = stead.par(' ', av, vv); av = stead.par(' ', av, vv);
else else
@ -1541,7 +1544,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', ...)); v = stead.par('', v, stead.call(o, 'ini', ...));
end end
math.randomseed(os.time(os.date("*t"))) math.randomseed(os.time(os.date("*t")))
rnd(1); rnd(2); rnd(3); -- Lua bug? rnd(1); rnd(2); rnd(3); -- Lua bug?
@ -1569,8 +1572,8 @@ stead.do_ini = do_ini
function game_ini(self) function game_ini(self)
local v,vv local v,vv
v = stead.do_ini(self); v = stead.do_ini(self);
vv = iface:title(call(self,'nam')); vv = iface:title(stead.call(self,'nam'));
vv = stead.par('^^', vv, call(self,'dsc')); vv = stead.par('^^', vv, stead.call(self,'dsc'));
if type(init) == 'function' then if type(init) == 'function' then
init(); init();
end end
@ -1629,14 +1632,14 @@ function isEnableSave()
if game.enable_save == nil or get_autosave() then if game.enable_save == nil or get_autosave() then
return true return true
end end
return call_bool(game, 'enable_save'); return stead.call_bool(game, 'enable_save');
end end
function isEnableAutosave() function isEnableAutosave()
if game.enable_autosave == nil then if game.enable_autosave == nil then
return true return true
end end
return call_bool(game, 'enable_autosave'); return stead.call_bool(game, 'enable_autosave');
end end
function for_each(o, n, f, fv, ...) function for_each(o, n, f, fv, ...)
@ -1870,7 +1873,7 @@ function game_save(self, name, file)
if not h then if not h then
return nil, false return nil, false
end end
local n = call(here(),'nam'); local n = stead.call(here(),'nam');
if type(n) == 'string' and n ~= "" then if type(n) == 'string' and n ~= "" then
h:write("-- $Name: "..n:gsub("\n","\\n").."$\n"); h:write("-- $Name: "..n:gsub("\n","\\n").."$\n");
end end
@ -1929,21 +1932,21 @@ end
function isForcedsc(v) function isForcedsc(v)
local r,g local r,g
r = call_bool(v, 'forcedsc'); r = stead.call_bool(v, 'forcedsc');
if r then if r then
return true return true
end end
g = call_bool(game, 'forcedsc', v); g = stead.call_bool(game, 'forcedsc', v);
return g and r ~= false return g and r ~= false
end end
function isSceneUse(v) function isSceneUse(v)
local o,g local o,g
o = call_bool(v, 'scene_use'); o = stead.call_bool(v, 'scene_use');
if o then if o then
return true return true
end end
g = call_bool(game, 'scene_use', v); g = stead.call_bool(game, 'scene_use', v);
return g and o ~= false return g and o ~= false
end end
@ -2309,12 +2312,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, ...); return stead.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, ...); return stead.call(ref(r),'used', self.key, ...);
end end
function vobj(key, name, dsc, w) function vobj(key, name, dsc, w)
@ -2571,15 +2574,15 @@ function movef(obj, there, from)
end end
function get_picture() function get_picture()
local s = call(here(),'pic'); local s = stead.call(here(),'pic');
if not s then if not s then
s = call(game, 'pic'); s = stead.call(game, 'pic');
end end
return s; return s;
end end
function get_title() function get_title()
local s = call(here(),'nam'); local s = stead.call(here(),'nam');
return s; return s;
end end
@ -2794,7 +2797,7 @@ stead.hook = hook
function nameof(v) function nameof(v)
if isObject(v) then if isObject(v) then
local r = call(v, 'nam'); local r = stead.call(v, 'nam');
return r return r
end end
end end

View file

@ -2,9 +2,9 @@ game.action = stead.hook(game.action, function(f, s, cmd, ...)
if cmd == 'user_timer' then if cmd == 'user_timer' then
local r,v local r,v
if here().timer then if here().timer then
r,v = call(here(), 'timer'); r,v = stead.call(here(), 'timer');
elseif s.timer then elseif s.timer then
r,v = call(s, 'timer'); r,v = stead.call(s, 'timer');
end end
if r == nil and v == nil and stead.api_version < "1.3.5" then if r == nil and v == nil and stead.api_version < "1.3.5" then
return nil, true return nil, true

View file

@ -110,7 +110,7 @@ function xdsc(n)
error("Wrong parameter to xdsc.", 2); error("Wrong parameter to xdsc.", 2);
end end
v.dsc = function(s) v.dsc = function(s)
return call(here(), s.disp); return stead.call(here(), s.disp);
end end
v.save = function(self, name, h, need) v.save = function(self, name, h, need)
if need then if need then
@ -123,7 +123,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 = stead.call(s, 'xdsc');
return par(' ', xdsc, f(s, ...)); return par(' ', xdsc, f(s, ...));
end) end)
return v return v