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

LSL Wiki : moving_start

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

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

Compare with moving_end.

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_start be triggered when I change the rotation of an 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_start 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_start(){
        // 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;
        }
    }
}
A2: Instead you can now use changed with CHANGED_REGION
changed(integer change) {
    if (change & CHANGED_REGION) { 
        //region change code here
    }
}

2009-06-15: Note that at present this event is not reliably fired as a result of manual move in edit mode.
- Editing the position of an object does not physically move it, but rather changes its position in the database. While you edit-move the object using the Red, Green, & Blue arrows, the object is still in it's original position until you release the mouse button. The movement you see is purely client side. -- BurnmanBedlam

Events | Position
There is one comment on this page. [Display comments/form]