|
Andryn Vaher
Registered User
Join date: 14 Sep 2008
Posts: 2
|
12-29-2008 13:29
I'm working on a chemistry model that contains multiple prims linked together that when touched the prims will begin emitting particles that represent the path of molecules. However the problem I'm having is that the individual prims only turn on and off when I click them individually. I'm looking for some way to get it where I can turn all of the emitters on and off with one click. I've done some searching and I'm pretty sure that I need to use something like Link Message but I'm relatively new at scripting so I'm not sure how to do that. I've looked at some example scripts but none of them are really what I'm looking for.
Here are some parameters I'm looking for in the script.
-multiple linked prims containing emitters will turn on and off simultaneously -the prims will turn on and off when touched by an avatar -the avatar will be able to touch a prim attached to but is not directly one of the emitters that will activate the script
-I'm also looking at having a text box containing information pop up when the avatar clicks but not critical at this point
If anyone has any suggestions or possible example scripts that would be great!
Thanks!
|
|
Aztral Aeon
Registered User
Join date: 22 Dec 2007
Posts: 34
|
12-29-2008 13:51
From: Andryn Vaher I'm working on a chemistry model that contains multiple prims linked together that when touched the prims will begin emitting particles that represent the path of molecules. However the problem I'm having is that the individual prims only turn on and off when I click them individually. I'm looking for some way to get it where I can turn all of the emitters on and off with one click. I've done some searching and I'm pretty sure that I need to use something like Link Message but I'm relatively new at scripting so I'm not sure how to do that. I've looked at some example scripts but none of them are really what I'm looking for.
Here are some parameters I'm looking for in the script.
-multiple linked prims containing emitters will turn on and off simultaneously -the prims will turn on and off when touched by an avatar -the avatar will be able to touch a prim attached to but is not directly one of the emitters that will activate the script
-I'm also looking at having a text box containing information pop up when the avatar clicks but not critical at this point
If anyone has any suggestions or possible example scripts that would be great!
Thanks! Try something like this... In the parent prim script: touch_start(integer total_number) { if( g_bParticlesOn == 1 ) { g_bParticlesOn = 0; llMessageLinked(LINK_ALL_CHILDREN, 0, "", NULL_KEY); } else { g_bParticlesOn = 1; llMessageLinked(LINK_ALL_CHILDREN, 1, "", NULL_KEY); } } In each of your particle emitter prims: link_message(integer sender_number, integer bParticlesOn, string message, key id) { if (bParticlesOn== 1) ShowParticles(); else HideParticles(); } Something like that 
|
|
Yingzi Xue
Registered User
Join date: 11 Jun 2008
Posts: 144
|
12-29-2008 13:54
Here's my example of how to do it. Note that linked messages can be dropped on occasion. If you want to ensure messages are always received then you should set the messenger script to listen for linked messages as well and have the listener scripts send a reply to let the messenger script know the message was received. As for dialog menus, they would be easy to add. You can find everything you need on the wiki's and on this forum if you search. Root prim script (messenger) integer toggle; // keep track of on/off status
defaults() { toggle = FALSE; // off }
particles_on() { // particle code here }
default { state_entry() { defaults(); // set script variables }
touch_start(integer total_number) { if (toggle == FALSE) { toggle = TRUE; // on particles_on(); // tell other prims to turn on using integer value of 1 llMessageLinked(LINK_ALL_OTHERS,1,"",""); // send integer value of 1 which means on } else if (toggle == TRUE) { toggle = FALSE; // off llParticleSystem([]); // turn particles off llMessageLinked(LINK_ALL_OTHERS,0,"",""); // send integer value of 0 which means off } } }
Linked prim script (listener) particles_on() { // particle code here }
default { link_message(integer sender_num, integer num, string str, key id) { if (num == 1) { llOwnerSay("On message received for link "+(string)llGetLinkNumber()+"."); particles_on(); } else if (num == 0) { llOwnerSay("Off message received for link "+(string)llGetLinkNumber()+"."); llParticleSystem([]); } } }
|