This file is indexed.

/usr/share/games/instead/stead/proxymenu.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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
stead.menu_prefix = '   '

local mpar = function(v, vv, rc) 		
	if type(v) == 'string' or type(vv) == 'string' then
		return stead.par(stead.space_delim, v, vv);
	elseif v == true or vv == true then
		return true
	end
	return rc
end

local call = function(o, m, ...)
	local rc = nil
	local v, r = stead.call(o, m, ...); 
	if r == false or v == false then
		rc = false
	elseif r or v then 
		rc = true 
	end
	return v, r, rc
end

stead.obj_proxy = function(o, act, use_mode, used_act, useit_act)
	local v = {};
	v.proxy_type = true;

	local d = stead.dispof(o);

	if type(d) == 'string' then
		v.nam = stead.menu_prefix..d;
	end

	if inv():srch(o) then
		v.nam = txtem(v.nam);
	end

	if not v.nam then
		v.nam = true
	end

	v.pobj = o;
	v.pact = act;
	v.use_mode = use_mode;
	v.used_act = used_act;
	v.useit_act = useit_act;

	v.save = function(self, name, h, need)
		if need then
			h:write(stead.string.format(name.." = stead.obj_proxy(%s, %s, %s, %s, %s);\n", 
				stead.tostring(self.pobj), 
				stead.tostring(self.pact),  
				stead.tostring(self.use_mode),
				stead.tostring(self.used_act),
				stead.tostring(self.useit_act)));
		end
		stead.savemembers(h, self, name, false);
	end

	if use_mode then
		v.use = function(s, w)
			if w.proxy_type then
				local v, r, vv, rr, rc = false, ri
				local act = s.pact
				v, r, ri = call(game, 'before_'..act, s.pobj, w.pobj);
				rc = ri or rc
				if ri == false then 
					return v, false 
				end
				vv, r, ri = call(s.pobj, act, w.pobj);
				rc = ri or rc
				v = mpar(v, vv, rc);

				if ri == false then
					return v, false
				end

				if type(s.used_act) == 'string' 
					and ri == nil then -- used only if use did nothing
					vv, r, ri = call(w.pobj, s.used_act, s.pobj);
					rc = ri or rc
					v = mpar(v, vv, rc);

					if ri == false then
						return v, false
					end
				end

				if ri then
					vv, rr, ri = call(game, 'after_'..act, s.pobj, w.pobj);
					rc = rc or ri
					v = mpar(v, vv, rc);

					if ri == false then
						return v, false
					end
				end

				if v == nil then
					v = stead.call(game, act, s.pobj, w.pobj);
				end

				return v, false;
			end
		end
	end

	v.inv = function(s)
		local v, r, vv, rr, rc = false, ri
		local act = s.pact
		if s.use_mode then
			act = s.useit_act
			if type(act) ~= 'string' then
				return nil
			end
		end

		v, r, ri = call(game, 'before_'..act, s.pobj); 
		rc = rc or ri
		if ri == false then
			return v
		end

		vv, r, ri = call(s.pobj, act); 
		rc = rc or ri
		v = mpar(v, vv, rc)

		if ri == false then
			return v
		end

		if ri then
			vv, rr, ri = call(game, 'after_'..act, s.pobj); 
			rc = rc or ri
			v = mpar(v, vv, rc);
		end
		if v == nil then
			v = stead.call(game, act, s.pobj);
		end

		return v, rc;
	end

	if use_mode then
		return obj(v)
	end
	return menu(v)
end

stead.proxy_fill_objs = function(s, w, act, use_mode, used_act, useit_act)
	local ii,i,o
	local rc = false
	for i,o,ii in opairs(w) do
		o = stead.ref(o);
		if isObject(o) and not isDisabled(o) and o ~= s and not isPhrase(o) 
			and not o.proxy_type and not isStatus(o) then

			s.obj:add(stead.obj_proxy(o, act, use_mode, used_act, useit_act));
			if not isRoom(o) then
				stead.proxy_fill_objs(s, o.obj, act, use_mode, used_act, useit_act);
			end
			rc = true
		end
	end
	return rc
end 

local select_only = function(s)
	local k, o, i
	for k,o in opairs(stead.me().obj) do
		o = stead.ref(o)
		if o.action_type and o._state and o ~= s then
			o:inv();
		end
	end
	stead.obj_tag(stead.me(), MENU_TAG_ID);
end


local proxy_menu = function(nam, act, _scene, _inv, _way, use_mode, used_act, useit_act, _ifhave)
	local v = { };
	if type(act) ~= 'string' then
		error("Wrong parameter to proxy_menu.", 3)
	end
	if null[act] then
		error(stead.tostring(act).."is a reserved handler. Do not use it.", 3)
	end

	if used_act and null[used_act] then
		error(stead.tostring(used_act).."is a reserved handler. Do not use it.", 3)
	end

	if useit_act and null[useit_act] then
		error(stead.tostring(useit_act).."is a reserved handler. Do not use it.", 3)
	end

	v.action_type = true;
	v._state = false;
	v.nam = nam;
	v.disp = function(s)
		local n = stead.call(s, 'nam')
		if s._state then
			return txtu(txtnb(n));
		end
		return txtnb(n);
	end

	v.fill_scene = _scene;
	v.fill_inv = _inv;
	v.fill_ifhave = _ifhave;
	v.fill_way = _way;

	v.gen = function(s)
		local k,o,i
		local rc = false
		s.obj:zap();
		if s.fill_inv then
			rc = stead.proxy_fill_objs(s, inv(), act, use_mode, used_act, useit_act);
		end
		if not s.fill_ifhave or rc then
			if s.fill_scene then
				stead.proxy_fill_objs(s, stead.here().obj, act, use_mode, used_act, useit_act);
			end
		end
		if s.fill_way then
			stead.proxy_fill_objs(s, stead.here().way, act, use_mode, used_act, useit_act);
		end
		select_only(s);
	end
	v.inv = function(s)
		local i,o
		local k,v
		s._state = not s._state 
		if s._state then
			s:gen();
		else
			s.obj:zap();
		end
		return nil, true -- to say instead, do not redraw scene, only inv ;)
	end
	return menu(v);
end

local function gen_actions(s)
	local k, o
	for k, o in opairs(stead.me().obj) do
		o = stead.ref(o)
		if o.action_type and o._state then
			o:gen();
		end
	end
end

act_menu = function(nam, act)
	local v = { };
	v.action_type = true;
	v.nam = nam;
	v.gen = function(s)
	end
	v.inv = function(s)
		local v, r 
		v, r = stead.call(game, act);
		return v, r
	end
	return menu(v);
end

obj_menu = function(nam, act, _scene, _inv, _way)
	return proxy_menu(nam, act, _scene, _inv, _way)
end

use_menu = function(nam, act, used_act, useit_act, _scene, _inv, _ifhave)
	return proxy_menu(nam, act, _scene, _inv, false, true, used_act, useit_act, _ifhave)
end

inv = function(s)
    return stead.me().inventory;
end

game.onuse = function(s, v, w) -- do not let use on non proxy obj
	if not v.proxy_type and not w.proxy_type then
		return
	end
	if not v.proxy_type or not w.proxy_type then
		return false
	end
end

player = stead.inherit(player, function(v)
	v.inv = function(s)
		gen_actions(s);
		return stead.player_inv(s);
	end
	v.inventory = list {}
	return v
end)

pl = player(pl) -- reinit
-- vim:ts=4