PostUndoObject: ModuleExecObject | [Previous] [Main] [Next]

PostUndoObject - every instance of this class is notified, via its execute() method, immediately after we perform an 'undo' command.
You can probably guess how our manic player-hating author might put this to evil use:
PostUndoObject
execute()
{
"If there's one thing I hate more than players feeble enough to save and restore,
it's idiots who ruin the amazing gaming experience I've devised for them by
resorting to UNDO. The penalty of <i>fifty</i> thousand points you're about to
suffer is thus richly deserved.\b
By the way, this makes the game unwinnable - but hey, only lousy LOSERS like
you use UNDO.<.p>";
addToScore(-50000, 'using undo');
}
;
Hopefully if you do find yourself using a PostUndoObject it will be for a more legitimate purpose than this, though it's probably not something you'll need to use very often, if at all. A more legitimate use might be if, for some research purpose, you wanted to keep track of how often players used UNDO during a session with your game, then you might do something like this:
transient statisticsObj: object
undoCount = 0
saveCount = 0
restoreCount = 0
;
PostUndoObject
execute()
{
statisticsObj.undoCount += 1;
}
;
Because statisticsObj has been declared as transient (for fuller details of which see the Object Definitions section of the language documentation) its properties will be preserved across operations such as UNDO, RESTART, SAVE and RESTORE, and this should work (although since a transient object is thus not itself saved or restored, its properties cannot be preserved across different game sessions, hence the seemingly odd name 'transient' for this type of object).