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?
detect crashes
Moderator: POL Developer
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
/scripts/console/shutdownalias.src
A new line to /scripts/start.src
And before every other Shutdown() function call..
I do not use this myself, and thus cannot guarantee that it would work for sure. Anyhow this should give you an idea.
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.
Code: Select all
use uo;
program shutdownalias( )
SetGlobalProperty("CleanShutdown", 1);
Shutdown();
endprogram
Code: Select all
// Inside the program block...
if (GetGlobalProperty("CleanShutdown"))
Print("POL did not crash.");
EraseGlobalProperty("CleanShutdown");
else
Print("POL crashed!");
endif
Code: Select all
SetGlobalProperty("CleanShutdown", 1);
lol, take a look on that:
console.cfg
console output:
every "Console is locked. Press 'u' to unlock." message is an 'w' keypress I am doing.
console.cfg
Code: Select all
Commands
{
CMD w exitpol POL safe exit
CMD u [unlock]
CMD l [lock]
}
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.