Jump to content

teuclase

Resident
  • Posts

    5
  • Joined

  • Last visited

Reputation

0 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I could do that, yes, but that'd be a different visual effect, I'd have to account for the different faces needing different texture rotations to make it seamless, and I'd need a texture. Furthermore, I made this script for mood lighting; in addition to llSetColor a script I just refined also sets the light color to floats <red, green, blue>.
  2. Huzzah! It has been done. I do realize that some of my if arguments contain colors that are irrelevant for the transition, but I put them in there for the sake of clarity. Any ideas for optimization besides removing said if arguments? /*TRISTAN MAKES ABSOLUTELY HORRID SCRIPT AND PEOPLE MAKE FUN OF HIM FOR IT BY CHANGING THIS NOTE BECAUSE THEY MEANS! */float red = 1.0;float green = 0.0;float blue = 0.0;integer touched = FALSE;float color_increase(float increase){ increase = increase + .01; return increase;}float color_decrease(float decrease){ decrease = decrease - .01; return decrease;}default{ state_entry() { llSetColor(<0, 0, 0>, ALL_SIDES); llSetText("Touch to Start Color Cycle!", <1,1,1>, 1); } touch_start(integer detectednum) { if(touched == FALSE) { touched = TRUE; llSetText(" ", <1,1,1>, 0); llSetColor(<red, green, blue>, ALL_SIDES); } else { touched = FALSE; llSetColor(<0, 0, 0>, ALL_SIDES); llSetText("Touch Again to Restart Color Cycle!", <1,1,1>, 1); } } changed(integer changedint) { if(changedint == CHANGED_COLOR && touched == TRUE) { //Transition RED to RED-BLUE if(red >= 1 && blue <= 1 && green <= 0) { blue = color_increase(blue); } //Transition RED-BLUE to BLUE else if(red >= 0 && blue >= 1 && green <= 0) { red = color_decrease(red); } //Transition BLUE to BLUE-GREEN else if (red <= 0 && blue >= 1 && green <= 1) { green = color_increase(green); } //Transition BLUE-GREEN to GREEN else if (red <= 0 && blue >= 0 && green >= 1) { blue = color_decrease(blue); } //Transition GREEN to GREEN-RED else if (red <= 1 && blue <= 0 && green >= 1) { red = color_increase(red); } //Transition GREEN-RED to RED else if (red >= 1 && blue <= 0 && green >= 0) { green = color_decrease(green); } llSetColor(<red, green, blue>, ALL_SIDES); } }}
  3. Ignore this; I posted a code and soon realized my error.
  4. LindaB Helendale wrote: touch_start() will be triggered when you click the object, but there's no way inside the event to see if the agent is still touching (holding the mouse button down), as all the llDetected* refer to the event when the touch started. You might see touch event (http://wiki.secondlife.com/wiki/Touch), it is triggered as long as the mouse button is held down (meaning as soon as your script event handler returns, there's new touch() event in the queue), so you can use touch() event instead of of the while loop. Hmm... wouldn't that make the color change only happen while you're holding down a click on the object? I'm looking moreso to have the color change triggered or stopped by clicking the object once.
  5. Hello, world! *snickers* I have recently rejoined SL after a bit of a hiatus; I unfortunately had to transfer to a new account as I've lost access to my previous one, and even if I got it restored my inventory would be missing due to it being a TSL account. Anyways, I haven't LSL Scripted- or done any programming/coding/scripting, for that matter- in roughl 3-4 years. I'm trying to get back into it, and I figured LSL would be a great way to as I can immediately compile my codes into a visual result. I've been working on a script, and have reached a bit of difficulty within it. What I'm trying to create is a script where an object is black; upon clicking, it's starts cycling through a rainbow; upon clicking again, it returns to black; and on another click, it resumes its rainbow cycling. My issue is that, within the following code, the color changing can start just fine; however, due to the script being stuck in multiple while loops, it never allows me to touch it again to revert to black. Here's the code: //TRISTAN MAKE PRETTY COLOR CHANGING SCRIPT! YAYYY //HI PERSON READING MY SCRIPT! float red = 0.0; float green = 1.0; float blue = 0.0; integer touched = FALSE; default { state_entry() { llSetColor(<0, 0, 0>, ALL_SIDES); llSetText("Touch to Start Color Cycle!", <1,1,1>, 1); } touch_start(integer detectednum) { if(touched == FALSE) { touched = TRUE; llSetText(" ", <1,1,1>, 0); llSetColor(<red, green, blue>, ALL_SIDES); } else { touched = FALSE; llSetColor(<0, 0, 0>, ALL_SIDES); llSetText("Touch to Start Color Cycle!", <1,1,1>, 1); } while(touched == TRUE) { //Becomes Red while(red < 1) { red = (red + .01); llSetColor(<red, green, blue>, ALL_SIDES); llSleep(0.005); } while(green > 0) { green = (green - .01); llSetColor(<red, green, blue>, ALL_SIDES); llSleep(0.005); } //Becomes Pink while(blue < 1) { blue = (blue + .01); llSetColor(<red, green, blue>, ALL_SIDES); llSleep(0.005); } //Becomes Blue while(red > 0) { red = (red - .01); llSetColor(<red, green, blue>, ALL_SIDES); llSleep(0.005); } //Becomes Teal while(green < 1) { green = (green + .01); llSetColor(<red, green, blue>, ALL_SIDES); llSleep(0.005); } //becomes Green while(blue > 0) { blue = (blue - .01); llSetColor(<red, green, blue>, ALL_SIDES); llSleep(0.005); } //Cycles } } } Now, I know I could use timers and a function to make this script work, but that would require calculation of color changing times; and I'm not doing this for the sake of making a color changing object, but rather for the sake of refreshing my mind on LSL and programming logic in general. What I'm looking for is a way that I could run what's in the while(touched == TRUE) loop, but still be able to use a touch_start to stop the loop at any time, not within a specific window of time. Would you mind sharing any ideas on how I could go about this? Thanks! ~Tristan Euclase
×
×
  • Create New...