Misc Utilities

Location

Note

To manipulate the location of Sims, take a look at CommonSimLocationUtils

Location

class CommonLocationUtils

Bases: object

Utilities for manipulating locations and lots.

To manipulate the location of Sims, see CommonSimLocationUtils. To manipulate the location of Objects, see CommonObjectLocationUtils.

static can_location_be_routed_to(location)

Determine if a location can be routed to by a Sim.

Parameters:location (CommonLocation) – The location to check.
Returns:True, if the location can be routed to by a Sim. False, it not.
Return type:bool
static can_position_be_routed_to(position, surface_identifier)

Determine if a position and surface can be routed to by a Sim.

Parameters:
Returns:

True, if the position can be routed to by a Sim. False, it not.

Return type:

bool

static current_lot_has_all_traits(lot_trait_ids)

Determine if the Current Lot has all of the specified Lot Traits.

Parameters:lot_trait_ids (Tuple[int]) – A collection of traits to look for.
Returns:True, if the current lot has all of the specified traits. False, if not.
Return type:bool
static current_lot_has_any_traits(lot_trait_ids)

Determine if the Current Lot has any of the specified Lot Traits.

Parameters:lot_trait_ids (Tuple[int]) – A collection of traits to look for.
Returns:True, if the current lot has any of the specified traits. False, if not.
Return type:bool
static current_lot_has_trait(lot_trait_id)

Determine if the Current Lot has the specified Lot Trait.

Parameters:lot_trait_id (int) – The trait to look for.
Returns:True, if the current lot has the specified trait. False, if not.
Return type:bool
static current_venue_allows_role_state_routing()

Determine if the current venue allows routing for role states.

Returns:True, if the venue of the current lot allows routing by role state. False, if not.
Return type:bool
static current_venue_requires_player_greeting()

Determine if the current venue requires player greeting.

Returns:True, if the venue of the current lot requires the player to be greeted. False, if not.
Return type:bool
static get_all_block_ids(zone_id)

Retrieve a collection of all Block Identifiers for a Zone.

Parameters:zone_id (int) – The decimal identifier of the Zone to retrieve the block ids of.
Returns:A collection of block identifiers.
Return type:Tuple[int]
static get_all_block_ids_in_current_zone()

Retrieve a collection of all Block Identifiers for the current zone.

Note

A Block Id is essentially an identifier for a Room.

Returns:A collection of block decimal identifiers.
Return type:Tuple[int]
static get_all_block_polygons(zone_id)

Retrieve all block polygons for a Zone.

Note

A Block is essentially just a Room.

Parameters:zone_id (int) – A decimal identifier of a Zone.
Returns:A collection of polygons for the specified Zone.
Return type:Dict[int, Tuple[Tuple[List[CommonVector3]]]]
static get_all_block_polygons_of_current_zone()

Retrieve all block polygons for the current Zone.

Returns:A dictionary of polygons for the current Zone with the Block Ids as the key.
Return type:Dict[int, Tuple[Tuple[Polygon]]]
static get_block_id(zone_id, position, surface_level)

Retrieve the decimal identifier of the block containing the position.

Parameters:
  • zone_id (int) – The decimal identifier of a Zone.
  • position (CommonVector3) – An instance of a vector.
  • surface_level (int) – The surface level of the position.
Returns:

A decimal identifier of the block containing the position.

Return type:

int

static get_block_id_in_current_zone(position, level)

Retrieve the decimal identifier of the block containing the position.

Parameters:
  • position (CommonVector3) – An instance of a vector.
  • surface_level (int) – The surface level of the position.
Returns:

A decimal identifier of the block containing the position.

Return type:

int

static get_current_lot()

Retrieve the current lot.

Returns:The current Lot.
Return type:Lot
static get_current_lot_id()

Retrieve the decimal identifier of the current Lot.

Returns:The decimal identifier of the current Lot or -1 if a problem occurs.
Return type:int
static get_current_venue_type()

Retrieve the type of the current venue.

Returns:The VenueType of the current lot.
Return type:VenueTypes
static get_current_zone()

Retrieve the current zone.

