SetTimeout function in lua? How to make fadeIn after fadeOut

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
pawelpoz
Posts: 8
Joined: Mon Apr 08, 2013 9:06 pm

SetTimeout function in lua? How to make fadeIn after fadeOut

Post by pawelpoz »

I have a problem with GameMode.fadeIn(color, length) and GameMode.fadeOut(color, length). First I want fadeOut screen, then fadeIn. But code below doesn't work, because both actions runs together (not second after first) :

Code: Select all

function fadeOutAndInEffect()
GameMode.fadeOut(0, 1)
GameMode.fadeIn(0, 1)
end
I want (for example) fade out screen and after 5 second fade in. How to do that? How to run one action after other in lua? Somethink similar to JavaScript SetTimeout?

And... another question - how to use color corectly: GameMode.fadeOut(color, length). I want green color, and 1 second fadeout. I use this code:

Code: Select all

GameMode.fadeOut(0, 255, 0, 1)
... and doesn't work. It makes fadeout to black with 255 second delay :?

Please help :)
Last edited by pawelpoz on Sat Nov 08, 2014 11:46 am, edited 1 time in total.
User avatar
Blichew
Posts: 157
Joined: Thu Sep 27, 2012 12:39 am

Re: SetTimeout function in lua? How to make fadeIn after fad

Post by Blichew »

Move fadeOut into separate function and call that function with delayedCall (entity, time, function). Check modding reference, there's info how to use delayedCall.
pawelpoz
Posts: 8
Joined: Mon Apr 08, 2013 9:06 pm

Re: SetTimeout function in lua? How to make fadeIn after fad

Post by pawelpoz »

Thank you for reply :)

I use scripting reference, but i see only delayedCall(receiver, delay, msg) and nothing else about that :?

http://www.grimrock.net/modding/scripting-reference/
Post Reply