(Also posted on CivFanatics)
Well, for a start, it isn't something for a regular player to use, so if you're not a python modder, stop now.
During my python escapades, I've had cause to make a small number of global functions that I believe others will benefit from, especially end users. This is NOT a standalone mod. It is a python module that can be incorporated into other projects. The major function of this library allows modders to store data without conflicting with anything else.
I felt that this was something that needed to be addressed sooner or later.
The following is a brief API :
Basic Utilities
===============
sdEcho( string )
Outputs 'string' to the python debug log AND onto the screen.
Either output mode can be toggled using two boolean variables inside the function definition.
sdGetTimeInt( turn_int )
Converts a year string of the form "1234 AD" or "1234 BC" to an integer. BC is negative.
sdGameYearsInt()
Returns the total span of years a given game should last, irrespective of victory conditions.
Standard Firaxis gamespeeds cover exactly 6,050 total years, but others do not - for example, my SD-Glacial mod covers 6,200 years.
Data Storage
============
Internal Functions :
sdModInit( 'MyModName_string' )
Initializes a central reservoir of custom variables for your mod's use.
For internal use. You should not need to actively use this function.
sdModFixCase( 'MyModName_string', Mod_dictionary )
For internal use. You should not use this function.
sdModLoad( 'MyModName_string' )
Loads previously initialized data from the central reservoir.
For internal use. You should not need to actively use this function.
sdModSave( 'MyModName_string', Mod_dictionary )
Saves a mod's entire variable data to the central reservoir.
For internal use. You should not need to actively use this function.
MOD Functions :
sdEntityInit( 'MyModName_string', 'UniqueName_string', Entity_dictionary )
Initializes a unique data entity (city, unit, plot).
UniqueName_string = Any string used to indentify the entity, such as 'Alcatraz' or '5435' or 'Warrior55'
Entity_dictionary = A python dictionary containing the data set for the 'Entity', such as {'var1' : 56, 'var2' : 'My Rectum', 'var3' : [1, 2, 3]}
sdEntityWipe( 'MyModName_string', 'UniqueName_string' )
Removes an entity that has been previously initialized by sdEntityInit.
An entity can be anything that contains a set of data... a city, a unit or your dog's name. Use your imagination.
sdEntityExists( 'MyModName', 'UniqueName_string' )
Checks whether or not an entity has been initialized by sdEntityInit.
Returns bool False on failure, bool True on success.
sdGetVal( 'MyModName_string', 'UniqueName_string', 'VariableName_string' )
Fetches a specific variable's value from the entity's data set.
Will raise an exception on failure.
sdSetVal( 'MyModName_string', 'UniqueName_string', 'VariableName_string', any_value )
Stores a specific variable's value within the entity's data set.
Returns bool False on failure, bool True on success.
sdDelVal( 'MyModName_string', 'UniqueName_string', 'VariableName_string' )
Removes a specific variable from the entity's data set.
Returns bool False on failure, bool True on success.
sdGetGlobal( 'MyModName_string', 'GlobalVariableName_string' )
Fetches a specific variable's value from the mod's global data set, which is automatically initialized.
Will raise an exception on failure.
sdSetGlobal( 'MyModName_string', 'GlobalVariableName_string', any_value )
Stores a specific variable's value within the mod's global data set, which is automatically initialized.
sdDelGlobal( 'MyModName_string', 'GlobalVariableName_string' )
Removes a specific variable from the mod's global data set.
Returns bool False on failure, bool True on success.
To clarify, the saved data is stored with saved games and will be restored when a game is reloaded by the user. Saved data will not clash with other mods using this toolkit.
History
=-=-=-=
v1.00 :
Initial Release.
v1.10 :
BASIC-UTILITIES Addition : sdGetTimeInt( turn )
BASIC-UTILITIES Addition : sdGameYearsInt()
SD-DATA-STORAGE Addition : sdModFixCase( 'MyModName', Mod_dictionary )
SD-DATA-STORAGE Addition : sdEntityWipe( 'MyModName', 'UniqueName_string' )
Now checks for changed case in mod names.
Changed all defs so the leading characters are lower case.
v1.20 :
Some minor cleanups and optimizations.
Added comments to the functions with examples and descriptions.
SD-DATA-STORAGE Addition : sdEntityExists( 'MyModName', 'UniqueName_string' )
SD-DATA-STORAGE Addition : sdDelVal( 'MyModName', 'UniqueName_string', 'VariableName_string' )
SD-DATA-STORAGE Addition : sdGetGlobal( 'MyModName', 'GlobalVariableName' )
SD-DATA-STORAGE Addition : sdSetGlobal( 'MyModName', 'GlobalVariableName', any_value )
SD-DATA-STORAGE Addition : sdDelGlobal( 'MyModName', 'GlobalVariableName' )
Boolean return values added to some functions. See API section.
v1.21 :
Fixed a major bug in sdDelGlobal.
v1.22 :
Fixed another bug in sdDelGlobal.
Well, for a start, it isn't something for a regular player to use, so if you're not a python modder, stop now.
During my python escapades, I've had cause to make a small number of global functions that I believe others will benefit from, especially end users. This is NOT a standalone mod. It is a python module that can be incorporated into other projects. The major function of this library allows modders to store data without conflicting with anything else.
I felt that this was something that needed to be addressed sooner or later.
The following is a brief API :
Basic Utilities
===============
sdEcho( string )
Outputs 'string' to the python debug log AND onto the screen.
Either output mode can be toggled using two boolean variables inside the function definition.
sdGetTimeInt( turn_int )
Converts a year string of the form "1234 AD" or "1234 BC" to an integer. BC is negative.
sdGameYearsInt()
Returns the total span of years a given game should last, irrespective of victory conditions.
Standard Firaxis gamespeeds cover exactly 6,050 total years, but others do not - for example, my SD-Glacial mod covers 6,200 years.
Data Storage
============
Internal Functions :
sdModInit( 'MyModName_string' )
Initializes a central reservoir of custom variables for your mod's use.
For internal use. You should not need to actively use this function.
sdModFixCase( 'MyModName_string', Mod_dictionary )
For internal use. You should not use this function.
sdModLoad( 'MyModName_string' )
Loads previously initialized data from the central reservoir.
For internal use. You should not need to actively use this function.
sdModSave( 'MyModName_string', Mod_dictionary )
Saves a mod's entire variable data to the central reservoir.
For internal use. You should not need to actively use this function.
MOD Functions :
sdEntityInit( 'MyModName_string', 'UniqueName_string', Entity_dictionary )
Initializes a unique data entity (city, unit, plot).
UniqueName_string = Any string used to indentify the entity, such as 'Alcatraz' or '5435' or 'Warrior55'
Entity_dictionary = A python dictionary containing the data set for the 'Entity', such as {'var1' : 56, 'var2' : 'My Rectum', 'var3' : [1, 2, 3]}
sdEntityWipe( 'MyModName_string', 'UniqueName_string' )
Removes an entity that has been previously initialized by sdEntityInit.
An entity can be anything that contains a set of data... a city, a unit or your dog's name. Use your imagination.
sdEntityExists( 'MyModName', 'UniqueName_string' )
Checks whether or not an entity has been initialized by sdEntityInit.
Returns bool False on failure, bool True on success.
sdGetVal( 'MyModName_string', 'UniqueName_string', 'VariableName_string' )
Fetches a specific variable's value from the entity's data set.
Will raise an exception on failure.
sdSetVal( 'MyModName_string', 'UniqueName_string', 'VariableName_string', any_value )
Stores a specific variable's value within the entity's data set.
Returns bool False on failure, bool True on success.
sdDelVal( 'MyModName_string', 'UniqueName_string', 'VariableName_string' )
Removes a specific variable from the entity's data set.
Returns bool False on failure, bool True on success.
sdGetGlobal( 'MyModName_string', 'GlobalVariableName_string' )
Fetches a specific variable's value from the mod's global data set, which is automatically initialized.
Will raise an exception on failure.
sdSetGlobal( 'MyModName_string', 'GlobalVariableName_string', any_value )
Stores a specific variable's value within the mod's global data set, which is automatically initialized.
sdDelGlobal( 'MyModName_string', 'GlobalVariableName_string' )
Removes a specific variable from the mod's global data set.
Returns bool False on failure, bool True on success.
To clarify, the saved data is stored with saved games and will be restored when a game is reloaded by the user. Saved data will not clash with other mods using this toolkit.
History
=-=-=-=
v1.00 :
Initial Release.
v1.10 :
BASIC-UTILITIES Addition : sdGetTimeInt( turn )
BASIC-UTILITIES Addition : sdGameYearsInt()
SD-DATA-STORAGE Addition : sdModFixCase( 'MyModName', Mod_dictionary )
SD-DATA-STORAGE Addition : sdEntityWipe( 'MyModName', 'UniqueName_string' )
Now checks for changed case in mod names.
Changed all defs so the leading characters are lower case.
v1.20 :
Some minor cleanups and optimizations.
Added comments to the functions with examples and descriptions.
SD-DATA-STORAGE Addition : sdEntityExists( 'MyModName', 'UniqueName_string' )
SD-DATA-STORAGE Addition : sdDelVal( 'MyModName', 'UniqueName_string', 'VariableName_string' )
SD-DATA-STORAGE Addition : sdGetGlobal( 'MyModName', 'GlobalVariableName' )
SD-DATA-STORAGE Addition : sdSetGlobal( 'MyModName', 'GlobalVariableName', any_value )
SD-DATA-STORAGE Addition : sdDelGlobal( 'MyModName', 'GlobalVariableName' )
Boolean return values added to some functions. See API section.
v1.21 :
Fixed a major bug in sdDelGlobal.
v1.22 :
Fixed another bug in sdDelGlobal.
Comment