Jump to content

I need to have two separated objects blink at the same time


VeranniCakes
 Share

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

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

Recommended Posts

The PRIM_COLOR parameter needs to be followed by three other values before you can go on to PRIM_GLOW. Those three are:

  • (integer) face -- you probably want ALL_SIDES
  • (vector) color -- this is where you'd use Molly's color variable
  • (float) alpha -- you probably want 1.0

--------------------

Of possible future interest to the OP, although it's a bit outside the scope of the question: There's a way to meet most of these requirements using texture animation, without needing to keep a script in the object at all once the flashing is working as desired.

There are, however, some limitations to the texture animation approach:

  • First, perhaps most obviously, without a script there'd be no way for a user to choose among different patterns of flashing: it's just going to keep flashing as it was when the script was present to set the texture animation,
  • There's no way to extend the flashing to include PRIM_POINT_LIGHT, and
  • Glow will either be on or off the whole time, unaffected by the texture animation.

One other possible limitation: if the flashing surface is supposed to include transparency, there's no way to emulate PRIM_FULLBRIGHT; on the other hand, if the surface is opaque, you can get as much fullbright as you want (even a spatial pattern of fullbright-ness) using "emissive" alpha mode and manipulating the alpha channel to affect just how emissive the surface should appear.

  • Like 1
Link to comment
Share on other sites

look at the order of the lines in your video script.  Think about it logically. Scripting is about logic

logically we first pick a color then we set PRIM_COLOR to the color we pick

at the moment, your code picks the color after it sets the prim. So change the order of the lines of code

Edited by Mollymews
video
  • Like 2
Link to comment
Share on other sites

  • 9 months later...

Novice wannabe scripter here - fascinating and informative thread that's been incredibly helpful - and seems to be the only one that remotely addresses what I'm looking for - but now I've come against a wall and can't figure out the solution. :(

Developing OP's original query further, I want to illuminate each prim in a linkset sequentially eg individual letters in a sign, in order, then repeat. I thought I could use Rolig's suggestion for illuminating 2 prims alternately, but I couldn't work out a way to extend it beyond the second prim. Instead, I used a variation of the script in each prim, using llsleep to insert a pause before illuminating each subsequent prim.

It works, but I'm sure there's a more elegant way to do it, without the need for all those scripts! Also, it seems you only have to breathe on it for the sequence to go wonky and require a reset.

Can anyone point me in the right direction, before my brain completely melts?

Thanks, in anticipation.

Link to comment
Share on other sites

Create a single script in the root prim

You will need a global integer for how many prims are in the linkset, call this numPrims , also have a global integer called counter , and a global integer called onOff.

Initialise counter to 2, onOff to 0; then numPrims = llGetNumberOfPrims(); set the timer interval to what you want, 1 second might be a good starting point. Then wait for the timer to happen

Inside the timer() event you first test onOff.

If it is 0 you are about to turn on a prim. check the value of counter and if it is greater than numPrims set it to 2; Turn on the child prim using llSetLinkPrimitiveParamsFast(counter, [PRIM_FULL_BRIGHT, ALL_SIDES, 1]); set OnOff to 1;

else (onOff was 1 so there's already a prim glowing) turn off the child using  llSetLinkPrimitiveParamsFast(counter, [PRIM_FULL_BRIGHT, ALL_SIDES, 0]); set OnOff to 0; increment the counter so that next time it will be tested and either reset to 2 or else the next child in sequence will be set bright.

And that's it, the timer event chugs away working through the children as counter gets incremented from 2 to numPrims every second time.

It is a 50% duty cycle. If you wanted to change this so the child glowed for longer., then inside the timer loop you would reset the timer interval to either a long value after turning the child on, or a shorter value after turning it off.

 

Don't be afraid to copy code snippets you find in the wiki and chop them around a bit. You need to look in particular at the timer event (how to set it up) and setting primitive params, especially PRIM_FULLBRIGHT or PRIM_GLOW.

Also you need to be aware of the link numbering in a linkset. The root prim is number 1, the child prims are then 2,3,4,5... so if there are five prims in a linkset the number of prims returned by the function call will be 5, and therefore the children go from 2 to 5. This can catch people out as they are used to things starting from 0 instead of 1 and ending at 1 less than the total number of notecards, textures etc that the function call returned.

 

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

It's often better to do blinky stuff using texture animation. Especially if you have lots of stuff to turn on and off. Texture animation is done entirely in the viewer, once started, so it's much less overhead sim side. Frantically turning lights on and off from scripts burns script time and causes a message from the server to the viewer for every on-off action.

Link to comment
Share on other sites

8 hours ago, animats said:

It's often better to do blinky stuff using texture animation.

Indeed, but it's not easy to control several child prims. In this instance I toyed with suggesting a texture divided into two parts, one brighter than the other half, and switching it instead of using fullbright. However, given that the poster was expressing an interest in working through the children in a linkset, I followed that path.

In a sculpty hotel sign I made for somebody that is a single prim but has 12 letters in two vertical columns, the only way to make it flicker through different shades of colour like a faulty neon was to make up a texture consisting of several shades of the blue and then play with the texture offsets via a script, but this was relying on the way textures get applied to the faces of sculpties made using the inworld tools.

Link to comment
Share on other sites

On 7/15/2020 at 3:23 AM, Profaitchikenz Haiku said:

the only way to make it flicker through different shades of colour like a faulty neon was to make up a texture consisting of several shades of the blue and then play with the texture offsets via a script

If it were up to me, I'd use emissive alpha mode to get the flickering effect, together with a texture that varies the alpha channel rather than "shade" of RGB luminance. This behaves as if toggling fullbright, so it looks correct regardless of lighting conditions. The downside is that it's only visible in viewers with Advanced Lighting Model enabled (but IMHO it's high time that be enabled by default in all viewers, only disabled through an obscure debug setting).

Assuming an appropriate UV map on a uniform surface, the effect comes from SMOOTH animating a texture that only varies that alpha channel, corresponding to the blinking effect. Note that the same texture cannot code both transparency and emissive alpha on the same surface.

It's also possible to animate the same or similar texture to mask a projected light, making it blink, too. This is tricky to set up, but means surrounding stuff can be lit from a flickering light source. (I think ALM is needed even for projected lights, so... I mean, may as well wear a blindfold as run without ALM.)

  • Like 1
Link to comment
Share on other sites

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