My team is trying to create a graphical overlay that will start off at a percentage of transparency and then get more solid (less transparent) as your heat level increases. I used the code in the Dynamic help as a starting point. The problem I'm having is I'm unsure where to place the code. I either get the overlay to show up and infinitely run, or it shows up one time and so fast that you don't ever see it. I want this to happen on any level throughout the game. I've tried to place it in the function repeatedly_execute() and the function repeatedly_execute_always() . Please help. Also, if you know how to set the transparency of the overlays, that would be excellent info.
function OL()
{
if (heatIndex >= 3)
{
Overlay* Boom = Overlay.CreateGraphical(100, 100, 71, true);
Wait(40);
Boom.Remove();
}
}
It will need to be in repeatedly_execute as blocking functions such as Wait() can't go in rep_exec_always(). In any case, you'll probably be better off creating a timer to specify the duration (checking to see if the timer is expired will also go in repeatedly_execute) - just remember to declare the overlay variable outside the function or it will disappear when it goes out-of-scope (the function concludes processing). If you do use a timer rather than Wait, you should be able to use repeatedly_execute_always(), but it will run when the game is blocked with other scripts, which may not be what you intend.
I believe you change the transparency of graphical arrays by modifying the transparency of the image itself - you've enabled transparency so it should work. You will probably need to remove and re-instate the array with the changed graphic.
We'd want it to stay indefinitely unless the heat goes back down. We've recently decided to try to do it through a gui we're making for a particle overlay. So as you heat up, the room will appear to start smoking. But if someone can figure it out to show that isn't on a timer, that would be great.
If it's staying on indefinitely then just make sure you are declaring the Overlay variable in a global scope (so it doesn't disappear when it goes out of scope) and only Remove it when the variable goes below that (checked through repeatedly_execute).
Overlay* Boom;
function repeatedly_execute() {
if (heatIndex >= 3) {
if (!Boom.Valid) Boom = Overlay.CreateGraphical(100,100,71,true);
}
else {
if (Boom.Valid) Boom.Remove();
}
}