1require "theme" 2 3click = { 4 nam = 'click'; 5 object_type = true; 6 system_type = true; 7 bg = false; 8 press = false; 9 button = false; 10 save = function(self, name, h, need) 11 local s = stead.tostring(self.bg) 12 h:write(stead.string.format("click[%q] = %s;\n", 'bg', s)) 13 s = stead.tostring(self.press) 14 h:write(stead.string.format("click[%q] = %s;\n", 'press', s)) 15 s = stead.tostring(self.button) 16 h:write(stead.string.format("click[%q] = %s;\n", 'button', s)) 17 end; 18} 19 20stead.module_init(function() 21 input.click = stead.hook(input.click, 22 function(f, s, press, mb, x, y, px, py, ...) 23 local cmd = 'click ' 24 local act = false 25 if ( press or click.press ) and ( mb == 1 or click.button ) then 26 cmd = cmd..stead.tostr(press)..','..stead.tostr(mb); 27 28 if click.bg or theme.get 'scr.gfx.mode' == 'direct' then 29 act = true 30 cmd = cmd .. ',' .. x .. ','.. y 31 end 32 33 if px then 34 act = true 35 cmd = cmd .. ',' .. px .. ',' .. py 36 end 37 38 if act then 39 return cmd 40 end 41 end 42 return f(s, press, mb, x, y, px, py, ...) 43 end) 44end) 45 46game.action = stead.hook(game.action, 47function(f, s, cmd, press, mb, x, y, px, py, ...) 48 if cmd == 'click' then 49 local r,v 50 local x2 = px 51 local y2 = py 52 53 if stead.tonum(mb) then 54 mb = stead.tonum(mb) 55 end 56 57 if stead.tonum(px) then 58 x2 = stead.tonum(px) 59 end 60 61 if stead.tonum(py) then 62 y2 = stead.tonum(py) 63 end 64 65 if stead.here().click then 66 s = stead.here() 67 end 68 69 if press == 'true' then 70 press = true 71 else 72 press = false 73 end 74 75 if s.click then 76 if click.press then 77 if click.button then 78 r,v = stead.call(s, 'click', press, mb, stead.tonum(x), stead.tonum(y), x2, y2, ...); 79 else 80 r,v = stead.call(s, 'click', press, stead.tonum(x), stead.tonum(y), x2, y2, ...); 81 end 82 else 83 if click.button then 84 r,v = stead.call(s, 'click', mb, stead.tonum(x), stead.tonum(y), x2, y2, ...); 85 else 86 r,v = stead.call(s, 'click', stead.tonum(x), stead.tonum(y), x2, y2, ...); 87 end 88 end 89 end 90 if r == nil and v == nil and not stead.api_atleast(1, 3, 5) then 91 return nil, true 92 end 93 return r,v 94 end 95 return f(s, cmd, press, mb, x, y, px, py, ...) 96end) 97-- vim:ts=4 98