/usr/share/games/instead/stead/walk.lua is in instead-data 1.9.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | local function onevent(ev, ...)
local vv, r
if stead.api_version >= "1.6.3" then
vv, r = stead.call(game, ev, ...);
if r == false then
return vv, false
end
if vv == false then
return nil, false
end
return vv
end
end
local go = function (self, where, back, noenter, noexit, nodsc)
local was = self.where;
local need_scene = false;
local ret
if not stead.in_walk_call then
ret = function(rc) stead.in_walk_call = false return nil end
else
ret = function(rc) return rc end
end
stead.in_walk_call = true
if where == nil then
return nil, ret(false)
end
if not isRoom(stead.ref(where)) then
error ("Trying to go nowhere: "..where);
end
if not isRoom(stead.ref(self.where)) then
error ("Trying to go from nowhere: "..self.where);
end
if stead.in_entered_call or stead.in_onexit_call then
error ("Do not use walk from left/entered action! Use exit/enter action instead:" .. self.where);
end
local v, r, jump;
if not isVroom(stead.ref(where)) and not stead.in_exit_call and not noexit then
stead.in_exit_call = true -- to break recurse
v,r = stead.call(stead.ref(self.where), 'exit', stead.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)
end
if self.where ~= was then
where = stead.deref(self.where) -- jump
jump = true
end
end
local res = v;
v = nil;
if not isVroom(stead.ref(where)) then
self.where = stead.deref(where);
end
if not jump and not noenter then
v, r = stead.call(stead.ref(where), 'enter', stead.ref(was));
if r == false or (stead.api_version >= "1.3.0" and v == false and r == nil) then
self.where = was;
return stead.par(stead.scene_delim, res, v), ret(r)
end
end
need_scene = true;
if stead.ref(where) ~= stead.ref(self.where) then -- jump !!!
need_scene = false;
end
res = stead.par(stead.scene_delim, res, v);
if not back then
stead.ref(where).__from__ = stead.deref(was);
end
ret()
PLAYER_MOVED = true
if need_scene and not nodsc then
NEED_SCENE = true
end
if not stead.in_walk_call then
local to = self.where
if not noexit then
self.where = was
stead.in_onexit_call = true
v = stead.call(stead.ref(was), 'left', stead.ref(to));
stead.in_onexit_call = false
res = stead.par(stead.scene_delim, res, v);
end
self.where = stead.deref(to)
if not noenter then
stead.in_entered_call = true
v = stead.call(stead.ref(to), 'entered', stead.ref(was));
stead.in_entered_call = false
res = stead.par(stead.scene_delim, res, v);
end
if tonumber(stead.ref(to).__visited) then
stead.ref(to).__visited = stead.ref(to).__visited + 1;
elseif stead.here().__visited == nil then
stead.ref(to).__visited = 1
end
if stead.api_version < "1.6.3" and isDialog(stead.ref(to)) then
stead.dialog_rescan(stead.ref(to))
end
end
return res;
end
stead.player_go = function(self, where) -- cmd iface
local w = stead.ref(self.where).way:srch(where);
if not w then
return nil,false
end
return self:walk(w);
end
stead.player_walk = function(self, where, ...) -- real work
local v, r, vv;
vv, r = onevent('onwalk', stead.ref(where), ...);
if vv == false then
return
end
if r == false then
return vv
end
v, r = stead.go(self, where, ...);
if type(vv) == 'string' then
v = stead.par(stead.space_delim, vv, v);
end
return v, r;
end
stead.player_back = function(self) -- deprecated
error ("Do not use stead.me():back(). It's deprecated.", 2)
end
stead.back = function(w)
if isDialog(stead.here()) and not isDialog(stead.from()) then
return stead.walkout(w);
end
return stead.walkback(w);
end
back = stead.back
stead.walkback = function(w)
if isRoom(stead.ref(w)) then
return stead.me():walk(w, true);
end
return stead.me():walk(stead.from(), true);
end
walkback = stead.walkback
stead.walk = function(what, back, noenter, noexit, nodsc, ...)
return stead.me():walk(what, back, noenter, noexit, nodsc, ...);
end
walk = stead.walk
stead.walkin = function(what)
return stead.me():walk(what, false, false, true);
end
walkin = stead.walkin
stead.walkout = function(what)
if isRoom(stead.ref(what)) then
return stead.me():walk(what, true, true, false, true);
end
return stead.me():walk(stead.from(), true, true, false, true);
end
walkout = stead.walkout
function visited(w)
if not w then w = stead.here() end
w = stead.ref(w)
if w == nil then
return nil;
end
if not isRoom(w) then
error ("Wrong parameter to visited.", 2);
end
return w.__visited
end
function visits(w)
local n = visited(w)
if not n then n = 0 end
return n
end
iface.fmt = function(self, cmd, st, moved, r, av, objs, pv) -- st -- changed state (main win), move -- loc changed
local l, vv
if st then
av = txtem(av);
pv = txtem(pv);
-- if not PLAYER_MOVED then
r = txtem(r)
-- end
if isForcedsc(stead.here()) or NEED_SCENE then
l = stead.here():scene();
end
end
if moved then
vv = stead.fmt(stead.cat(stead.par(stead.scene_delim, r, l, av, objs, pv), '^'));
else
vv = stead.fmt(stead.cat(stead.par(stead.scene_delim, l, r, av, objs, pv), '^'));
end
return vv
end
stead.go = function(...)
local r,v = go(...)
if type(r) == 'string' and stead.cctx() then
stead.pr (r)
end
-- if stead.in_life_call then
-- ACTION_TEXT = nil
-- end
if r == nil and v == nil then
if stead.cctx() then
stead.cctx().action = true
else
r = true
end
end
return r,v
end
iface.cmd = stead.hook(iface.cmd, function(f, ...)
NEED_SCENE = nil
return f(...)
end)
player = stead.inherit(player, function(v)
v.look = function(s)
if not stead.started then
game:start()
stead.started = true
end
if game._time == 0 then
return stead.walk(stead.here(), false, false, true);
end
NEED_SCENE = true
if stead.api_version >= "1.3.5" then
return true -- force action
end
end
return v
end)
pl = player(pl) -- reinit
-- vim:ts=4
|