OddbroShillings Posted August 16, 2011 Share Posted August 16, 2011 Hello, Im back again with another question. (as you see Im not good of a scipter,but Hey! Im learning) Anyways, I have this script. I would like to to be able to be actiavted only if I say a certain thing on a certaion channel and go back to default state when I deactivate it: Example: Default state:(lights are off) Red,Red,Red,White,White,Red,Red,RedWhen I say: /911 Lights on: I want this script to become active.When I say: /911 lights off: I want the script to shut off, and the object go back to the default state. If anyone can help me it would be greatly appreciated as always. vector COLOR_1 = <1.0,0.0,0.0>; // Color 1 as RGB vector COLOR_2 = <255.0,255.0,255.0>; // COLOR 2 as RGB integer USE_COLOR_1; default { state_entry() { USE_COLOR_1 = FALSE; llSetTimerEvent( 0.2); } timer() { if (USE_COLOR_1) llSetColor( COLOR_1, ALL_SIDES ); else llSetColor( COLOR_2, ALL_SIDES ); USE_COLOR_1 = !USE_COLOR_1; } } Link to comment Share on other sites More sharing options...
Clarke Kondor Posted August 16, 2011 Share Posted August 16, 2011 The script below will stop and start the blinking. It listens for the Owner on channel 911 - Clarke vector COLOR_1 = <1.0,0.0,0.0>; // Color 1 as RGBvector COLOR_2 = <255.0,255.0,255.0>; // COLOR 2 as RGBinteger USE_COLOR_1;default { state_entry() { USE_COLOR_1 = FALSE; llListen(911,"",llGetOwner(),""); llSetTimerEvent( 0.2); } listen(integer channel, string name, key id, string message){ message == llToLower(message) if(message == "lights on") llSetTimerEvent(0.2); else if (message == "lights off")llSetTimerEvent(0.0); } timer() { if (USE_COLOR_1) llSetColor( COLOR_1, ALL_SIDES ); else llSetColor( COLOR_2, ALL_SIDES ); USE_COLOR_1 = !USE_COLOR_1; }} Link to comment Share on other sites More sharing options...
OddbroShillings Posted August 16, 2011 Author Share Posted August 16, 2011 There was a syntax error listen(integer channel, string name, key id, string message){ message == llToLower(message) if(message == "lights on") llSetTimerEvent(0.2); else if (message == "lights off")llSetTimerEvent(0.0); where it says message == llToLower......... this is where the error message was. Any idea on why? Thank you for the help btw. Link to comment Share on other sites More sharing options...
Rolig Loon Posted August 16, 2011 Share Posted August 16, 2011 Or, more compactly.... integer USE_COLOR;default{ state_entry() { llListen(911,"",llGetOwner(),""); } listen (integer channel, string name, key id, string msg) { integer Light; if (llToLower(msg) == "lights on") { Light = TRUE; } if (llToLower(msg) == "lights off") { Light = FALSE; } llSetTimerEvent(0.2 * Light); } timer() { llSetColor(<1.0,1.0,1.0> * (USE_COLOR = !USE_COLOR), ALL_SIDES); }} I'm assuming that you want to blink from black to white, although your script just switches from white to white (<1.0,1.0,1.0> is the same thing as <255.0,255.0,255.0>). Since that's the case, you only need to put <1.0,1.0,1.0> in the llSetColor command and then multiply it alternately by 1 or 0. BTW, it's smart to get in the habit of always using curly brackets {} to mark the start and end of a scope, even if you can sometimes get away without them. Sooner or later, you'll forget them when you really DO need them, and you will waste a lot of time cursing. Link to comment Share on other sites More sharing options...
OddbroShillings Posted August 16, 2011 Author Share Posted August 16, 2011 Good, script, but is doesnt go back to the default state, it onlys shuts off and stays on whatever color i said it on. Looking back at my DESC, I think I need to make an edit. Lets say the default object is Red. When I Say /911 lights on: It should start flashing between white and red. When I say /911 lights off: It should stop and only stopn back on red(or the default state. Link to comment Share on other sites More sharing options...
Rolig Loon Posted August 16, 2011 Share Posted August 16, 2011 It's doing that because colors in LSL range from 0.0 to 1.0, not 0.0 to 255.0. That's why I wrote that note in my post. If you want the light to blink from white to red, using the method I put in my script, you can do it with llSetColor((vector)llList2String(["<1.0,0.0,0.0>","<1.0,1.0,1.0>"],(USE_COLOR = !USE_COLOR)),ALL_SIDES); in the timer event. Incidentally, a matter of terminology, your entire script is in the default state. It is a one-state script with three events. Link to comment Share on other sites More sharing options...
OddbroShillings Posted August 16, 2011 Author Share Posted August 16, 2011 I now see what you mean, it works, and thank you for both your help and help in making be a better scripter Link to comment Share on other sites More sharing options...
Recommended Posts
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