Can anyone explain why...?

A forum dedicated to George scripting questions
Post Reply
jokinb
Posts: 7
Joined: 18 Aug 2009, 07:13

Can anyone explain why...?

Post by jokinb »

Can anyone explain why in the following script the point is drawn in the same position always?

Code: Select all

a=1
do
	tv_getmouse
	parse result x y
	y = y * 65536               // fix bogus value for Y		   
	tv_ZDot x y 0 100		
	a=a+1	
	
until (a>10)
I use the Tv_Getmouse instruction but it seems that the actual x y values are not read. The dot is writen in the same position in the a -->10 cicle. This position is the x y value of the mouse when you press the script button that launch the code.

In the second script variation if I press the ok button with the "intro" keyboard´s button and I move the mouse around the screen the dots are drawn in differents positions. The x y values are read ok.

Code: Select all

a=1
do
	tv_getmouse
	parse result x y
	y = y * 65536               // fix bogus value for Y		   
	tv_ZDot x y 0 100		
	a=a+1	
	print x y
	
until (a>10)
User avatar
Hervé
Site Admin
Posts: 3490
Joined: 08 Feb 2006, 17:00
Location: Metz France
Contact:

Re: Can anyone explain why...?

Post by Hervé »

jokinb wrote:Can anyone explain why in the following script the point is drawn in the same position always?
Because the loop is too short and executed very fast, tv_getmouse return the immediate position of the cursor and the mouse position can't change in only 10 loop.
Hervé ADAM, TVPaint Team
jokinb
Posts: 7
Joined: 18 Aug 2009, 07:13

Re: Can anyone explain why...?

Post by jokinb »

write Until (a>100000) and the same thing happens.(???????)
jokinb
Posts: 7
Joined: 18 Aug 2009, 07:13

Re: Can anyone explain why...?

Post by jokinb »

Here is another test . Something is wrong. The tv_getmouse is not working ok. Despite moving the mouse Tv_getmouse does´nt detect new coordinates.
In the fololowing script I save the "y" value in the 4997, 5998, and 6999 cicle in an array.

Code: Select all

a=1
do
	tv_getmouse
	parse result x y
	y = y * 65536   // fix bogus value for Y
	if (a==4997)
	matriz(a)=y	// save in matriz(4997) the y value for test
	end
	if (a==5998)
	matriz(a)=y
	end
	if (a==6999)
	matriz(a)=y
	end
	tv_ZDot x y 0 100		
	a=a+1	
		
until (a>10000)

print "coordinate y:" matriz(4997) matriz(5998) matriz(6999) 
We get the same y value along the cicle
Svengali
Posts: 1553
Joined: 28 Dec 2006, 10:08

Re: Can anyone explain why...?

Post by Svengali »

I tested tv_GetMouse using the following script and it appears to not update when I move the mouse and sample X and Y 10 times during the loop.
I agree, something is probably wrong with tv_GetMouse.

Code: Select all

// readXY.grg

X = 0
Y = 0
OrigXandY = ""
XandY = ""

tv_GetMouse
parse result X Y
	OrigXandY = "Before Loop, X = " X "  Y = " Y


For i = 1 to 10
	Stamp()
END

XandY = OrigXandY "         After Loop, X = " X "  Y = " Y

tv_warn XandY						// display original and final X and Y values

Function Stamp
	tv_GetMouse
	parse result X Y
	IF Y < .1
	   Y = Y * 65536				// fix bogus value for Y
	END

	tv_ZDot X Y 0 100				// stamp cutbrush

	XandY = "loop count = " i "   X = " X "  Y = " Y

	tv_LockDisplay XandY			// locks display and shows message
		Delay()						// prolongs locked message display
	tv_UnLockDisplay				// unlocks display
END

Function Delay
	For j = 1 to 100000				// delays approx. 1 second
	END
END

Sven
User avatar
Hervé
Site Admin
Posts: 3490
Joined: 08 Feb 2006, 17:00
Location: Metz France
Contact:

Re: Can anyone explain why...?

Post by Hervé »

OK, the mouse coordinate change only when the software run the main message loop ( it's a normal behavior ).
Try this:
GetMouse.tvpx
(4.5 KiB) Downloaded 142 times
In the example, the script is called at each mouse position.
Hervé ADAM, TVPaint Team
jokinb
Posts: 7
Joined: 18 Aug 2009, 07:13

Re: Can anyone explain why...?

Post by jokinb »

Thanks
Now it works fine
jokinb
Posts: 7
Joined: 18 Aug 2009, 07:13

Re: Can anyone explain why...?

Post by jokinb »

It is a bug?

If we have selected as active tool the "Warpbrush" ,the "tv_getactivetool" instruction give us an error "mode" value.
If we have selected a "Warp Out" mode , the"tv_getactivetool" said us that it is in "Warp In" mode and vive versa.

Select the Warpbrush tool and test the folloging code:

Code: Select all

tv_getactivetool
parse result tool 
texto= tool
print texto
Post Reply