Timed Target Cursor

Archive of posts related to former distro versions. Be aware that posts here do not refer to the current distro and may not work.

Moderators: POL Developer, Distro Developer

Locked
User avatar
OldnGrey
POL Expert
Posts: 657
Joined: Sat Feb 04, 2006 6:26 pm

Timed Target Cursor

Post by OldnGrey »

I tried using the TargetEX(who, time); functions and although they work I have some problems.

It is really easy to get a "nnnn used out-of-sequence target cursor" console error if you double click a target.

Also the function itself seems to be buggy: the second half after the return statment can't run can it?

Code: Select all

function TargetEX(mobile, duration:=0, flags := TGTOPT_CHECK_LOS+TGTOPT_NEUTRAL)
	if ( duration > 0 )
		if ( CInt(TS_GetTimerDuration(mobile, "TargetControl")) > 0 )
			// Existing timer... stop it (itll cancel the old target)
			TS_LowerDuration(mobile, "TargetControl", -1);
		endif

		TS_StartTimer(mobile, "TargetControl", duration);
	endif

	return Target(mobile, flags);

	if ( duration > 0 )
		if ( CInt(TS_GetTimerDuration(mobile, "TargetControl")) > 0 )
			TS_LowerDuration(mobile, "TargetControl", -1);
		endif
	endif

	return 1;
endfunction
It also appears the program is killed when the timer runs down. Any reason for this? Wouldn't it just be better for the target cursor to cancel and the TargetEX return 0 if it timed out?
User avatar
OldnGrey
POL Expert
Posts: 657
Joined: Sat Feb 04, 2006 6:26 pm

Post by OldnGrey »

Fixed by MuadDib in record time.
Fix available in distro SVN now.

Many thanks.
MuadDib
Former Developer
Posts: 1091
Joined: Sun Feb 12, 2006 9:50 pm

Post by MuadDib »

NP. Please be sure to do extensive testing and report back in irc or here :)
User avatar
OldnGrey
POL Expert
Posts: 657
Joined: Sat Feb 04, 2006 6:26 pm

Post by OldnGrey »

Yep, I am about to subject my staff to a square meal of TargetEX. This will soon weed out any problems.

As a matter of interest, the way MaudDib explained it, these functions are set up in such a way that it is important to test the function return for errors to avoid the "nnnn used out-of-sequence target cursor" errors. For example:

Code: Select all

var targetted := TargetEX(who, 10);
if ( !targetted or targetted.errortext )
  return 0;
endif
Both TargetEX and TargetCoordinatesEX will now return an error if there is already a target cursor being displayed.
Locked