Jump to content

Trigger multiple scripts


Gryphon Ronas
 Share

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

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

Recommended Posts

I thought this would be a simple thing.  Two days of Googling and being baffled, asking in groups and getting answers that don't work...  OK, so maybe it isn't simple.

The items (including their scripts) are modifiable, so I can change whatever I need to - if I can grasp how to.

I have a light that goes fullbright and glows slightly when touched.  I have a curtain that opens and closes by resizing on touch. All I want to do is link them either to each other, or to a separate root prim, like a button.  Click the button, the curtain closes and the light goes on.  (Think of something like a voting booth)

If one of the two has to be the root, that's fine too.  Actually, preferable - I would rather touch the curtain prim and have it close and trigger the other script (make the light glow).

Is there any way to do this?  I have been told I can do it with listeners, but I have heard so many times that isn't a good idea.

Any help is greatly appreciated!  Thanks!

Link to comment
Share on other sites

The general answer is:

If you have linked prims, use llMessageLinked and link_message. This set of function and event is specifically for intra object communication.

Chat communication with llWhisper, llSay, llShout, llRegionSay or llRegionSayTo plus listen you need if the communicating prims are not linked.

I hope this points you in the right direction.

Link to comment
Share on other sites

if anyone can touch it to make it work then all you need to do is move the code from the touch event to a link_message event and have a script send a link message.

however it would be more efficient if a single script did it all using llSetLinkPrimitiveParams

Link to comment
Share on other sites

Tried looking up the first two suggestions, and I obviously don't know enough for the wiki to amke any sense.

By trying the 'stick it in wherever it will take it' method, I was able to put the set primitive params and LINK_ROOT one in the curtain, and I was able to trigger the root prim. But the curtain no longer works.

Maybe I don't need a light on there as bad as I thought I did. It may not be impossible to do for some - but for some of us, I guess it is.

Thanks for the help guys.

:-)

Link to comment
Share on other sites

If you want to do this the oldfashioned way with multiple scripts, you'd have a script like this in your root prim:

 

default{   touch_start(integer total_number)   {      llMessageLinked(LINK_SET,1,"touched",llDetectedKey(0));   }}

 

And a script like this in your light bulb:

 

