Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

very noobie here

Alberto McGettigan
Registered User
Join date: 14 Jun 2005
Posts: 57
07-07-2005 03:46
trying hard to grasp the language just starting out haveing a hard time figuring out how to get a cube to blink random colors on random sides till someone says off

i can get it to do it but it only listens once and dosent again and it stays in the loop blinkin non stop get syntax if i put the listen in the loop dont get it.
Hawk Mendicant
www.hawkuk.com
Join date: 6 Jun 2005
Posts: 30
07-07-2005 04:19
I'm quite new to SL too but I think I can see the problem here. I'm sure someone more experienced will correct me if i'm wrong...

You've put your random colour blinking code in a loop. LSL will wait until your loop has finished processing before it will process the next incoming event. This means the stop message will never be read and it just keeps blinking forever.

One way to get this to work would be to put your code to change colour in a timer() event and when you recieve your on/off messages you can turn the timer on using llSetTimerEvent(interval) and turn it off using llSetTimerEvent(0). You can read more about the timer event here: http://secondlife.com/badgeo/wakka.php?wakka=llSetTimerEvent

I hope i've been able to help,
Hawk
Argus Stravinsky
Dog of the Hero
Join date: 22 Nov 2004
Posts: 2,027
07-07-2005 04:32
that's good! alternatively, what i did was use

integer z = 1;
if( z == 1)
{
llSetColor(whatever) ;
z = 2;
}
else if ( z == 2)
{
llSetColor( different one from whatever);
z = 3;
}

and then it has a listen function where if you say off it changes z to 5 or w/e (a number that doesn't do anything for changing colors) and if you say on it changes z to 1 (the starting number)


it might not be as good as others, but it's simple, and it works!
Synergy Belvedere
Prim Reaper
Join date: 7 Jul 2004
Posts: 253
07-07-2005 09:00
CODE

float tmr = 1.0;
default
{
state_entry()
{
llListen(1,"",NULL_KEY,"");
llSetTimerEvent(tmr);
}
listen(integer chan, string name, key id, string msg)
{
if(msg=="on")
{
llSetTimerEvent(tmr);
}
if(msg=="off")
{
llSetTimerEvent(0);
}
}
timer()
{
integer i;
for(i=0;i<=5;i++)
{
llSetColor(<llFrand(1),llFrand(1),llFrand(1)>,i);
}
}


Writing this from work so not sure if it compiles but it looks ok from here and should do what you ask. Use /1 on to turn on and /1 off to turn off.
_____________________
----------------------------------------------------------
--The mind's eye is limited only by its focus--
Synergy Belvedere
Prim Reaper
Join date: 7 Jul 2004
Posts: 253
07-07-2005 09:07
BTW the above should work on a cube, which has 6 sides. Not sure about other shapes.
_____________________
----------------------------------------------------------
--The mind's eye is limited only by its focus--
Alberto McGettigan
Registered User
Join date: 14 Jun 2005
Posts: 57
thanks
07-07-2005 10:50
Thank You alll for your help
last programming i did was on old pet comp. with BASIC language in the late 70's early80's.
Still trying to get my head around no numbered lines:) . And im not kikking heheheh


Thanks again.
Vortex Saito
Quintzee Creator
Join date: 10 Sep 2004
Posts: 73
07-07-2005 11:06
CODE

timer()
{
integer i;
for(i=0;i<=5;i++)
{
llSetColor(<llFrand(1),llFrand(1),llFrand(1)>,i);
}


Why use a loop when you can use the ALL_SIDES

So it would be :

CODE

timer()
{
llSetColor(<llFrand(1),llFrand(1),llFrand(1)>,ALL_SIDES);
}
_____________________
I don't care I am a lemming, I am NOT going !!!!

secondlife://puea/54/15
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
07-07-2005 11:15
because then the cube would be the same color on each side.
Velox Severine
Network Slave
Join date: 19 May 2005
Posts: 73
07-07-2005 14:34
As he said, he was trying to change the color of each side, which was the purpose for the for loop in the first place, otherwise you could simply drop the loop.
Vortex Saito
Quintzee Creator
Join date: 10 Sep 2004
Posts: 73
07-07-2005 14:46
Oops my bad, misread it
_____________________
I don't care I am a lemming, I am NOT going !!!!

secondlife://puea/54/15
Alberto McGettigan
Registered User
Join date: 14 Jun 2005
Posts: 57
still nothing
07-07-2005 16:51
Think im gonna have to buy my scripts.
coppied the one you gave me Synergy but it still wont listen more than the one time.

dont know what is wrong
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
07-07-2005 17:28
From: Alberto McGettigan
Think im gonna have to buy my scripts.
coppied the one you gave me Synergy but it still wont listen more than the one time.
CODE
float tmr = 1.0;
default
{
state_entry()
{
llListen(1,"",NULL_KEY,"");
llSetTimerEvent(tmr);
}

listen(integer chan, string name, key id, string msg)
{
if (msg == "on")
{
llSetTimerEvent(tmr);
}
else if (msg == "off")
{
llSetTimerEvent(0);
}
}

timer()
{
integer i;
for(i = 0; i <= 5; i++)
{
llSetColor(<llFrand(1),llFrand(1),llFrand(1)>,i);
}
}
}
This should work correctly... you're sure you're saying the commands "/1 on" and "/1 off" to toggle it on and off respectively?
_____________________
Need scripting help? Visit the LSL Wiki!
Omega Point - Catherine Omega's Blog