Don't click here unless you want to be banned.

LSL Wiki : at_target

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org
at_target(integer tnum, vector targetpos, vector ourpos)

This event handler is triggered when the scripted object comes within a defined range of the target position targetpos (defined by the llTarget function call). See also the not_at_target() event.

The tnum parameter is the handle of the target that was reached (as returned by llTarget); examine this value when there are multiple targets active. The targetpos parameter gives the location of the target. The ourpos parameter gives the object's current position, which can be anywhere within the range specified in the original call to llTarget.

The following example demonstrates the use of llTarget and the associated event handlers. Note that while this example uses llMoveToTarget and llStopMoveToTarget, there is no requirement to use these functions; anything that moves the object to within range of the target will trigger the at_target event.

integer targetID;

default
{
    touch_start( integer total_number )
    {
        // Become a physical object
        llSetStatus(STATUS_PHYSICS, TRUE);

        llWhisper( 0, "we're on our way" );

        // destination is ten meters above our current position
        vector destination = llGetPos() + <0, 0, 10>;

        // how close is close enough 
        float range = 0.5; 

        // Ask to be informed whether we're there or not
        targetID = llTarget( destination, range );

        // Start moving towards the destination
        llMoveToTarget( destination, 10 );
    }

    not_at_target()
    {
        // We're not there yet.
        llWhisper(0, "Still going");
    }

    at_target( integer number, vector targetpos, vector ourpos )
    {
        llSay(0, "We've arrived!");

        // Stop notifications of being there or not
        llTargetRemove(targetID);

        // Stop moving towards the destination
        llStopMoveToTarget();

        // Become non-physical
        llSetStatus(STATUS_PHYSICS, FALSE);
    }
}


Events
There is no comment on this page. [Display comments/form]