Jump to content
MIVIMEX

Sound from the child prim in the linkset

Recommended Posts

Hello! Help please to do so that the sound does NOT come from the ROOT prim BUT from a certain CHILD PRIM in the link set. (In this script it's a prim 2)
This is the script of generator, when you click on the button it makes a sound, the lamp lights up and the engine smokes. I will be grateful for any help! Thank you!

//* script_starts_here
//
integer run;
integer PARTICLES_PRIM = 2;

default
{
touch_start(integer total_number)
{
if(llDetectedKey(0)==llGetOwner())
{
if(run)
{
run = FALSE;
llLinkParticleSystem(PARTICLES_PRIM,[]);
llStopSound();
llPlaySound("Switch 08 On", 1.0);
llSetLinkPrimitiveParamsFast(LINK_SET, [
                PRIM_FULLBRIGHT, ALL_SIDES, FALSE]);
llSetLinkPrimitiveParamsFast(3, [ PRIM_GLOW, ALL_SIDES, FALSE ]);                
}
else
{
run = TRUE;

llPlaySound("Switch 08 On", 1.0);
llSetLinkPrimitiveParamsFast(3, [
                PRIM_FULLBRIGHT, 1, TRUE]);
llSetLinkPrimitiveParamsFast(3, [ PRIM_GLOW, 1, 0.2 ]);
llSleep(1.0);

llLinkParticleSystem(PARTICLES_PRIM,[PSYS_PART_MAX_AGE,1.46,
PSYS_PART_FLAGS, 263,
PSYS_PART_START_COLOR, <1, 1, 1>,
PSYS_PART_END_COLOR, <1, 1, 1>,
PSYS_PART_START_SCALE,<0.75, 0.39, 0.00>,
PSYS_PART_END_SCALE,<1.00, 0.88, 0.00>,
PSYS_SRC_PATTERN, 2,
PSYS_SRC_BURST_RATE,0.00,
PSYS_SRC_BURST_PART_COUNT,4,
PSYS_SRC_BURST_RADIUS,0.26,
PSYS_SRC_BURST_SPEED_MIN,0.04,
PSYS_SRC_BURST_SPEED_MAX,0.93,
PSYS_SRC_ANGLE_BEGIN, 1.65,
PSYS_SRC_ANGLE_END, 0.00,
PSYS_SRC_MAX_AGE, 0.0,
PSYS_SRC_TEXTURE, "74e8631c-33a9-bc1a-03d3-ede886272a21",
PSYS_PART_START_ALPHA, 0.41,
PSYS_PART_END_ALPHA, 0.00,
PSYS_SRC_ACCEL, <0.00, 0.00, -0.92>]);


//llPlaySound("Switch 08 On", 1.0);
//llSetLinkPrimitiveParamsFast(3, [
               // PRIM_FULLBRIGHT, 0, TRUE]);
//llSleep(1.0);
llPlaySound("harley_start", 1.0);
llSleep(2.0);
llLoopSound("idle", 1.0);


}
}
}
}
//* script_ends_here

 

Share this post


Link to post
Share on other sites

This can only be done with a second script in the link you want the sound to play from. LSL has no functions for this.

At this point you we should ask how far away the link is from the root. If it's not a significant distance, it's probably not worth it to add a second script because the effect just won't be very noticeable.

If you think the benefit is still worth it though, the easiest thing to use is llMessageLinked and the link_message event. 

  • Thanks 1

Share this post


Link to post
Share on other sites
36 minutes ago, Wulfie Reanimator said:

If you think the benefit is still worth it though, the easiest thing to use is llMessageLinked and the link_message event. 

@Wulfie Reanimator

Thank you very much for the quick response! what if i move the script and sounds in the prim where the sound should come from, how do I make it turn on only when I click on a specific prim (button) in the linkset?

Edited by MIVIMEX

Share this post


Link to post
Share on other sites
1 hour ago, MIVIMEX said:

@Wulfie Reanimator

Thank you very much for the quick response! what if i move the script and sounds in the prim where the sound should come from, how do I make it turn on only when I click on a specific prim (button) in the linkset?

I believe you would again need two scripts because a non-root script will not receive touch events unless it was touched directly.

With that in mind, I think you could move the main script into the button and the sound script into where you want the sound to come from. This has one neat effect of the cursor not changing into a hand unless it is hovering over the button specifically.

I can't get inworld to double-check though. 

  • Thanks 1

Share this post


Link to post
Share on other sites

For single script multi object systems i add an extra prim to the link set as a sound emitter and i move it in place before playing.

Doesn't work for loops obviously.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×