From f2333e2d8fbb22f152a9557767df7bf107eb1a89 Mon Sep 17 00:00:00 2001
From: "p.kosyh"
Date: Wed, 23 Jun 2010 10:35:53 +0000
Subject: [PATCH] para fix, new goto cleanups
---
stead/goto.lua | 37 +++++++++++++++++++++++++++++++++++--
stead/para.lua | 2 +-
stead/stead.lua | 11 ++++++-----
3 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/stead/goto.lua b/stead/goto.lua
index e4632ce..8dd3dda 100644
--- a/stead/goto.lua
+++ b/stead/goto.lua
@@ -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
diff --git a/stead/para.lua b/stead/para.lua
index f6a01ba..1327184 100644
--- a/stead/para.lua
+++ b/stead/para.lua
@@ -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)
diff --git a/stead/stead.lua b/stead/stead.lua
index e8e44d0..081d95b 100644
--- a/stead/stead.lua
+++ b/stead/stead.lua
@@ -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