Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Linked Message Help

Dragger Lok
(loading ...)
Join date: 10 Sep 2006
Posts: 228
12-04-2009 06:12
Trying (failing) to add a linked message to turn on/off ...

CODE

float MAX_RADIUS = .15;
float RADIUS_INTERVAL = 0.25;
// Modified values
integer IS_ON = FALSE;
float RADIUS = 2;
string TEXTURE = "";
effect() {
llParticleSystem([ PSYS_PART_MAX_AGE, 1.800000,
PSYS_PART_FLAGS, 259,
PSYS_PART_START_COLOR, <0.53000, 0.42000, 1.00000>,
PSYS_PART_END_COLOR, <1.00000, 1.00000, 1.00000>,
PSYS_PART_START_SCALE, <0.045, 0.045, 0.0>,
PSYS_PART_END_SCALE, <0.05, 0.05, 0.0>,
PSYS_SRC_PATTERN, 2,
PSYS_SRC_BURST_RATE,0.051000,
PSYS_SRC_ACCEL,<0.00000, 0.00000, -0.10000>,
PSYS_SRC_BURST_PART_COUNT,6,
PSYS_SRC_BURST_RADIUS,0.200000,
PSYS_SRC_BURST_SPEED_MIN,0.010000,
PSYS_SRC_BURST_SPEED_MAX,0.010000,
PSYS_SRC_INNERANGLE,3.141593,
PSYS_SRC_OUTERANGLE,6.283185,
PSYS_SRC_OMEGA,<0.00000, 0.00000, 1.40000>,
PSYS_SRC_MAX_AGE,0.000000,
PSYS_PART_START_ALPHA,1.,
PSYS_PART_END_ALPHA,1.,
PSYS_SRC_TEXTURE, TEXTURE,
PSYS_SRC_TARGET_KEY,(key)"" ]);
}
stop() {
llParticleSystem([]);
}
default {
state_entry() {
if(IS_ON) {
llSetTimerEvent(RADIUS_INTERVAL);
effect();
} else {
stop();
}
}
touch_start(integer num_detected) {
if(IS_ON) {
llSetTimerEvent(0.0);
stop();
llWhisper(0, "effect has stopped");
} else {
llSetTimerEvent(RADIUS_INTERVAL);
effect();
llWhisper(0, "effect has started");
}
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);
effect();
}
}
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
12-04-2009 06:26
Something like
CODE
 link_message(integer sender, integer num, string str, key id){
if(str=="turn on"){
llSetTimerEvent(RADIUS_INTERVAL);
effect();
IS_ON=TRUE;
}
else if (str =="turn off"){
llSetTimerEvent(0.0);
stop();
IS_ON=FALSE;
}
}
should do it, I think.
Dragger Lok
(loading ...)
Join date: 10 Sep 2006
Posts: 228
Still Escaping Me, Compiles But ...
12-04-2009 06:45
Tried placing the code in a couple of spots- still no go

CODE

