Persistence

Sim Data Storage

class CommonSimDataStorage(sim_info)

Bases: sims4communitylib.persistence.common_sim_data_storage._CommonSimDataStorage

A wrapper for Sim instances that allows storing of data.

Warning

Data stored within is not persisted when closing and reopening the game!

Warning

DO NOT CREATE THIS CLASS DIRECTLY, IT IS ONLY MEANT TO INHERIT FROM!

Example usage:
# Inherit from CommonSimDataStorage
class ExampleSimDataStorage(CommonSimDataStorage):
    @classmethod
    def get_mod_identity(cls) -> CommonModIdentity:
        # !!!Override with the CommonModIdentity of your own mod!!!
        from sims4communitylib.modinfo import ModInfo
        return ModInfo.get_identity()

    @property
    def example_property_one(self) -> bool:
        # Could also be written self.get_data(default=False, key='example_property_one') and it would do the same thing.
        return self.get_data(default=False)

    @example_property_one.setter
    def example_property_one(self, value: bool):
        # Could also be written self.set_data(value, key='example_property_one') and it would do the same thing.
        self.set_data(value)
Parameters:sim_info (SimInfo) – The SimInfo of a Sim.
classmethod get_mod_identity()

Retrieve the identity of the mod that owns the class.

Warning

Override this function with the CommonModIdentity of your mod.

This is a MUST override to allow for proper Exception Handling and Logging!

Returns:An instance of CommonModIdentity
Return type:CommonModIdentity
Raises:NotImplementedError – Thrown when the function is not implemented.