para fix, new goto cleanups

This commit is contained in:
p.kosyh 2010-06-23 10:35:53 +00:00
parent c8e91c66a6
commit f2333e2d8f
3 changed files with 42 additions and 8 deletions

View file

@ -82,13 +82,32 @@ go = function (self, where, back)
stead.in_entered_call = false
res = par('^^',res,v);
end
PLAYER_MOVED = true
if need_scene then -- or isForcedsc(ref(where)) then -- i'am not sure...
return par('^^',res,ref(where):scene());
NEED_SCENE = true
-- return par('^^',res,ref(where):scene());
end
return res;
end
iface.fmt = function(self, cmd, st, moved, r, av, objs, pv) -- st -- changed state (main win), move -- loc changed
local l
if st then
av = txtem(av);
pv = txtem(pv);
r = txtem(r)
if isForcedsc(here()) or NEED_SCENE then
l = here():scene();
end
end
if moved then
vv = stead.fmt(stead.cat(stead.par("^^", r, av, l, objs, pv), '^'));
else
vv = stead.fmt(stead.cat(stead.par("^^", l, r, av, objs, pv), '^'));
end
return vv
end
go = hook(go, function(f, ...)
local r,v = f(unpack(arg))
if type(r) == 'string' and cctx() then
@ -99,3 +118,17 @@ go = hook(go, function(f, ...)
end
return r,v
end)
iface.cmd = hook(iface.cmd, function(f, ...)
NEED_SCENE = nil
return f(unpack(arg))
end)
player = inherit(player, function(v)
v.look = function(s)
NEED_SCENE = true
end
return v
end)
pl = player(pl) -- reinit

View file

@ -1,7 +1,7 @@
stead.fmt = hook(stead.fmt, function(f, ...)
local r = f(unpack(arg))
if type(r) == 'string' then
r = r:gsub('~', txtnb(' '));
r = r:gsub('~[ \t]*([^ \t]+)', txtnb(' %1'));
end
return r;
end)

View file

@ -1170,7 +1170,7 @@ function go(self, where, back)
stead.in_entered_call = false
res = stead.par('^^',res,v);
end
PLAYER_MOVED = true
if need_scene then -- or isForcedsc(ref(where)) then -- i'am not sure...
return stead.par('^^',res,ref(where):scene());
end
@ -1715,7 +1715,8 @@ iface = {
local st = false; -- changed state (main screen)
local a = { };
local cmd;
RAW_TEXT = nil
PLAYER_MOVED = nil
cmd,a = stead.getcmd(inp);
-- me():tag();
local oldloc = here();
@ -1766,14 +1767,13 @@ iface = {
end
if RAW_TEXT then
RAW_TEXT = nil
v = false
end
if v == false then
return stead.cat(r, '\n'), false;
end
ACTION_TEXT = r; -- here, life methods can redefine this
local av, pv -- av -- active lifes, pv -- background
@ -1785,7 +1785,8 @@ iface = {
vv = here():look();
end
vv = self:fmt(cmd, st, oldloc ~= here(), ACTION_TEXT, av, vv, pv);
vv = self:fmt(cmd, st, (oldloc ~= here()) or PLAYER_MOVED,
ACTION_TEXT, av, vv, pv);
if st then
game._lastdisp = vv