Jump to content

auto color change?


Nova Waifu
 Share

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

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

Recommended Posts

I'm trying to put a script together that automatically (without touching it) changes a prim's color from orange to blue and then repeats. Sounds real simple, and I thought I figure it out at first but my script did nothing. So I spent 2 hours searching for an example of what I needed and I couldn't find anything that does what I need.

Could anyone help please? :3

Link to comment
Share on other sites

Define a global integer switch:  integer gSwitch;

Start a timer in the state_entry event:   llSetTimerEvent(20.0);

Put your color vectors in a list:  list Colors = [<1,1,0>,<0,0,1>];

Put the list in your timer event, along with two more lines:

     gSwitch = !gSwitch;

     llSetColor(llList2Vector(Colors,gSwitch), ALL_SIDES);

You could actually make it more compact than that, but that's really all there is to it.

 

  • Like 1
Link to comment
Share on other sites

 integer gSwitch;

vector blue = <0.000, 0.455, 0.851>;

vector orange = <1.000, 0.522, 0.106>;

 

default

{

{

 

state_entry()

}

(llSetTimerEvent(8.0);

{

//below are the colors that the script will switch between

list Colors = [<0.000, 0.455, 0.851>,<1.000, 0.522, 0.106>];

gSwitch = !gSwitch;

llSetColor(llList2Vector(Colors,gSwitch), All_SIDES);

}

}

 This is what I have, but I know I'm missing something because I'm getting syntax errors :x

Link to comment
Share on other sites

You're getting closer!

Just glancing at your code, I'm going to guess that opening paren before llSetTimerEvent is causing your syntax error. But you also have a structural error.

llSetTimerEvent(8.0) says "start a timer that rings every eight seconds". Each ring is an "event" that will run whatever code is inside the timer event handler. But you haven't got a timer event handler. Here's what that would look like...

 

timer(){
// put the code that does the color change work here, instead of after llSetTimerEvent
}

 That timer event handler would go right after the state_entry handler, within the default braces.

ETA: You changed your code while I was writing this. I think you've now got excess braces in the default state. They don't harm anything, but they're not needed.

You may find it helpful to indent everything inside each pair of braces, and match the indentation of each brace pair, so that you can see what code is within each event handler or lower level block.

like this...

default{    state_entry()    {
// stuff
} //* end state_entry

timer()
{
// timer stuff
} //* end timer
} //* end default

 The //* comments are things I sometimes use in long sections of code to remind myself and those who follow me just what each closing brace actually closes.

  • Like 2
Link to comment
Share on other sites

OK... A couple of basic rules:

1.   All scopes in a script are bounded by { } brackets, and they have to match.

2.   All events must start with one of the formal event names (state_entry, timer, listen, attach, ...)

Also, not anything bad, but you defined blue and orange as global vectors, but you never used them (mostly because you don't need them).

I think the best step now is to take a half hour to review a starter tutorial.  I think you'll see what's wrong.   :smileywink:

  • Like 1
Link to comment
Share on other sites

    integer gSwitch;    default{    state_entry(){    llSetTimerEvent(8);}    timer()    {        //below are the colors that the script will switch between        list Colors = [        <0.000, 0.455, 0.851>,        <1.000, 0.522, 0.106>];        gSwitch = !gSwitch;        llSetColor(llList2Vector(Colors,gSwitch),All_SIDES);        }    }

 alright, i think i almost have it but i'm getting a "name not definied within scope" right after ALL_SIDES and that's really confusing me because i thought "ALL_SIDES" was telling it to color all sides and i'm not sure why the script is having issues with that

Link to comment
Share on other sites

I've gone through the basic tutorial and even asked a few people within SL and nobody can seem to figure out why this script won't work

 

edit: nevermind, got it working :D for some reason i had to retype ALL_SIDES for it to work and now i have exactly what i wanted

 

thank you!

Link to comment
Share on other sites

Excellent! 

Yoiu had to retype ALL_SIDES because computers are very literal. They follow instructions exactly, but that means you have to give them extremely clear instructions.

All_SIDES is not the same thing as ALL_SIDES.

That specific instruction must be in ALL CAPS.  If it helps, that sort of mistake is extremely common.  As you may have noticed, I am a terrible typist.  I cannot type a sentence without going back and correcting errors, and I have the same problem in writing LSL scripts.  I count on the script editor to catch the mistakes that I don't spot myself, and I know that there will always be some. 

Welcome to the realm of scripting.  :smileywink:

Link to comment
Share on other sites

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