From 5e431c248f5c940afb6045db051458e97ebf547c Mon Sep 17 00:00:00 2001
From: "p.kosyh"
Date: Fri, 15 Apr 2011 09:17:34 +0000
Subject: [PATCH] click press, release
---
stead/click.lua | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/stead/click.lua b/stead/click.lua
index 0cde5b6..b22c5ae 100644
--- a/stead/click.lua
+++ b/stead/click.lua
@@ -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