float MAX_RADIUS = .15;
float RADIUS_INTERVAL = 0.25;
// Modified values
integer IS_ON = FALSE;
float RADIUS = 2;
string TEXTURE = "";
effect() {
llParticleSystem([ PSYS_PART_MAX_AGE, 1.800000,
PSYS_PART_FLAGS, 259,
PSYS_PART_START_COLOR, <0.53000, 0.42000, 1.00000>,
PSYS_PART_END_COLOR, <1.00000, 1.00000, 1.00000>,
PSYS_PART_START_SCALE, <0.045, 0.045, 0.0>,
PSYS_PART_END_SCALE, <0.05, 0.05, 0.0>,
PSYS_SRC_PATTERN, 2,
PSYS_SRC_BURST_RATE,0.051000,
PSYS_SRC_ACCEL,<0.00000, 0.00000, -0.10000>,
PSYS_SRC_BURST_PART_COUNT,6,
PSYS_SRC_BURST_RADIUS,0.200000,
PSYS_SRC_BURST_SPEED_MIN,0.010000,
PSYS_SRC_BURST_SPEED_MAX,0.010000,
PSYS_SRC_INNERANGLE,3.141593,
PSYS_SRC_OUTERANGLE,6.283185,
PSYS_SRC_OMEGA,<0.00000, 0.00000, 1.40000>,
PSYS_SRC_MAX_AGE,0.000000,
PSYS_PART_START_ALPHA,1.,
PSYS_PART_END_ALPHA,1.,
PSYS_SRC_TEXTURE, TEXTURE,
PSYS_SRC_TARGET_KEY,(key)"" ]);
}
stop() {
llParticleSystem([]);
}
default {
//state_entry() {
//if(IS_ON) {
//llSetTimerEvent(RADIUS_INTERVAL);
//effect();
//} else {
//stop();
//}
//}
link_message(integer sender, integer num, string str, key id){
if(str=="turn on"){
llSetTimerEvent(RADIUS_INTERVAL);
effect();
IS_ON=TRUE;
}
else if (str =="turn off"){
llSetTimerEvent(0.0);
stop();
IS_ON=FALSE;
}
}
timer() {
integer max_inventory = llGetInventoryNumber(INVENTORY_TEXTURE);
if(max_inventory > 0) {
TEXTURE = llGetInventoryName(INVENTORY_TEXTURE, (integer)llFrand(max_inventory));
}
RADIUS = llFrand(MAX_RADIUS);
effect();
}
}


CODE

float MAX_RADIUS = .15;
float RADIUS_INTERVAL = 0.25;
// Modified values
integer IS_ON = FALSE;
float RADIUS = 2;
string TEXTURE = "";
effect() {
llParticleSystem([ PSYS_PART_MAX_AGE, 1.800000,
PSYS_PART_FLAGS, 259,
PSYS_PART_START_COLOR, <0.53000, 0.42000, 1.00000>,
PSYS_PART_END_COLOR, <1.00000, 1.00000, 1.00000>,
PSYS_PART_START_SCALE, <0.045, 0.045, 0.0>,
PSYS_PART_END_SCALE, <0.05, 0.05, 0.0>,
PSYS_SRC_PATTERN, 2,
PSYS_SRC_BURST_RATE,0.051000,
PSYS_SRC_ACCEL,<0.00000, 0.00000, -0.10000>,
PSYS_SRC_BURST_PART_COUNT,6,
PSYS_SRC_BURST_RADIUS,0.200000,
PSYS_SRC_BURST_SPEED_MIN,0.010000,
PSYS_SRC_BURST_SPEED_MAX,0.010000,
PSYS_SRC_INNERANGLE,3.141593,
PSYS_SRC_OUTERANGLE,6.283185,
PSYS_SRC_OMEGA,<0.00000, 0.00000, 1.40000>,
PSYS_SRC_MAX_AGE,0.000000,
PSYS_PART_START_ALPHA,1.,
PSYS_PART_END_ALPHA,1.,
PSYS_SRC_TEXTURE, TEXTURE,
PSYS_SRC_TARGET_KEY,(key)"" ]);
}
stop() {
llParticleSystem([]);
}
default {
state_entry() {
if(IS_ON) {
llSetTimerEvent(RADIUS_INTERVAL);
effect();
} else {
stop();
}
}
link_message(integer sender, integer num, string str, key id){
if(str=="turn on"){
llSetTimerEvent(RADIUS_INTERVAL);
effect();
IS_ON=TRUE;
}
else if (str =="turn off"){
llSetTimerEvent(0.0);
stop();
IS_ON=FALSE;
}
}
timer() {
integer max_inventory = llGetInventoryNumber(INVENTORY_TEXTURE);
if(max_inventory > 0) {
TEXTURE = llGetInventoryName(INVENTORY_TEXTURE, (integer)llFrand(max_inventory));
}
RADIUS = llFrand(MAX_RADIUS);
effect();
}
}
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
12-04-2009 07:21
You're updating particles every 0.25 seconds? :(

/me pokes at the script and comes up with the stuff below. You'll still need another script to actually send the link message, though.

CODE

