steed/stead/click.lua

51 lines
1,006 B
Lua
Raw Normal View History

2010-11-07 14:04:18 +02:00
click = {
nam = 'click';
object_type = true;
system_type = true;
bg = false;
save = function(self, name, h, need)
local s = stead.tostring(self.bg)
h:write(stead.string.format("click[%q] = %s;\n", 'bg', s))
end;
}
2010-07-22 13:39:48 +03:00
stead.module_init(function()
input.click = stead.hook(input.click,
function(f, s, press, mb, x, y, px, py, ...)
2010-11-07 14:04:18 +02:00
local cmd = 'click '
if press then
if click.bg then
cmd = cmd .. x .. ','.. y
if px then
cmd = cmd .. ','
end
end
if px then
cmd = cmd .. px .. ',' .. py
end
if cmd ~= 'click ' then
return cmd
end
2010-07-22 13:39:48 +03:00
end
2011-02-23 12:11:27 +02:00
return f(s, press, mb, x, y, px, py, ...)
2010-07-22 13:39:48 +03:00
end)
2010-06-16 12:41:03 +03:00
end)
2010-06-07 16:53:00 +03:00
2010-06-23 15:09:33 +03:00
game.action = stead.hook(game.action,
2010-06-07 16:53:00 +03:00
function(f, s, cmd, x, y, ...)
if cmd == 'click' then
2010-07-19 09:40:58 +03:00
local r,v
2010-06-09 13:19:11 +03:00
if here().click then
2011-02-23 12:11:27 +02:00
r,v = call(here(), 'click', x, y, ...);
2010-07-19 09:40:58 +03:00
elseif s.click then
2011-02-23 12:11:27 +02:00
r,v = call(s, 'click', x, y, ...);
2010-06-09 13:19:11 +03:00
end
2010-07-19 09:40:58 +03:00
if r == nil and v == nil then
return nil, true
2010-06-09 13:19:11 +03:00
end
2010-07-19 09:40:58 +03:00
return r,v
2010-06-07 16:53:00 +03:00
end
2011-02-23 12:11:27 +02:00
return f(s, cmd, x, y, ...)
2010-06-07 16:53:00 +03:00
end)
2010-07-06 13:15:27 +03:00
-- vim:ts=4