click press, release
This commit is contained in:
parent
80fa273aeb
commit
5e431c248f
|
@ -5,9 +5,12 @@ click = {
|
|||
object_type = true;
|
||||
system_type = true;
|
||||
bg = false;
|
||||
press = false;
|
||||
save = function(self, name, h, need)
|
||||
local s = stead.tostring(self.bg)
|
||||
h:write(stead.string.format("click[%q] = %s;\n", 'bg', s))
|
||||
s = stead.tostring(self.press)
|
||||
h:write(stead.string.format("click[%q] = %s;\n", 'press', s))
|
||||
end;
|
||||
}
|
||||
|
||||
|
@ -15,16 +18,21 @@ stead.module_init(function()
|
|||
input.click = stead.hook(input.click,
|
||||
function(f, s, press, mb, x, y, px, py, ...)
|
||||
local cmd = 'click '
|
||||
if press then
|
||||
if press or click.press then
|
||||
|
||||
cmd = cmd..tostring(press)..',';
|
||||
|
||||
if click.bg or theme.get 'scr.gfx.mode' == 'direct' 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
|
||||
|
@ -34,7 +42,7 @@ stead.module_init(function()
|
|||
end)
|
||||
|
||||
game.action = stead.hook(game.action,
|
||||
function(f, s, cmd, x, y, px, py, ...)
|
||||
function(f, s, cmd, press, x, y, px, py, ...)
|
||||
if cmd == 'click' then
|
||||
local r,v
|
||||
local x2 = px
|
||||
|
@ -49,9 +57,14 @@ function(f, s, cmd, x, y, px, py, ...)
|
|||
end
|
||||
|
||||
if here().click then
|
||||
r,v = call(here(), 'click', tonumber(x), tonumber(y), x2, y2, ...);
|
||||
elseif s.click then
|
||||
r,v = call(s, 'click', tonumber(x), tonumber(y), x2, y2, ...);
|
||||
s = here()
|
||||
end
|
||||
if s.click then
|
||||
if click.press then
|
||||
r,v = call(s, 'click', press, tonumber(x), tonumber(y), x2, y2, ...);
|
||||
else
|
||||
r,v = call(s, 'click', tonumber(x), tonumber(y), x2, y2, ...);
|
||||
end
|
||||
end
|
||||
return r,v
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue