pytower.object

class pytower.object.TowerObject(item=None, properties=None, nocopy=False)[source]

Represents an object appearing in the Suitebro file. This includes all the sections of the object.

Parameters:
__init__(item=None, properties=None, nocopy=False)[source]

Initializes TowerObject instance taking in uesave json data

To ensure uniqueness, this assigns a new GUID to this object

Parameters:
  • item (Optional[dict[str, Any]]) – The item section parsed, as parsed from tower-unite-suitebro

  • properties (Optional[dict[str, Any]]) – The properties section, as parsed from tower-unite-suitebro

  • nocopy (bool) – If True, then do not deep-copy the item and properties dictionaries

__lt__(other)[source]

Return self<value.

Parameters:

other (Any)

__repl__()[source]
__str__()[source]

Return str(self).

add_connection(con)[source]

Adds a connection to this object

Parameters:

con (ItemConnectionObject) – The connection to add to this object

compress()[source]
connect_to(listener_event_name, other, event_name, delay=0.0, data=None)[source]

Connect this object to another object

Parameters:
  • listener_event_name (str) – The name of the listener event to connect to (for example, “OnFired”)

  • other (TowerObject) – The other object to connect to

  • event_name (str) – The name of the event on this object to connect from

  • delay (float) – The delay in seconds

  • data (Optional[ItemConnectionData]) – The optional data to use for this event

copy()[source]

Creates a new TowerObject with the same item and properties as this one.

Return type:

TowerObject

Returns:

Copy of this TowerObject instance

property custom_name: str[source]

Custom name set by Tower Unite player

static deserialize_objects(data)[source]
Return type:

list[TowerObject]

Parameters:

data (dict)

get_connections()[source]
Return type:

list[ItemConnectionObject]

Returns:

List of connections attached to this object

get_custom_name()[source]

Deprecated since version 0.3.0: Use TowerObject.custom_name instead

Return type:

str

get_name()[source]

Deprecated since version 0.3.0: Use TowerObject.name instead

Return type:

str

get_property(path)[source]

Gets property value

Parameters:

path (list[str] | str) – Either a list of string keys or a period-separated string representing the path to take through the dictionary. For example, “properties.ItemCustomName.Name.value” and [“properties”, “ItemCustomName”, “Name”, “value”]

Return type:

Optional[Any]

Returns:

Value at path or None

property group_id: int[source]

TowerObject’s Group ID

property guid: str[source]

TowerObject’s GUID

is_canvas()[source]
Return type:

bool

Returns:

Whether object is a canvas object

matches_name(name)[source]

Determines if instance matches input name

Parameters:

name (str) – Name to match against

Return type:

bool

Returns:

True if the input name matches name or custom_name, case-insensitive

property metadata_scale: float[source]

Metadata scale (used by some workshop items)

property name: str[source]

Name used by Tower Unite internally

property position: XYZ | None[source]

World position

property rotation: XYZW | None[source]

Rotation quaternion

property scale: XYZ | None[source]

Local scale

set_connections(cons)[source]

Set all the connections attached to this object. Useful when resetting/overriding connections

Parameters:

cons (list[ItemConnectionObject]) – List of connections to attach onto this object

set_group_id(group_id)[source]

Deprecated since version 0.3.0: Assign to TowerObject.group_id instead

Parameters:

group_id (int)

set_meta_property(path, value)[source]

Sets property only the properties section

Parameters:
  • path (list[str] | str) – Either a list of string keys or a period-separated string representing the path to take through the dictionary. For example, “properties.ItemCustomName.Name.value” and [“properties”, “ItemCustomName”, “Name”, “value”]

  • value (Any) – Value to set

set_property(path, value)[source]

Sets property in both item and properties sections

Parameters:
  • path (list[str] | str) – Either a list of string keys or a period-separated string representing the path to take through the dictionary. For example, “properties.ItemCustomName.Name.value” and [“properties”, “ItemCustomName”, “Name”, “value”]

  • value (Any) – Value to set

ungroup()[source]

Clears the group info attached to this object, effectively un-grouping it

property url: str | None[source]
pytower.object.spec_keys(spec)[source]
Return type:

list[str]

Parameters:

spec (str)