Page 1 of 1

Timed Target Cursor

Posted: Thu Oct 11, 2007 10:42 pm
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?

Posted: Fri Oct 12, 2007 12:10 am
by OldnGrey
Fixed by MuadDib in record time.
Fix available in distro SVN now.

Many thanks.

Posted: Fri Oct 12, 2007 12:27 am
by MuadDib
NP. Please be sure to do extensive testing and report back in irc or here :)

Posted: Fri Oct 12, 2007 4:04 am
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.