Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

moving_start()/moving_end() query

Carbon Philter
Registered User
Join date: 4 Apr 2008
Posts: 165
07-03-2009 16:22
Hi all.
I'm trying to set up a boat bow wave using particles. I've got the appearance I want and I set it using moving_start()/moving_end() but it doesn't seem to stop when the boat stops.

I've even tried putting a scrubber script in the prim to clear the prim attributes when the boat stops and moving_end should take effect.

Is there something I'm missing to make the particles stop/start properly?

Thanks for any help/advice.

The script is as follows:

list particle_parameters=[]; // stores your custom particle effect, defined below.
list target_parameters=[]; // remembers targets found using TARGET TEMPLATE scripts.

default
{
state_entry()
{
particle_parameters = [ // start of particle settings
// Texture Parameters:
(
........particles blurb.............
)
//end of particle settings
];
}

moving_start()
{
llParticleSystem( particle_parameters + target_parameters );
}

moving_end()
{
llParticleSystem( [ ] );
}
}
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
07-03-2009 16:34
It's probably because your boat hasn't actually stopped moving, or the moving_end event wasn't triggered after moving_start... put a debug in it to see, llOwnerSay. This will give you more data on when the events are actually being triggered.
Tali Rosca
Plywood Whisperer
Join date: 6 Feb 2007
Posts: 767
07-06-2009 11:58
More likely, it's simply because moving_start and moving_end are entirely broken.
http://jira.secondlife.com/browse/SVC-1004

As a workaround, you can run a timer and check if the position has (not) changed. Just be nice to the sim and don't run it too fast.
Carbon Philter
Registered User
Join date: 4 Apr 2008
Posts: 165
07-06-2009 15:11
Thx for the info, Tali.

I've gone and added my vote on the JIRA.

Now.............. This timer event thing - is it straightforward? I was comfortable getting my head round the moving_start/moving_end (with a struggle), but am not so confident with the timer process. Will I need an if/or event set up to have the position check whenever the timer triggers?
Tali Rosca
Plywood Whisperer
Join date: 6 Feb 2007
Posts: 767
07-07-2009 11:01
Yes, you'll have to poll the position in your timer, and check if it has changed. That way you know where you're moving or not. Then you need to check if that was a change (since you want to catch start and stop, not moving or not).

The readable version could look something like

integer wasMoving;
vector lastPos;

default
{
state_entry()
{
llSetTimerEvent(2.0);
}

timer()
{
if (llGetPos() == lastPos)
{
// We're not moving.
if (wasMoving)
{
wasMoving = FALSE;
llOwnerSay("Stopped moving";);
}
}
else
{
// We're moving. Keep track of position:
lastPos = llGetPos();
if (!wasMoving)
{
wasMoving = TRUE;
llOwnerSay("Started moving";);
}
}
}
}

...but since this is something which will be performed all the time, it would be good style to optimize it as much as possible, minimizing the number of commands, calls and stack pushing:

integer wasMoving;
vector lastPos;

default
{
state_entry()
{
llSetTimerEvent(2.0);
}

timer()
{
// This one registers the position, compares it to the previous to determine
// whether we're moving or not, and compares *that* to what we last knew, i.e.
// detecting a change in one go while we have all the variables.
if ((wasMoving = (lastPos = llGetPos()) == lastPos) != wasMoving)
{
// A change was detected. Now we just need to figure out which it was:
if(wasMoving)
llOwnerSay("Stopped moving";);
else
llOwnerSay("Started moving";);
}
}
}
Carbon Philter
Registered User
Join date: 4 Apr 2008
Posts: 165
07-07-2009 11:14
Many many thanks, Tali.

Marginally more complex than the moving_start/moving_end, I fear!!

Ok, I'll head off to a quiet corner and work on this....................

I think I feel a headache coming on!!

:)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-07-2009 13:06
you can record your last moving position and the current one, and then forcibly stop your boat if the change is below a certain threshold. although I don't know how much extra script time that's going to cause (you'd be doing you check in the moving event, perhaps llMinEventDelay may help in this case.)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -