mouse example

This commit is contained in:
p.kosyh 2010-03-10 14:49:17 +00:00
parent 6c0bebcdd5
commit e8fbc401e6

24
doc/examples/mouse.lua Normal file
View file

@ -0,0 +1,24 @@
-- call here().click or game.click on pic clicks
input.click = function(s, press, mb, x, y, px, py)
if press and px then
return "__mclick__ "..mb..','..px..','..py;
end
end
game.action = function(s, cmd,...)
if cmd == '__mclick__' then
local r
local v
v, r = call(here(), 'click', unpack(arg));
if not v and r ~= true then
v, r = call(ref(game), 'click', unpack(arg));
end
if not v then
return nil, true
end
return v, r
end
return nil,true
end