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

LSL Wiki : moving_end

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org
moving_end()

This event is triggered when an object (physical or nonphysical) with this script stops moving (and changes position, including when attached) or exits 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 moving to a different sim?
A: No, the best you can do is filter your event as in:
string gPreviousSim; // previous simulator name

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

2009-03-27: Note that at present this event is not fired as a result of manual move in edit mode.
2010-07-18: This doesn't seem to be the case anymore. -AgentRevolution

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