Returns:The current Zone
Return type:Zone
static get_current_zone_id()

Retrieve the current zone id.

Returns:The identifier of the current Zone.
Return type:int
static get_current_zone_plex_id()

Retrieve the plex id of the current zone.

Note

A plex id is basically a Room location.

Returns:The decimal identifier of the current zone or 0 if the current zone does not have a plex id.
Return type:int
static get_current_zone_world_description_id()

Retrieve the world description id of the current Zone.

Returns:The world description id of the current Zone.
Return type:int
static get_current_zone_world_id()

Retrieve the world id of the current Zone.

Returns:The world id of the current Zone.
Return type:int
static get_lot_corners(lot)

Retrieve the lot corners of the specified Lot.

Returns:A collection of corners of the specified Lot.
Return type:Tuple[Any]
static get_lot_corners_of_current_lot()

Retrieve the lot corners of the current Lot.

Returns:A collection of corners on the current Lot.
Return type:Tuple[Any]
static get_lot_id(lot)

Retrieve the decimal identifier of a Lot.

Parameters:lot (Lot) – An instance of a Lot.
Returns:The decimal identifier of the specified lot or -1 if a problem occurs.
Return type:int
static get_lot_traits(lot_id)

Retrieve the Lot Traits of a Lot with the specified identifier.

Parameters:zone_id (int) – The lot to retrieve the traits of.
Returns:A collection of Lot Traits for the specified lot.
Return type:Tuple[ZoneModifier]
static get_lot_traits_of_current_lot()

Retrieve the Lot Traits of the Current Lot.

Returns:A collection of Lot Traits for the current lot.
Return type:Tuple[ZoneModifier]
static get_plex_id(zone_id)

Retrieve the plex id of a Zone.

Returns:The Plex Id of the specified zone or -1 if it was not found.
Return type:int
static get_plex_id_for_zone(zone)

Retrieve the plex id for a Zone.

Returns:The Plex Id of the specified zone or -1 if it was not found.
Return type:int
static get_surface_height_at(x, z, routing_surface)

Calculate the height of a surface.

Parameters:
  • x (float) – The x position of the surface.
  • z (float) – The z position of the surface.
  • routing_surface (CommonSurfaceIdentifier) – The surface.
Returns:

The height of the surface.

Return type:

float

static get_venue_of_current_lot()

Retrieve a Venue for the current lot.

Returns:The Venue of the current lot.
Return type:Venue
static get_zone(zone_id, allow_unloaded_zones=False)

Retrieve the Zone matching an identifier.

Parameters:
  • zone_id (int) – The decimal identifier of a Zone.
  • allow_unloaded_zones (bool, optional) – If set to True, Zones that are currently not loaded (or have not been loaded) will be considered. If set to False, Zones that have yet to be loaded will not be considered. Default is False.
Returns:

The Zone with the specified zone id or None if it was not found.

Return type:

Zone

static get_zone_id(zone)

Retrieve the identifier of the specified Zone.

Parameters:zone (Zone) – The Zone to get the identifier of.
Returns:The identifier of the specified Zone.
Return type:int
static get_zone_lot(zone)

Retrieve the lot of a Zone.

Parameters:zone (Zone) – An instance of a Zone.
Returns:The Lot belonging to the specified Zone or None if a problem occurs.
Return type:Union[Lot, None]
static get_zone_world_description_id(zone_id)

Retrieve the world description id of the a Zone.

Parameters:zone_id (int) – The decimal identifier of a Zone.
Returns:The world description id of the the specified Zone.
Return type:int
static get_zone_world_id(zone_id)

Retrieve the world id of the a Zone.

Parameters:zone_id (int) – The decimal identifier of a Zone.
Returns:The world id of the specified Zone.
Return type:int
static is_current_venue_residential()

Determine if a venue is residential.

Returns:True, if the venue of the current lot is residential. False, if not.
Return type:bool
static is_location_outside_current_lot(location)

Determine if a location is outside of the current lot or not.

Parameters:location (CommonLocation) – The Location to check.
Returns:True, if the location is outside of the current lot. False, if not.
Return type:bool
static is_location_outside_lot(location, lot_id)

Determine if a location is outside of the Lot with the specified identifier.

Parameters:
  • location (CommonLocation) – The Location to check.
  • zone_id (int) – The identifier of a Zone to check for the Location to be outside of.
Returns:

True, if location is outside of the Lot with the specified lot_id. False, if not.

Return type:

bool

static is_position_on_current_lot(position)

Determine if a sim is on the current lot.

Parameters:position (CommonVector3) – The position to check.
Returns:True, if the specified position is within the bounds of the current lot. False, if not.
Return type:bool
static is_position_on_lot(position, lot)

Determine if a Position is located on a Lot.

Parameters:
  • position (CommonVector3) – An instance of a CommonVector
  • lot (Lot) – An instance of a Lot.
Returns:

True, if the Sim is on the specified Lot. False, if not.

Return type:

bool

Terrain

Travel

class CommonTravelUtils

Bases: object

Utilities for moving Sims around.

static get_travel_group_id(sim_info)

Retrieve a decimal identifier for the Travel Group of a Sim.

Parameters:sim_info (SimInfo) – An instance of a Sim.
Returns:The decimal identifier of the Travel Group of the Sim or -1 if a problem occurs.
Return type:int
static travel_to_home_lot_of(sim_info)

Travel to the home lot of a Sim.

Parameters:sim_info (SimInfo) – The owner of the home lot to travel to.
static travel_to_home_lot_of_active_sim(sim_info)

Travel with the specified Sim to the home lot of the Active Sim.

Parameters:sim_info (SimInfo) – The Sim to travel with.
static travel_to_lot(sim_info, lot_id)

Travel with the specified Sim to the Lot with the specified identifier.

Parameters:
  • sim_info (SimInfo) – The Sim to travel with.
  • lot_id (int) – The identifier of the lot to travel to.
static travel_to_zone(sim_info, zone_id)

Travel with the specified Sim to a Zone.

Parameters:
  • sim_info (SimInfo) – The Sim to travel with.
  • zone_id (int) – The identifier of the zone to travel to.

Resources

Statistics

Note

To manipulate statistics/commodities of Sims, take a look at CommonSimStatisticUtils

class CommonStatisticUtils

Bases: object

Utilities for manipulating Statistics.

static get_statistic_initial_value(statistic_id)

Retrieve the Initial Value of a Statistic.

Parameters:statistic_id (Union[int, CommonStatisticId]) – The identifier of the Statistic to use.
Returns:The initial value of the statistic.
Return type:float
static get_statistic_max_value(statistic_id)

Retrieve the Maximum Value of a Statistic.

Parameters:statistic_id (Union[int, CommonStatisticId]) – The identifier of the Statistic to use.
Returns:The maximum value of the statistic.
Return type:float
static get_statistic_min_value(statistic_id)

Retrieve the Minimum Value of a Statistic.

Parameters:statistic_id (Union[int, CommonStatisticId]) – The identifier of the Statistic to use.
Returns:The minimum value of the statistic.
Return type:float
static load_statistic_by_id(statistic_id: Union[int, sims4communitylib.enums.statistics_enum.CommonStatisticId]) → Optional[<sphinx.ext.autodoc.importer._MockObject object at 0x7fe47f0431d0>]

load_statistic(statistic_id)

Load an instance of a Statistic by its decimal identifier.

Parameters:statistic_id (Union[int, CommonStatisticId]) – The decimal identifier of a Statistic.
Returns:An instance of a Statistic matching the decimal identifier or None if not found.
Return type:Union[Statistic, None]

Situations

Note

To manipulate situations of Sims, take a look at CommonSimSituationUtils

class CommonSituationUtils

Bases: object

Utilities for manipulating Situations.

static get_situation_id(situation_identifier)

Retrieve the decimal identifier of a Situation.

Parameters:situation_identifier (Union[int, Situation]) – The identifier or instance of a Situation.
Returns:The decimal identifier of the Situation or None if the Situation does not have an id.
Return type:Union[int, None]
static get_situation_name(situation)

Retrieve the Name of a Situation.

Parameters:situation (Situation) – An instance of a Situation.
Returns:The short name of a Situation or None if a problem occurs.
Return type:Union[str, None]
static get_situation_names(situations)

Retrieve the Names of a collection of Situation.

Parameters:situations (Iterator[Situation]) – A collection of Situation instances.
Returns:A collection of names for all specified Situations.
Return type:Tuple[str]

Resources

class CommonResourceUtils

Bases: object

Utilities for retrieving the Tuning files and instances of various resources. (Objects, Snippets, Statistics, etc.).

static convert_str_to_fnv32(text, seed=2166136261, high_bit=True)

Convert a text string into an FNV32 decimal identifier.

Parameters:
  • text (str) – The text to convert.
  • seed (int) – A seed to use when converting. Default value is 2166136261.
  • high_bit (bool) – If True, the high FNV bit will be returned. If False, a low FNV bit will be returned.
Returns:

The text converted to a FNV32 decimal identifier.

Return type:

int

static convert_str_to_fnv64(text, seed=14695981039346656037, high_bit=True)

Convert a text string into an FNV64 decimal identifier.

Parameters:
  • text (str) – The text to convert.
  • seed (int) – A seed to use when converting. Default value is 14695981039346656037.
  • high_bit (bool) – If True, a high bit version of the FNV bit will be returned. If False, a low bit version of the FNV bit will be returned.
Returns:

The text converted to an FNV64 decimal identifier.

Return type:

int

static get_enum_by_name(name, enum_type, default_value=None)

Retrieve an enum value by its a name.

Parameters:
  • name (str) – The name of an outfit category.
  • enum_type (Any) – The type of enum to retrieve.
  • default_value (Any, optional) – The default value to return if an enum value was not found using the specified name. Default is None.
Returns:

The enum value with a name matching the specified name.

Return type:

Any

static get_instance_manager(instance_manager_type)

Get an InstanceManager for the specified type.

Parameters:instance_manager_type (Types) – The type of InstanceManager to get.
Returns:An InstanceManager for the specified type, or None if no InstanceManager is found.
Return type:Union[InstanceManager, None]
static get_resource_key(resource_type, instance_id)

Retrieve the resource key of a resource in the format: 00000000(Type):00000000(Group):00000000000000000(Instance Guid)

Note

Possible Usages:

  • Retrieve the identifier of an Icon to display next to an Interaction in the Pie Menu.
  • Retrieve the identifier of an Image for display in Dialogs or Notifications.
Example Usage:
# This will retrieve the key for the image with identifier 1234
icon_key = CommonResourceUtils.get_resource_key(Types.PNG, 1234)
Parameters:
  • resource_type (Types) – The type of resource being loaded.
  • instance_id (int) – The decimal identifier of the resource.
Returns:

The resource key of an instance or None if no instance was found.

Return type:

_resourceman.Key

static load_all_instances(instance_type)

Load all instances of the specified type.

Parameters:instance_type (Types) – The type of instance being loaded.
Returns:All instances of the specified type.
Return type:ItemsView[Any, Any]
static load_instance(instance_type, instance_id)

Load an instance of the specified type.

Example Usage 1:
 
# This will retrieve an instance for the Confident mood and will be of type statistics.mood.Mood
mood_instance = CommonResourceUtils.load_instance(Types.MOOD, CommonMoodId.CONFIDENT)
Example Usage 2:
 
# This will retrieve an instance for the Walk Style Angry buff and will be of type buffs.buff.Buff
buff_instance = CommonResourceUtils.load_instance(Types.BUFF, CommonBuffId.WALK_STYLE_ANGRY)
Parameters:
  • instance_type (Types) – The type of instance being loaded.
  • instance_id (int) – The decimal identifier of an instance.
Returns:

An instance of the specified type or None if no instance was found.

Return type:

Any

static load_instance_from_manager(instance_manager, instance_id)

Load an instance from the specified InstanceManager.

Parameters:
  • instance_manager (InstanceManager) – The InstanceManager an instance will be loaded from.
  • instance_id (int) – The decimal identifier of an instance.
Returns:

An instance of the specified type or None if no instance was found.

Return type:

Any

static load_instances_with_any_tags(resource_type, tags)

Retrieve all resources that contain the specified tag names within their tuning file.

Note

Possible Usages:

  • Load all Snippet files containing properties with any of the specified tags.
Parameters:
  • resource_type (Types) – The type of resource being loaded.
  • tags (Tuple[str]) – A collection of tag names to locate within a tuning file.
Returns:

A collection of resources that contain any of the specified tags.

Return type:

Tuple[Any]

static load_resource_bytes(resource_key, silent_fail=True)

Retrieve the bytes of a resource.

Parameters:
  • resource_key (_resourceman.Key) – The key of the resource.
  • silent_fail (bool, optional) – Set to True to ignore errors if they occur. Set to False to throw errors when they occur. Default is True.
Returns:

An Input Output Byte reader/writer for the resource.

Return type:

BytesIO

static load_resource_bytes_by_name(resource_type, resource_name, fnv64=True, high_bit=False)

Load the bytes of a resource into a Bytes Reader.

Note

This function will only work if the instance key/decimal identifier of the resource equates to the name of the resource.

Parameters:
  • resource_type (Types) – The type of resource being loaded.
  • resource_name (str) – The tuning name of the resource.
  • has_fnv64_identifier (bool, optional) – Set to True to indicate the resource uses a 64 bit identifier. Set to False to indicate the resource uses a 32 bit identifier. Default is True.
  • has_high_bit_identifier (bool, optional) – Set to True to indicate the resource uses a high bit identifier. Set to False to indicate the resource uses a low bit identifier. Default is False.
Returns:

An Input Output Byte reader/writer for the resource or None if a problem occurs.

Return type:

Union[BytesIO, None]

Components

class CommonComponentUtils

Bases: object

Utilities for handling components of component containers.

static add_dynamic_component(component_container, component_type)

Add a dynamic component to a ComponentContainer.

Parameters:
  • component_container (ComponentContainer) – The ComponentContainer to add to.
  • component_type (CommonComponentType) – The type of component being added.
Returns:

The added Component or None

Return type:

Union[Component, None]

static get_component(component_container, component_type, add_dynamic=False)

Retrieve a component from a ComponentContainer.

Parameters:
  • component_container (ComponentContainer) – The ComponentContainer to retrieve a component from.
  • component_type (CommonComponentType) – The type of component being retrieved.
  • add_dynamic (bool, optional) – Whether or not to add the component dynamically.
Returns:

An object of type Component, or None if the specified component type is not found.

Return type:

Union[Component, None]

static has_component(component_container, component_type)

Determine if a ComponentContainer has a component of the specified type.

Parameters:
  • component_container (ComponentContainer) – The ComponentContainer to check.
  • component_type (CommonComponentType) – The type of component to locate.
Returns:

True, if the ComponentContainer contains a component of the specified type. False, if not.

Return type:

bool

Interactions

Note

To manipulate interactions of Sims, take a look at CommonSimInteractionUtils

class CommonInteractionUtils

Bases: object

Utilities for manipulating Interactions.

static get_instance_manager()

Retrieve the instance manager for interactions.

Returns:The instance manager for interactions.
Return type:InteractionInstanceManager
static get_interaction_display_name(interaction, tokens=())

Retrieve the display name of an interaction.

Parameters:
  • interaction (Interaction) – An instance of an interaction.
  • tokens (Iterator[Any]) – A collection of tokens to format into the display name.
Returns:

An instance of type LocalizedString or None if a problem occurs.

Return type:

Union[LocalizedString, None]

static get_interaction_id(interaction_identifier)

Retrieve the decimal identifier of an Interaction.

Parameters:interaction_identifier (Union[int, Interaction]) – The identifier or instance of a Interaction.
Returns:The decimal identifier of the Interaction or None if the Interaction does not have an id.
Return type:Union[int, None]
static get_interaction_short_name(interaction)

Retrieve the Short Name of an Interaction.

Parameters:interaction (Interaction) – An instance of an interaction.
Returns:The short name of an interaction or None if a problem occurs.
Return type:Union[str, None]
static get_interaction_short_names(interactions)

Retrieve the Short Names of a collection of Interactions.

Parameters:interactions (Iterator[Interaction]) – A collection of interaction instances.
Returns:A collection of short names of all interaction instances.
Return type:Tuple[str]
static is_social_mixer_interaction(interaction)

Determine if an interaction is a Social Mixer interaction.

Parameters:interaction (Interaction) – An instance of an Interaction.
Returns:True, if the interaction is a Social Mixer interaction. False, if not.
static is_super_interaction(interaction)

Determine if an interaction is a Super interaction.

Parameters:interaction (Interaction) – An instance of an Interaction.
Returns:True, if the interaction is a Super interaction. False, if not.
static load_interaction_by_id(interaction_id)

Load an instance of an Interaction by its decimal identifier.

Parameters:interaction_id (Union[int, CommonInteractionId]) – The decimal identifier of an Interaction.
Returns:An instance of an Interaction matching the decimal identifier or None if not found.
Return type:Union[Interaction, None]

Misc

Collections

class CommonCollectionUtils

Bases: object

Utilities for collections.

static add_to_dict_if_not_exist(dictionary_one, dictionary_two)

Combine two dictionaries.

Note

If a key already exists in the first dictionary, the value from the second dictionary is ignored.

Parameters:
  • dictionary_one (Dict[Any, Any]) – The first dictionary.
  • dictionary_two (Dict[Any, Any]) – The second dictionary.
Returns:

A new combined dictionary.

Return type:

Dict[Any, Any]

static create_possible_combinations(items, items_per_combination)

Create a collection of all possible combinations of the specified items.

Note

Example: With items: [1, 2, 3] and combination_length: 2 the result will be: {(1, 2), (1, 3), (2, 3)}

Parameters:
  • items (Union[List[Any], Tuple[Any]]) – A collection of items to create combinations from.
  • items_per_combination (int) – The number of items in each combination.
Returns:

A collection of combinations

Return type:

Set[Tuple[Any]]

static flatten(to_flatten)

Flatten a collection of collections to a single list or itself if already flattened.

Parameters:to_flatten (Any) – A collection of items.
Returns:A single flattened list or to_flatten if already flattened.
Return type:Union[Any, List[Any]]
static intersects(list_one, *list_items)

Determine if a list contains any of the specified items.

Parameters:
  • list_one (List[Any]) – The list being checked.
  • list_items (Any) – An iterable of items being searched for.
Returns:

True, if the list contains any of the specified items. False, if not.

Return type:

bool

static is_collection(obj)

Determine if an object is a collection or not.

Parameters:obj (Any) – An object.
Returns:True, if the object is a collection, False, if not.
Return type:bool

Functions

class CommonFunctionUtils

Bases: object

Utilities for manipulating functions.

static noop(*_, **__)

An empty function that does nothing. Useful when you need something to do nothing.

Note

Use this when you want something to do nothing.

static noop_enqueue(*_, **__)

An empty function that does nothing but return EnqueueResult.NONE(). Useful when you need something to do nothing.

Note

Use this when you want something to do nothing.

static print_arguments(log, func_identifier='NO_IDENTIFIER_SPECIFIED')

Create a function that will log the arguments and keyword arguments it receives

Parameters:
  • log (CommonLog) – The log to print the arguments to.
  • func_identifier (str) – An identifier for the function to determine which function was invoked
Returns:

A function that will print the arguments sent to it when the original function is invoked.

Return type:

Callable[.., Any]

static run_predicate_with_reversed_result(predicate_function)

Wrap the specified predicate function and reverse the result of it when the function is invoked.

Parameters:predicate_function (Callable[.., bool]) – The predicate function to reverse the result of.
Returns:A function that will reverse the result of predicate_function upon invocation.
Return type:Callable[.., bool]
static run_predicates_as_one(predicate_functions, all_must_pass=True)

Wrap all predicate functions into a single predicate function. (See returned value for more information).

Note

If all_must_pass is True a wrapped function that will return a value of:

  • True, if all predicates resulted in a True value.
  • False, if any predicates resulted in a False value.

