MIVIMEX 51 Posted September 15, 2018 Share Posted September 15, 2018 (edited) 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 1lights up a lamp - prim 2 >donestarter sound - one time ..........................remains???sound generator - loop >donegoes smoke - particles - from prim 3 >donepressing the on/off button - prim 1smoke does not go the generator's sound stops >donestarter stalls .......................................... remains???the light goes out - prim 2while 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 September 15, 2018 by MIVIMEX Link to post Share on other sites
Innula Zenovka 3,512 Posted September 15, 2018 Share Posted September 15, 2018 (edited) 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 September 15, 2018 by Innula Zenovka 1 1 Link to post Share on other sites
Wulfie Reanimator 3,674 Posted September 15, 2018 Share Posted September 15, 2018 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. 1 Link to post Share on other sites
MIVIMEX 51 Posted September 15, 2018 Author Share Posted September 15, 2018 @Innula Zenovka @Wulfie Reanimator Thank you very much guys! It was just what I need! Everything works like magic! 1 Link to post Share on other sites
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
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 accountSign in
Already have an account? Sign in here.
Sign In Now