/usr/share/games/instead/stead/xact.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 | xact = function(n, f) -- just simple action!
local v = {};
if f == nil and type(n) == 'table' then
f = n[2];
n = n[1];
end
if type(n) ~= 'string' then
error ("Wrong parameter to xact.", 2)
end
v.xaction_type = true
v.nam = n
if stead.api_version >= "1.6.3" then
v.disp = false
end
v.act = f;
v = obj(v);
v.save = function(self, name, h, need)
if need then
local f = self.act;
f = stead.tostring(f);
if f == nil then
error("Can not save xact: "..name);
end
h:write(stead.string.format("%s = xact(%q, %s);\n", name, self.nam, f))
end
stead.savemembers(h, self, name, false);
end
return v
end
local __do_xact = function(str, self)
local aarg = {}
local function parg(v)
stead.table.insert(aarg, v);
return ''
end
local xrefrep = function(str)
local s = stead.string.gsub(str,'[\001\002]','');
local o,d,a, oo;
local delim = ':'
if stead.api_version >= "1.2.2" then
delim = stead.delim;
end
s = s:gsub('\\?[\\'..delim..']', { [ delim ] = '\001', [ '\\'..delim ] = delim });
local i = s:find('\001', 1, true);
aarg = {}
if i then
o = s:sub(1, i - 1);
d = s:sub(i + 1);
i = o:find("(", 1, true);
if i then
a = o:sub(i);
o = o:sub(1, i - 1);
a:gsub('[^,()]+', parg);
end
if o == '' then
if isObject(self) then
oo = self
else
error("Empty link: "..s, 3);
end
else
if stead.api_version >= "1.6.3" then
oo = stead.here():srch(o)
else
oo = objs():srch(o)
end
if not oo then
oo = stead.ref(o, true)
end
end
elseif isObject(self) then
oo = self
d = s;
else
error("Wrong link: "..s, 3);
end
d = d:gsub("\001", delim);
return stead.xref(d, stead.ref(oo, true), stead.unpack(aarg));
end
if type(str) ~= 'string' then return end
local s = stead.string.gsub(str, '\\?[\\{}]',
{ ['{'] = '\001', ['}'] = '\002' }):gsub('\001([^\002]+)\002', xrefrep):gsub('[\001\002]', { ['\001'] = '{', ['\002'] = '}' });
return s;
end
stead.fmt = stead.hook(stead.fmt, function(f, ...)
local i, res, s
local a = {...}
for i=1,stead.table.maxn(a) do
if type(a[i]) == 'string' then
s = __do_xact(a[i]);
res = stead.par('', res, s):gsub('\\?[\\{}]', { [ '\\{' ] = '{', [ '\\}' ] = '}' });
end
end
return f(res);
end)
obj = stead.inherit(obj, function(v)
v.xref = function(s, str)
return __do_xact(str, s);
end
return v
end)
function xdsc(n)
local v = {}
v.nam = true
if n == nil then
v.disp = 'xdsc'
elseif type(n) == 'string' then
v.disp = n;
else
error("Wrong parameter to xdsc.", 2);
end
v.dsc = function(s)
return stead.call(stead.here(), s.disp);
end
v.save = function(self, name, h, need)
if need then
h:write(stead.string.format("%s = xdsc(%q);\n", name, self.disp))
end
stead.savemembers(h, self, name, false);
end
return obj(v)
end
xroom = stead.inherit(room, function(v)
v.look = stead.hook(v.look, function(f, s,...)
local xdsc = stead.call(s, 'xdsc');
return stead.par(stead.space_delim, xdsc, f(s, ...));
end)
return v
end)
if stead.api_version >= "1.6.3" then
xwalk = xact('xwalk', code [[ stead.walk(arg1) ]]);
xwalk.system_type = true
end
-- vim:ts=4
|