--- SOLVED ---
It's working now, thanks for the suggestions, they really helped me to find a way to do this...
// script for room: Repeatedly execute
if (IsTimerExpired(1) == 1) {
if (GetGlobalInt(150)==0) {
SetTimer(1,Random(20));
SetBackgroundFrame(1);
SetAreaLightLevel(2,0);
SetGlobalInt(150,1); }
else {
SetTimer(1,Random(30));
SetBackgroundFrame(0);
SetAreaLightLevel(2,-98);
SetGlobalInt(150,0); }
}
--- SOLVED ---
Hi,
I'm making a room with broken lights, so that the lights flash randomly all the time. I tried with animated background, but it can only be 5 frames and the character doesn't go dark, so this amateurish experiment didn't work for this problem... So what would be the best way to try to do this kind of things?
I don't know the exact function names, cause I don't have the files with me.
But this could be done, using the Random(int) function.
First of all, you would need to put all of the possible lighting frames, into an animated background.
Then, you would use a code, looking something like this:
//The room's Repeatedly execute
if (IsTimerExpired(1) == 1){
SetTimer(1,Random(80));
frame = Random(4) //however many frames you have - 1
}
if(frame == 0) SetBackgroundFrame(1);
if(frame == 1) SetBackgroundFrame(2);
if(frame == 2) SetBackgroundFrame(3);
if(frame == 3) SetBackgroundFrame(4);
if(frame == 4) SetBackgroundFrame(5);
That will probably have to be modified, for timing etc. cause I dodn't have everything with me. Its normally 40 frames per second as far as I know. So that should change the frame every, up to 2 seconds. Also, its assuming you have five different frames, but it shouldn't be too hard to get to work. Sorry if it doesn't though.
If you need more frames, you should try using objects for the animation, rather than background frames.
To make the character go dark, use SetRegionTint, or maybe TintScreen.
Sorry for bringing the thread up again, especially seeing this is almost unrelated, but I didn't think it was worth making a new topic for - what's the difference between SetAmbientTint and TintScreen? Has TintScreen become obsolete due to SetAmbientTint? Or is there an advantage to TintScreen which SetAmbientTint doesn't have?
AFAIK, SetAmbientTint only tints objects and characters.
TintScreen tints the whole screen, including the background.
Exactly. That's why TintScreen is noticeably slower.
i think your other option would be to make the lights as partly transparent objects and then use individual timers for each one, which would allow you to control the frequency they each blinked at