LSL Wiki Mirror 7-7-7 : moving_end

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings ::
moving_end()

This event is triggered when an object (physical or nonphysical) with this script stops moving (and changes position, including when attached) or enters a sim.

Compare with moving_start.

Example:
vector start;

default {
    moving_start() {
        start = llGetPos();
        llSleep(2.0); // this prevents the end event from getting triggered earlier than we want
    }
        
    moving_end() {
        llSay(0, "You moved me " + (string)llVecDist(start, llGetPos()) + " meters.");
    }
}

Q: Will moving_end be triggered when I change the rotation of my object?
A: No, both moving_start and moving_end are only triggered by a position change. There is no way to trigger on a rotation directly. To do so, you'll need to use a timer. The "exception" to this is if the object is an attachment. When your avatar turns, moving_start and moving_end will be triggered. Why? Because they're moving; their position has changed, because they're not rotating around the avatar's point of rotation, but rather in an arc.

Q: Is there a way to only trigger moving_end when entering a different sim?
A: No, the best you can do is filter your event as in:
string gCurrentSim; // current simulator name

default {
    moving_end(){
        // sim_name is so we only need to call llGetRegionName once.
        string sim_name = llGetRegionName();
        if (sim_name != gCurrentSim) {
            // if we're here, it means we've just entered a new sim.
            llOwnerSay("Entered " + sim_name + ".");
            gCurrentSim = sim_name;
        }
    }
}


Events | Position
There are 9 comments on this page. [Display comments/form]