Jump to content

particle script trigger by linkmessage


You are about to reply to a thread that has been inactive for 4168 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Love this script!  Triggered by touch, but would like the trigger to be via link message....no idea how to do that.   (Waving the white flag.)  Any help greatly appreciated.

 

//- Click to start / stop




float MAX_RADIUS = 3.0;
float RADIUS_INTERVAL = 0.200;

// Modified values
integer IS_ON = FALSE;
float RADIUS = 2;
string TEXTURE = "09792b7c-cd84-5145-43c8-0bc3b57e657b";

garden() {
    llParticleSystem([
        PSYS_PART_FLAGS, 0 | PSYS_PART_EMISSIVE_MASK |
        PSYS_PART_INTERP_COLOR_MASK | PSYS_PART_INTERP_SCALE_MASK,
        PSYS_SRC_PATTERN,PSYS_SRC_PATTERN_ANGLE_CONE,

        // Texture / Size / Alpha / Color
        PSYS_SRC_TEXTURE, TEXTURE,
        PSYS_PART_START_SCALE,<0.0500, 0.0500, 0.0000>,
        PSYS_PART_END_SCALE,<0.150, 0.150, 0.0000>,
        PSYS_PART_START_ALPHA,0.0100000,
        PSYS_PART_END_ALPHA,1.000000,
        PSYS_PART_START_COLOR, <1.0,1.0,1.0>,
        PSYS_PART_END_COLOR, <1.0,1.0,1.0>,

        // Flow
        PSYS_PART_MAX_AGE,3000.0000,
        PSYS_SRC_BURST_RATE,1.000000,
        PSYS_SRC_BURST_PART_COUNT,1,
        PSYS_SRC_MAX_AGE,0.000000,

        // Rez position
        PSYS_SRC_BURST_RADIUS,RADIUS,
        PSYS_SRC_INNERANGLE,0,
        PSYS_SRC_OUTERANGLE,180.,
        PSYS_SRC_OMEGA,<0.00000, 0.00000, 4>,
        PSYS_SRC_BURST_SPEED_MIN,0.000000,
        PSYS_SRC_BURST_SPEED_MAX,0.000000
            ]);
}

stop() {
    llParticleSystem([]);
}

default {
    state_entry() {
        if(IS_ON) {
            llSetTimerEvent(RADIUS_INTERVAL);
            garden();
        } else {
                stop();
        }
    }

    touch_start(integer num_detected) {
        if(IS_ON) {
            llSetTimerEvent(0.0);
            stop();
            llWhisper(0, "off");
        } else {
                llSetTimerEvent(RADIUS_INTERVAL);
            garden();
            llWhisper(0, "on");
        }
        IS_ON = !IS_ON;
    }

    timer() {
        integer max_inventory = llGetInventoryNumber(INVENTORY_TEXTURE);
        if(max_inventory > 0) {
            TEXTURE = llGetInventoryName(INVENTORY_TEXTURE, (integer)llFrand(max_inventory));
        }
        RADIUS = llFrand(MAX_RADIUS);
        garden();
    }
} // END //


 

Link to comment
Share on other sites

The function you're looking for is llMessageLinked(); -- which you will send from whichever other prim in the linkset that you want to spur the event.

In the current script you have, you'll want to add a link_message() event.  This event will receive the llMessageLinked() that you send and be able to process it just like the touch event you have now.


For instance ... if script #1 sends the link message:

llMessageLinked(-1, 0, "Start", NULL_KEY);


I will receive those variables into my link_message() event ...

link_message(integer sender, integer int, string str, key id)
{
     if(str == "Start") //start your particle script;
}

 

Hope that helps!

Link to comment
Share on other sites

integer ON;default {    touch_end(integer num_detected) {        if(IS_ON) {           llMessageLinked(LINK_SET, 0, "Start", NULL_KEY);        } else {           llMessageLinked(LINK_SET, 0, "Stop", NULL_KEY);        }        IS_ON = !IS_ON;    }} 

 You could replace with this above

 

If you keep your old code and you add a script with linkedmessage , you will trigger twice the particles

Link to comment
Share on other sites

It does not matter that the script was written on touch, no.  You would simply move the functionality from the touch_start() event to the link_message() event.  Or, you could allow it to trigger both ways.  Remember that an event is just a 'hook', allowing you to trigger actions based on certain input or ... 'events'.  You can set your script to respond to whatever events you wish -- limited by those available to LSL of course.

Link to comment
Share on other sites

i think i'm getting confused because the "timer" sets the timing for the llSetTimerEvent which regulates the frequency of textures being changed.

so, if i use a link message to turn the bugger on, and one to turn it off, i have to either dedicate the timer to texture randomization or to the frequency that the particle script is triggered.

idealy I'd like the script to trigger via link message, run for 120 seconds, then sleep for 1800 seconds and repeat.  Can I call timer1, timer2? 

Much thanks from us green folks trying to figure out the pieces of the puzzle :)

Link to comment
Share on other sites

You can only have one active timer per script, BUT there are several ways around that limitation.  For instance:


1 - If you have a texture change, say, every 5 seconds ... and you want to run the whole system for 120 seconds before turning off ...

timer(){     if(isOn && itotalTime < 120) {          //change texture          itotalTime += 5;     } else {          //turn off system
if(isOn) { itotalTime = 0;
isOn = FALSE; llSetTimerEvent(1800.0);
} else {
isOn = TRUE;
llSetTimerEvent(5.0);
} }}

 

You'll note that in the timer event, I use a "flag" (isOn) that is either true/false to determine exactly what happens.  I also iterate an integer (itotalTime) to act as sort of a second counter.  So long as your larger time-period is divisible by your shorter time period, this method works out rather well.  You just have to run through some if-statements.

 

2 - You can send link messages from different scripts, each running a timer.  In that sense, your link-message simply becomes the trigger and all of your action is in the link_message() event.  So ... if you have a texture-change and you want to change it every 5 seconds ... set up another script with a 5 second timer that, on each timer() event sends an llMessageLinked() saying something like "Change texture".  Receive that in your link_message() event and call llSetTexture() - or however you're doing it.  You could make yet another script for turning particles on and off on a 120 second timer, etc.

Personally, I suggest option #1 :-)

And hey ... all of us were green once and all got help from others.  It's just passing things forward.

Link to comment
Share on other sites

There may be an additional independent timer in the script, implemented via llSensorRepeat() if one wants to go into such trouble. Just scan for something definitely not there and use no_sensor() event as an additional timer.

Preferably to that,  you may consider your timer event as a "system clock", set it to a 1sec tick and then if some occurance requires 20sec timing and another one 30 sec timing, count down from 20 and from 30 respectively in the timer event.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4168 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...