Difference between revisions of "Moving start"

From Second Life Wiki
Jump to navigation Jump to search
m (LSL moving start moved to Moving start: removing prefix)
m (Replaced old <LSL> block with <source lang="lsl2">)
 
(11 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{LSL_Event|event_id=25|event_delay|event=moving_start|event_desc=Triggered when task begins moving|constants|spec
{{LSL_Event|event_id=25|event_delay|event=moving_start
|caveats=The moving_start and moving_end events require special handling when scripting attachments.   To make the moving events fire correctly in this case, you have to add the script to the attachment, take off the attachment, then wear the attachment again. If you're changing the script while it is in the attachment, you recompile it, then remove the attachment, then wear the attachment. This only needs to be done when you're changing/adding scripts.
|inject-2={{Issues/SVC-1004}}
|examples|helpers|also_header|also_events|also_functions|also_articles|also_footer|notes|mode|deprecated}}[[Category:LSL_Stub]]
|event_desc=Triggered when task begins moving
|constants
|spec
|caveats=*The [[moving_start]] and [[moving_end]] events require special handling when scripting attachments.
**After adding or editing a script you must:
***Take off the attachment and then wear the attachment again.
 
*This event is also triggered when an object is rezzed (unless, presumably, you happen to rez it in precisely the same spot it was before.)
*This event's behavior is undefined for non-physical movement ([[llSetPos]], movement via [[Building_Tools|build tool]], etc.)
*This event is triggered when an object initiates a new [[LlSetKeyframedMotion|keyframed motion]], or when motion is resumed via KFM_CMD_PLAY
|examples=<source lang="lsl2">
//Physical Prim Movement Script
//By Nika Rugani
//With spam work around
 
vector pos;
float move_time = 5; //Move every 5 seconds
float increment = 5;
 
float power = 0.5; //The TAU
 
integer trigger_multiple = FALSE; // This bad boy will prevent spam of moving start event
integer trigger_slave = 1;
 
setPhysical(integer status_physics)
{
    llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_PHYSICS, status_physics]);
}
 
default
{
    touch_start(integer num_detected)
    {
        if(llGetStatus(STATUS_PHYSICS) == FALSE)
        {
            pos = llGetPos(); //Set the objects default position
            setPhysical(TRUE);
            llSetTimerEvent(move_time);
        }
        else
        {
            setPhysical(FALSE);
            llSetPos(pos);
        }
    }
    moving_start()
    {
        if(trigger_slave == 0)
        {
            llOwnerSay("YEY!! I'm Moving!");
            if(trigger_multiple == FALSE)
            {
                trigger_slave = 1;
            }
        }
    }
    moving_end()
    {
        llSetTimerEvent(move_time);
    }
    timer()
    {
        llSetTimerEvent(0);
        if(llVecDist(pos, llGetPos()) > (increment-2))
        {
            llMoveToTarget(pos, power);
        }
        else
        {
            llMoveToTarget(pos+<0.0,0.0,increment>, power);
        }
        trigger_slave = 0;
    }
}</source>
|helpers
|also_header
|also_events={{LSL DefineRow||[[moving_end]]|}}
|also_functions={{LSL DefineRow||[[llTarget]]|}}
{{LSL DefineRow||[[llRotTarget]]|}}
|also_articles
|also_footer
|notes
|mode
|deprecated
|cat1=Movement
|cat2=Physics
|cat3
|cat4
}}

Latest revision as of 00:18, 22 January 2015

Description

! Event: moving_start( ){ ; }

Triggered when task begins moving


Caveats

  • The moving_start and moving_end events require special handling when scripting attachments.
    • After adding or editing a script you must:
      • Take off the attachment and then wear the attachment again.
  • This event is also triggered when an object is rezzed (unless, presumably, you happen to rez it in precisely the same spot it was before.)
  • This event's behavior is undefined for non-physical movement (llSetPos, movement via build tool, etc.)
  • This event is triggered when an object initiates a new keyframed motion, or when motion is resumed via KFM_CMD_PLAY


Examples

//Physical Prim Movement Script
//By Nika Rugani
//With spam work around

vector pos;
float move_time = 5; //Move every 5 seconds
float increment = 5;

float power = 0.5; //The TAU

integer trigger_multiple = FALSE; // This bad boy will prevent spam of moving start event
integer trigger_slave = 1;

setPhysical(integer status_physics)
{
    llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_PHYSICS, status_physics]);
}

default
{
    touch_start(integer num_detected)
    {
        if(llGetStatus(STATUS_PHYSICS) == FALSE)
        {
            pos = llGetPos(); //Set the objects default position
            setPhysical(TRUE);
            llSetTimerEvent(move_time);
        }
        else
        {
            setPhysical(FALSE);
            llSetPos(pos);
        }
    }
    moving_start()
    {
        if(trigger_slave == 0)
        {
            llOwnerSay("YEY!! I'm Moving!");
            if(trigger_multiple == FALSE)
            {
                trigger_slave = 1;
            }
        }
    }
    moving_end()
    {
        llSetTimerEvent(move_time);
    }
    timer()
    {
        llSetTimerEvent(0);
        if(llVecDist(pos, llGetPos()) > (increment-2))
        {
            llMoveToTarget(pos, power);
        }
        else
        {
            llMoveToTarget(pos+<0.0,0.0,increment>, power);
        }
        trigger_slave = 0;
    }
}

See Also

Events

•  moving_end

Functions

•  llTarget
•  llRotTarget

Deep Notes

Issues

All Issues

~ Search JIRA for related Issues
   Behavior of moving_start() and moving_end() is inconsistent.

Signature

event void moving_start(  );