Jump to content
MIVIMEX

Starter / Idle / Stall sounds Script

Recommended Posts

Hello! Help please create an effect script for the old generator (link set). everything should happen in a sequence:

pressing the on/off button
- prim 1
lights up a lamp -
prim 2 >done
starter sound - one time ..........................remains???
sound generator - loop >done
goes smoke - particles - from prim 3 >done
pressing the on/off button -
prim 1
smoke does not go  the generator's sound stops >done
starter stalls .......................................... remains???
the light goes out
- prim 2

while I was able to create such a script:

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

default
{
touch_start(integer total_number)
{
if(llDetectedKey(0)==llGetOwner())
{
if(run)
{
run = FALSE;
llLinkParticleSystem(PARTICLES_PRIM,[]);
llStopSound();
llSetLinkPrimitiveParamsFast(LINK_SET, [
                PRIM_FULLBRIGHT, ALL_SIDES, FALSE]);
}
else
{
run = TRUE;
llLinkParticleSystem(PARTICLES_PRIM,[PSYS_PART_MAX_AGE,1.46,
PSYS_PART_FLAGS, 263,
PSYS_PART_START_COLOR, <0.99, 0.74, 0.73>,
PSYS_PART_END_COLOR, <0.79, 0.65, 0.20>,
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>]);
llLoopSound("idle", 1.0);

llSetLinkPrimitiveParamsFast(2, [
                PRIM_FULLBRIGHT, 0, TRUE]);
}
}
}
}
//* script_ends_here

 


Ok I managed to make it so that the particles were coming from a separate prim. remains to understand how to insert the sound of a starter and a stalling generator.  and the main thing is not clear why it turns on when you click on any place of the generator. how to make it work only when you click the on/off button? I will definitely continue to try to do everything myself, but if there are any tips I will be very grateful!
Thanks for any help!

Edited by MIVIMEX

Share this post


Link to post
Share on other sites

To know what link number has been touched, use llDetetedLinkNumber.   So you don't have to worry about link numbers changing, I would very strongly advise creating global variables with meaningful names (integer iOnOffButton, integer iLightBulb and so on), give the various prims appropriate names and then run through the linkset in state entry, matching them up -- something like 

//this is just a fragment, obviously

integer iOnOffButton;
integer iLightBulb;
default
{
	state_entry()
	{
		integer max = llGetNumberOfPrims();
		integer counter = 1;
		do{
			string str = llGetLinkName(counter);
			if("OnOff Switch" == str){//if the prim is called "OnOff Switch"
				iOnOffButton = counter;//store the link number as iOnOffButton
			}
			else if ("Light Bulb" == str){
				iLightBulb = counter;
				}
			//and so on
		}
		while(++counter < max);
	}
	touch_start(integer total_number)
	{
		integer i = llDetectedLinkNumber(0);
		if(iOnOffButton == i){
			//turn the machine on or off
		}
	}
}

To turn the lamp prim on and off, use llSetLinkPrimitiveParamsFast and PRIM_POINT_LIGHT.

To use a prim other than the one containing the script as a particle emitter, use llLinkParticleSystem.

To play a sound, use llPlaySound.

http://wiki.secondlife.com/wiki/LlDetectedLinkNumber

http://wiki.secondlife.com/wiki/LlGetLinkName

http://wiki.secondlife.com/wiki/LlSetLinkPrimitiveParamsFast#llSetLinkPrimitiveParamsFast

http://wiki.secondlife.com/wiki/LlLinkParticleSystem#llLinkParticleSystem

http://wiki.secondlife.com/wiki/LlPlaySound

Edited by Innula Zenovka
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

To limit the touch to just the on/off button, you must add a check for llDetectedLink.

For the sound, you could just llPlaySound, sleep for the duration of that sound, and then play the loop until the generator is turned off, which is when you llStopSound and play the stalling sound.

Optionally, you could use llSetSoundQueueing and ensure a more seamless transition from one sound to the next.

  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...