Hi peoples. Just trying to put in a message that says "game loaded" upon the restoration of a saved game, here's my code:
function on_event (EventType event, int data)
{
if(event == eEventRestoreGame) {
Display("Game Loaded.");
}
}
However I'm assuming the code is running before the fade in is complete as the screen remains black until I click the mouse and the game fades in, sans message.
Any idea if I'm doing something wrong or is there a way of getting it to work.
I've tried adding a fadeIn(3) before the display, which shows the room background but again no display message and there is no cursor or GUI until I click the mouse.
A quick hack to do this would be to have a global variable that tells the game was loaded from a save game. Then you could check for that value in the 'Player enters room after fadein' event. There is no global event for this as far as I know, so you should check for it in each room separately in that case.
Global script headerimport LoadedGame;
Global scriptbool LoadedGame = false;
export LoadedGame;
function on_event (EventType event, int data)
{
if (event == eEventRestoreGame)
LoadedGame = true;
}
Each room
function room_AfterFadeIn()
{
if (LoadedGame)
{
LoadedGame = false;
Display("Game Loaded.");
}
}
It is a bit dirty, maybe that someone else can think of something more sophisticated. :)
Thanks. Although it's a solution I'd much rather avoid. I'll wait and see f anyone else has any ideas.
Here's my global solution:
// At the top of the global scripts file
bool restored = false;
// Global on_event
function on_event (EventType event, int data) {
if(event == eEventRestoreGame) {
restored = true;
}
}
// Global repeatedly_execute
function repeatedly_execute() {
if(restored) {
restored = false;
Display("Game Restored.");
}
}
Works a treat!
Granted it's not strictly optimal to have to hook your events this way across multiple functions (in this case only two of course), but yes, that solution seems appropriate. :=
P.S. Does this mean you accept what I said in the beta thread? :P
Quote from: monkey_05_06 on Wed 05/05/2010 00:31:18
P.S. Does this mean you accept what I said in the beta thread? :P
Indeed :)