Documentation for readsavedevents.py

Warning: This documentation was generated from the comments in the source code (using progrutils.documentPyFile()), with a few tweaks, under the principle that poor documentation is better than no documentation. In case of ambiguity, please refer to the code itself.

 

Read Saved Events

By Stumpy

 

Read through a Freedom Force saved game file and return a list of all the event sinks in the game engine. Potentially useful for debugging and optimization. Note that this can be run in-game or in a separate python command window. WHen run in-game, it may be useful to combine with the datfiles filename-guessing utility functions, like GetMostRecentSavedGameFile(). I have not optimized this code at all; it is not intended for real-time use.

Example: (in-game)
from datfiles import *
from readsavedevents import *
events = ReadSavedEvents(GetMostRecentSavedGameFile(),verbose=1)

ReadSavedEvents(filename, verbose=0)

Grab the event sinks stored in the saved game file filename. These are returned as a list of events, with each event as a tuple containing the event type, callback function, event.string, event.object, event.userdata, event.float, and event.persist. Call with verbose==1 to get a crude printout.

ShowEventList(elist)

print out the event list in a somewhat readable form

GetEventTypes(EventList,EventType)

FindDuplicates(list,ignorePersist=1)

Given a list, return a the items in the list that are duplicated. What is returned is a dictionary with the duplicated list items as keys and the number of occurances of that item in the original list as the values.

NB: The obvious assumption here is that the items in the list are suitable as dictionary mapping keys. That includes most, but not all, objects. If ignorePersist==1 (the default), then if the items in the list are sequence types, the last item in each sequence is ignored (which is the persist field - often filled with semi-arbitary values by the engine).

FindGroups(list,ignorePersist=1)

Look at the SE list and make a dictionary of how many times each saved event is registered. Very similar to FindDuplicates(), but also includes SEs that are registered only once.

ShowEventDict(edict)

Print out the dictionary of grouped events generated by functions like FindGroups and FindDuplicates.