Actually I got it to work in Lua script (but had to use a function return value to get the number of rectangles changed)
This works on my A590 for a=1, but it doesn't quite snap the picture when a=0. Here is my script so far:
--[[
@title security cam
rem Based on work done by MLuna - based om MX3 sample script
rem Tested A590
rem Shot without auto-focus/with auto-focus/continuously (need to put in continuous mode manually)
rem T implies test mode with MD cells drawing and no shots taken
@param a Shot (0=nf/1=f/2=c/3=t)
@default a 1
rem How long the shutter button will be pressed in continuous mode
@param b Continuos shoot (secs)
@default b 10
@param c Threshold (0-255)
@default c 5
@param d Compare Interval (msecs)
@default d 20
@param e Compare Interval (secs)
@default e 0
rem If this value is too small, the camera goes continuously shooting after the 1st shot.
rem Experiment with this value to find one fitted to your needs
@param f Begin Delay (secs)
@default f 5
@param g Pix step(speed/accuracy adj)
@default g 5
@param h Columns
@default h 6
@param i Rows
@default i 6
rem Frame width in which no MD is performed (in cell units)
@param j Dead frame
@default j 0
]]
if a<0 then
a=0
end
if a>3 then
a=3
end
if c<0 then
c=0
end
if d<0 then
d=0
end
if e<0 then
e=0
end
if g<1 then
g=1
end
if h<1 then
h=1
end
if i<1 then
i=1
end
if j<0 then
j=0
end
-- Conversions secs to msecs
b=b*1000
e=e*1000
f=f*1000
d=d+e
-- This is the timeout in msecs. After this period, the motion trap is rearmed.
T=600000
-- Parameters for the Dead Frame
J=j+1
H=h-j
I=i-j
t=0
print( "press Shutter to Stop")
while ( 1 ) do
rectangles = 0
rectangles = md_detect_motion( h, i, 1, T, d, c, 1, t, 1, J, J, H, I, 0, g, f)
t=rectangles
if a==0 and t>0 then click "shoot_full" end
if a==1 and t>0 then shoot() end
if a==2 and t>0 then
X=get_tick_count()
press("shoot_full")
while (V<b) do
U=get_tick_count()
V=(U-X)
end
release( "shoot_full" )
end
-- Test Mode Output
if a==3 then
if t>0 then
print( "Detected cells: ",t)
else
print( "No detection in 10 min!" )
end
t=0
end
-- end of while loop
end
print("END")