Page 1 of 1

detect crashes

Posted: Sun Mar 30, 2008 8:25 am
by phao
how can I detect a crash in start script? to see if the last pol close was made by a crash or by ctrl-C ??

and, saveworldstate() function save every prop in datafiles?

Posted: Sun Mar 30, 2008 8:52 am
by ncrsn
You could save a global property just before calling Shutdown(). Then, in start.src that property is read, and if it returns error (unset property), you know POL crashed. If property exists, you have to erase it.

As far as I know, CTRL+C is reserved command and thus you cannot manipulate its actions. You could however create a script shutdownalias.src into scripts/console/, add a command, say, CTRL+X, and use that instead of hardcoded shutdown.

Scriptwise the whole setting would look like this.

A new line to /config/console.cfg

Code: Select all

CMD ^X shutdownalias Forces shutdown.
/scripts/console/shutdownalias.src

Code: Select all

use uo;

program shutdownalias( )
    
    SetGlobalProperty("CleanShutdown", 1);
    Shutdown();
    
endprogram
A new line to /scripts/start.src

Code: Select all

// Inside the program block...
if (GetGlobalProperty("CleanShutdown"))
    Print("POL did not crash.");
    EraseGlobalProperty("CleanShutdown");
else
    Print("POL crashed!");
endif
And before every other Shutdown() function call..

Code: Select all

SetGlobalProperty("CleanShutdown", 1);
I do not use this myself, and thus cannot guarantee that it would work for sure. Anyhow this should give you an idea.

Posted: Sun Mar 30, 2008 10:11 am
by phao
lol, take a look on that:
console.cfg

Code: Select all

Commands
{
	CMD w exitpol POL safe exit
	CMD u [unlock]
	CMD l [lock]
}
console output:

Code: Select all

Console is locked.  Press 'u' to unlock.
Console is now unlocked.
Console is locked.  Press 'u' to unlock.
Console is now unlocked.
every "Console is locked. Press 'u' to unlock." message is an 'w' keypress I am doing.