If all_must_pass is False a wrapped function that will return a value of:

  • True, if any predicates resulted in a True value.
  • False, if all predicates resulted in a False value.
Parameters:
  • predicate_functions (Iterator[Callable[.., bool]]) – The predicate functions to run as one.
  • all_must_pass (bool, optional) – If True, all of the predicates must return a True value. If False, only some of the predicates must return a True value.
Returns:

The result of running all functions.

Return type:

bool

static run_with_arguments(primary_function, *args, **kwargs)

Wrap a function and run it with additional arguments when something invokes it.

Parameters:primary_function (Callable[.., Any]) – The function that will be run.
Returns:A function that will send extra arguments upon invocation.
Return type:Callable[.., Any]
static safe_run(mod_identity, primary_function, fallback_function, *args, **kwargs)

Safely run a function, if the primary function throws an exception, the fallback function will be run instead.

Parameters:
  • mod_identity (CommonModIdentity) – The identity of the mod running a function safely.
  • primary_function (Callable[.., Any]) – The primary function to safely run.
  • fallback_function (Callable[.., Any]) – A function called when the primary function throws an exception.
  • args (Any) – Arguments to pass to both the primary function and fallback function.
  • kwargs (Any) – Keyword Arguments to pass to both the primary function and fallback function.
Returns:

The result of either the primary function or the fallback function if the primary threw an exception.

Return type:

Any

Icons

class CommonIconUtils

Bases: object

Utilities for loading icons.

static load_arrow_left_icon()

Get the Resource Key for the ARROW_LEFT_ICON.

Returns:An identifier for the icon.
Return type:Any
static load_arrow_navigate_into_icon()

Get the Resource Key for the ARROW_NAVIGATE_INTO_ICON.

Returns:An identifier for the icon.
Return type:Any
static load_arrow_right_icon()

Get the Resource Key for the ARROW_RIGHT_ICON.

Returns:An identifier for the icon.
Return type:Any
static load_blank_square_icon()

Get the Resource Key for the BLANK_SQUARE_ICON.

Returns:An identifier for the icon.
Return type:Any
static load_checked_circle_icon()

Get the Resource Key for the CHECKED_CIRCLE_ICON.

Returns:An identifier for the icon.
Return type:Any
static load_checked_square_icon()

Get the Resource Key for the CHECKED_SQUARE_ICON.

Returns:An identifier for the icon.
Return type:Any
static load_filled_circle_icon()

Get the Resource Key for the FILLED_CIRCLE_ICON.

Returns:An identifier for the icon.
Return type:Any
static load_question_mark_icon()

Get the Resource Key for the QUESTION_MARK_ICON.

Returns:An identifier for the icon.
Return type:Any
static load_six_sided_dice_icon()

Get the Resource Key for the SIX_SIDED_DICE_ICON.

Returns:An identifier for the icon.
Return type:Any
static load_text_next_icon()

Get the Resource Key for the TEXT_NEXT_SQUARE_ICON.

Returns:An identifier for the icon.
Return type:Any
static load_text_prev_icon()

Get the Resource Key for the TEXT_PREV_SQUARE_ICON.

Returns:An identifier for the icon.
Return type:Any
static load_unchecked_square_icon()

Get the Resource Key for the UNCHECKED_SQUARE_ICON.

Returns:An identifier for the icon.
Return type:Any
static load_unfilled_circle_icon()

Get the Resource Key for the UNFILLED_CIRCLE_ICON.

Returns:An identifier for the icon.
Return type:Any
static load_x_icon()

Get the Resource Key for the X_ICON.

Returns:An identifier for the icon.
Return type:Any

Types

class CommonTypeUtils

Bases: object

Utilities for determining the type of an object.

static is_door(obj)

Determine if an Object is of type Door

Parameters:obj (Any) – The object to check.
Returns:True, if it is. False, if it is not.
Return type:bool
static is_game_object(obj)

Determine if an object is of type GameObject

Parameters:obj (Any) – The object to check.
Returns:True, if it is. False, if it is not.
Return type:bool
static is_location(obj)

Determine if an object is of type Location.