float MAX_RADIUS = .15;
float RADIUS_INTERVAL = 0.25;
// Modified values
integer IS_ON = FALSE;
float RADIUS = 2;
string TEXTURE = "";
integer COUNT = 0;

effect()
{
llParticleSystem([ PSYS_PART_MAX_AGE, 1.800000,
PSYS_PART_FLAGS, 259,
PSYS_PART_START_COLOR, <0.53000, 0.42000, 1.00000>,
PSYS_PART_END_COLOR, <1.00000, 1.00000, 1.00000>,
PSYS_PART_START_SCALE, <0.045, 0.045, 0.0>,
PSYS_PART_END_SCALE, <0.05, 0.05, 0.0>,
PSYS_SRC_PATTERN, 2,
PSYS_SRC_BURST_RATE,0.051000,
PSYS_SRC_ACCEL,<0.00000, 0.00000, -0.10000>,
PSYS_SRC_BURST_PART_COUNT,6,
PSYS_SRC_BURST_RADIUS,0.200000,
PSYS_SRC_BURST_SPEED_MIN,0.010000,
PSYS_SRC_BURST_SPEED_MAX,0.010000,
PSYS_SRC_INNERANGLE,3.141593,
PSYS_SRC_OUTERANGLE,6.283185,
PSYS_SRC_OMEGA,<0.00000, 0.00000, 1.40000>,
PSYS_SRC_MAX_AGE,0.000000,
PSYS_PART_START_ALPHA, 1.0,
PSYS_PART_END_ALPHA,1.0,
PSYS_SRC_TEXTURE, TEXTURE,
PSYS_SRC_TARGET_KEY,(key)"" ]);
}

stop()
{
IS_ON = FALSE;
llSetTimerEvent (0.0);
llParticleSystem([]);
}

start()
{
IS_ON = TRUE;
effect();
llSetTimerEvent (RADIUS_INTERVAL);
}

default
{
state_entry()
{
COUNT = llGetInventoryNumber(INVENTORY_TEXTURE);

if(IS_ON)
{
start();
}
else
{
stop();
}
}

on_rez (integer param)
{
llResetScript();
}

changed (integer mask)
{
if (mask & CHANGED_INVENTORY)
{
COUNT = llGetInventoryNumber(INVENTORY_TEXTURE);
}
}

touch_start(integer num_detected)
{
IS_ON = !IS_ON;

if(!IS_ON)
{
stop();
llWhisper(0, "effect has stopped");
}
else
{
start();
llWhisper(0, "effect has started");
}
}

link_message(integer sender_number, integer number, string message, key id)
{
if (message == "on")
{
start();
}
else if (message == "off")
{
stop();
}
else
{
llOwnerSay ("wha?");
}
}

timer()
{
if(COUNT > 0)
{
TEXTURE = llGetInventoryName(INVENTORY_TEXTURE, (integer)llFrand(COUNT));

RADIUS = llFrand(MAX_RADIUS);
effect();
}
else
{
stop();
}
}
}
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Dragger Lok
(loading ...)
Join date: 10 Sep 2006
Posts: 228
Woot!
12-04-2009 07:47
Innula, both scripts worked well!! I had a bit of an issue in the link i was sending "oops". I did comment out a bunch of the original script "//integer IS_ON = FALSE;" and everything it pertained to but not sure if it mattered once i found the issue with the link i was sending "woo hoo :)"

Meade, thanks so much, the script you posted worked also but for a brief time, not sure where it is tripping but i'm so much better off than i was this morning :)
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
12-04-2009 08:01
From: Dragger Lok
Meade, thanks so much, the script you posted worked also but for a brief time, not sure where it is tripping but i'm so much better off than i was this morning :)

Really? Hrm..

/me fires it up on her opensim box here at work and checks it out. Seems to work ok.. Dunno why it would have stopped for you.

The big difference that you should take from my script is what I did in the changed & timer events. If you're really determined to use a fast timer like that, you shouldn't also be counting the number of textures every time - the changed even will tell you when the object inventory changes and you can just cache that instead. It's a lot friendly on the sim.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left