integer toggle;default{   link_message(integer link, integer num, string message, key id)   {      if (message=="touched")      {           toggle=!toggle; // on/off switch           if(toggle)            {              llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE,               <1, 1, 1>, 1.0, 10.0, 0.75]); // light on           }           else           {              llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE,               <1, 1, 1>, 1.0, 10.0, 0.75]); // light off           }       }   }}

 

You can use a copy of the second script in your curtain prim. Just change the llSetPrimitiveParams commands to something that opens and closes the curtain.

As I said, this is the oldfashioned way. It works, but it uses more memory than necessary. Like Void said, you can do the same with a single script in the root prim using llSetLinkPrimitiveParams commands (or llSetLinkAlpha, llSetLinkTexture etc., depending on what you want to do). But if you don't have much experience as a scripter, you might find the above approach easier at the beginning.

PS: I didn't test the scripts, but I'm pretty sure that they work.

Link to comment
Share on other sites

Thanks.  I tried copying those in, but dind't get the light response.

I have managed to get the default state working using:

llSetLinkPrimitiveParams( 1, [ PRIM_FULLBRIGHT, ALL_SIDES, TRUE ] );

The default state on teh curtain is closed, so the light on is correct.  I also put it in right after the touch event starts, but with glow set to FALSE.  It turns the light off as you open the curtain.  Again - just what I want.  The problem is, it never comes on agaion when you close the curtain again.  The curtain doesn't move, it resizes from one end.  I think I can see how it doies that, but how it goes back to a closed state is a mystery to me.  If I could figure that out, maybe I could guess where to put the line to turn the light back on.

The curtain can't be the root prim because if it is, when it closes.opens, it moves the other prim with it.  So I seem to be a bit stuck there with that. I tried to post the code here, but it's s jumbled mess when I paste it.  (It's an open source script, so it would have been OK to post)

This is driving me nuts.  I finally got a handle on how to set the params of the prim fromm touching the other prim.... Now I can't make it do it more than once. I really do appreciate all the help from everyone though.  :-)

Link to comment
Share on other sites

vector offset = <1,0,0>; //Prim moves/changes size along this local coordinatefloat hi_end_fixed = FALSE; //Which end of the prim should remain in place when size changes?                                      //The one with the higher (local) coordinate? float min = 0.4; //The minimum size of the prim relative to its maximum sizeinteger ns = 10; //Number of distinct steps for move/size changedefault {    state_entry() {        offset *= ((1.0 - min) / ns) * (offset * llGetScale());        hi_end_fixed -= 0.5;        llSetLinkPrimitiveParams( 1, [ PRIM_FULLBRIGHT, ALL_SIDES, TRUE ] );    }        touch_start(integer detected) {        integer i;        llSetLinkPrimitiveParams( 1, [ PRIM_FULLBRIGHT, ALL_SIDES, FALSE ] );        do  llSetPrimitiveParams([PRIM_SIZE, llGetScale() - offset,                PRIM_POSITION, llGetLocalPos() + ((hi_end_fixed * offset) * llGetLocalRot())]);        while ((++i) < ns);                   offset = - offset;    }}

 You can see the 2 lines I added - and yeah - I dind't realize there was an "Insert Code" button.....  duh.  lol

Link to comment
Share on other sites

Just looked back and I see I replied to the wrong person when I posted the code.

Sorry - 4am will do that to ya.  ;-)

 

Also - I had wondered about a reset at the end of each event, but that won't work. No only would it turn the light on all the time, but when you resize the curtain, you stretch it then reset the script. That gives it a new value for its 'closed' size.

Link to comment
Share on other sites

After the loop that opens or closes the curtain. offset is assigned -offset - which basically just changes the direction. You have something along the same line for the light. What changes here is TRUE and FALSe. Since FALSE equals 0 and any other number means false, you can put a variable that toggles between 1 and 0

vector offset = <1,0,0>; //Prim moves/changes size along this local coordinatefloat hi_end_fixed = FALSE; //Which end of the prim should remain in place when size changes?                                      //The one with the higher (local) coordinate? float min = 0.4; //The minimum size of the prim relative to its maximum sizeinteger ns = 10; //Number of distinct steps for move/size changeinteger lighton = 1;default {    state_entry() {        offset *= ((1.0 - min) / ns) * (offset * llGetScale());        hi_end_fixed -= 0.5;        llSetLinkPrimitiveParams( 1, [ PRIM_FULLBRIGHT, ALL_SIDES, lighton ] );    }        touch_start(integer detected) {	integer i;	lighton = !lighton;        llSetLinkPrimitiveParams( 1, [ PRIM_FULLBRIGHT, ALL_SIDES, lighton ] );        do  llSetPrimitiveParams([PRIM_SIZE, llGetScale() - offset,                PRIM_POSITION, llGetLocalPos() + ((hi_end_fixed * offset) * llGetLocalRot())]);        while ((++i) < ns);                   offset = - offset;    }}

 

  • Like 1
Link to comment
Share on other sites

Has anyone told you yet today that you totally ROCK!?

I stared at that for so long trying to see what made it go back....  THANK YOU!

I was looking for something like a return, or a loop back kind of thing. I see now that the code executes once, and then stops and waits at the end, and the next touch starts it over again, but this time the varialbe has been changed so it does the opposite.

 

I tested that out and the light goes on and off as it should, perfectly.  What happens though if I need to add to it - like fullbright isn't enough? I guess what I am asking is, is there any way to define a set of parameters for 'lightoff'? Local lights are making it hard to tell from fullbright alone if it's lit or not. Here's what I tried:

llSetLinkPrimitiveParams( 1, [ PRIM_GLOW, ALL_SIDES, 0.25, PRIM_FULLBRIGHT, ALL_SIDES, lighton ] );

That turned on the glow, but the !lighton can only work with TRUE or FALSE, and glow of course is different.

Next I tried adding into the beginning:

integer lightoff = 0;default {    state_entry() {        offset *= ((1.0 - min) / ns) * (offset * llGetScale());        hi_end_fixed -= 0.5;        llSetLinkPrimitiveParams( 1, [ PRIM_GLOW, ALL_SIDES, 0.25, PRIM_FULLBRIGHT, ALL_SIDES, lighton ] );        llSetLinkPrimitiveParams( 1, [ PRIM_GLOW, ALL_SIDES, 0.00, PRIM_FULLBRIGHT, FALSE, lightoff ] );           }

 When I did that, I didn't get the glow to go off when I tried to use !lightoff, which I thought would change lightoff to 1 and set those parameters.

Is this something I can define in the scope? LIke a set of parameters that tells it

if lighton = 1 then glow = .25

else glow = 0.0

That kinda thing? I guess I didn't take into account the lighting in the area where this is used.  It messes everything up.  :(

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4335 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...