Parameters:obj (Any) – The object to check.
Returns:True, if it is. False, if it is not.
Return type:bool
static is_ocean(obj)

Determine if an object is of type Ocean

Parameters:obj (Any) – The object to check.
Returns:True, if it is. False, if it is not.
Return type:bool
static is_pool_seat(obj)

Determine if an Object is a Pool Seat.

Parameters:obj – An instance of an Object.
Type:Any
Returns:True, if the Object is a Pool Seat. False, if not.
Return type:bool
static is_script_object(obj)

Determine if an object is of type ScriptObject

Note

GameObjects, Terrain, and Sims are all ScriptObjects. Try also is_game_object(), is_terrain(), and is_sim_instance()

Parameters:obj (Any) – The object to check.
Returns:True, if it is. False, if it is not.
Return type:bool
static is_sim_info(obj)

Determine if an object is of type SimInfo

Parameters:obj (Any) – The object to check.
Returns:True, if it is. False, if it is not.
Return type:bool
static is_sim_info_base_wrapper(obj)

Determine if an object is of type SimInfo

Parameters:obj (Any) – The object to check.
Returns:True, if it is. False, if it is not.
Return type:bool
static is_sim_instance(obj)

Determine if an object is of type Sim

Parameters:obj (Any) – The object to check.
Returns:True, if it is. False, if it is not.
Return type:bool
static is_sim_or_sim_info(obj)

Determine if an object is either of type Sim or type SimInfo

Parameters:obj (Any) – The object to check.
Returns:True, if it is. False, if it is not.
Return type:bool
static is_swimming_pool(obj)

Determine if an object is of type SwimmingPool

Parameters:obj (Any) – The object to check.
Returns:True, if it is. False, if it is not.
Return type:bool
static is_terrain(obj)

Determine if an object is of type Terrain

Parameters:obj (Any) – The object to check.
Returns:True, if it is. False, if it is not.
Return type:bool

Weathers

class CommonWeatherUtils

Bases: object

Utilities for manipulating the weather.

static current_temperature_is_cold_or_freezing()

Determine if the current temperature is cold or freezing.

Returns:True, if the current temperature contains cold or freezing. False, if not.
Return type:bool
static current_weather_contains_thunder_or_lightning()

Determine if the current weather contains lightning or thunder.

Returns:True, if the current weather contains thunder or lightning. False, if not.
Return type:bool
static get_current_temperature()

Retrieve the current temperature.

Returns:The current temperature.
Return type:Temperature
static get_weather_cloud_type()

Retrieve the current cloud type.

Returns:The current cloud type.
Return type:CloudType
static weather_effect_is_active(weather_effect_type)

Determine if the specified weather effect is currently active.

Parameters:weather_effect_type (WeatherEffectType) – The weather effect to check for.
Returns:True, if the weather is active. False, if it is not.
Return type:bool
static weather_effects_are_active(weather_effect_types)

Determine if any of the specified weather effects are currently active.

Parameters:weather_effect_types (Iterator[WeatherEffectType]) – An iterable of weather effects to check for.
Returns:True, if any of the weathers is active. False, if none of the weathers are active.
Return type:bool

Math

class CommonMathUtils

Bases: object

Utilities for math operations.

static calculate_degrees_between_positions(position_one, position_two)

Calculate the degrees between two positions.

Parameters:
Returns:

The degrees between the specified Vectors.

Return type:

float

static calculate_distance(position_one, position_two, flatten_positions=True)

Calculate the distance between two vectors.

Parameters:
  • position_one (CommonVector3) – An instance of a Vector.
  • position_two (CommonVector3) – An instance of a Vector.
  • flatten_positions (bool, optional) – If True, both Vectors will be flattened before calculations will occur. Default is True.
Returns:

The distance between the two specified vectors.

Return type:

float

static degrees_to_radian(degrees)

Translate Degrees to Radian.

Parameters:degrees (float) – The value to convert.
Returns:The value as Radian.
Return type:float
static radian_to_degrees(radian)

Translate Radian to Degrees.

Parameters:radian (float) – The value to convert.
Returns:The value as Degrees.
Return type:float