/tg/ Station 13 - Modules - TypesVar Details - Proc Details

/datum

The absolute base class for everything

A datum instantiated has no physical world prescence, use an atom if you want something that actually lives in the world

Be very mindful about adding variables to this class, they are inherited by every single thing in the entire game, and so you can easily cause memory usage to rise a lot with careless use of variables at this level

Vars

active_timersActive timers with this datum as the target
comp_lookupAny datum registered to receive signals from this datum is in this list Lazy associated list in the structure of signal:registree/list of registrees
datum_componentsComponents attached to this datum Lazy associated list in the structure of type:component/list of components
datum_flagsDatum level flags
gc_destroyedTick count time when this object was destroyed.
signal_enabledIs this datum capable of sending signals? Set to true when a signal has been registered
signal_procsLazy associated list in the structure of signals:proctype that are run when the datum receives that signal
status_traitsStatus traits attached to this datum
weak_referenceA weak reference to another datum

Procs

DestroyDefault implementation of clean-up code.
GetComponentReturn any component assigned to this datum of the given type This will throw an error if it's possible to have more than one component of that type on the parent
GetComponentsGet all components of a given type that are attached to this datum
GetExactComponentReturn any component assigned to this datum of the exact given type This will throw an error if it's possible to have more than one component of that type on the parent
LoadComponentGet existing component of type, or create it and return a reference to it
RegisterSignalRegister to listen for a signal from the passed in target
TakeComponentTransfer this component to another parent
TopicCalled when a href for this datum is clicked
TransferComponentsTransfer all components to target
UnregisterSignalStop listening to a given signal from target
_AddComponentCreates an instance of new_type in the datum and attaches to it as parent Sends the COMSIG_COMPONENT_ADDED signal to the datum Returns the component that was created. Or the old component in a dupe situation where COMPONENT_DUPE_UNIQUE was set If this tries to add an component to an incompatible type, the component will be deleted and the result will be null. This is very unperformant, try not to do it Properly handles duplicate situations based on the dupe_mode var
_AddElementFinds the singleton for the element type given and attaches it to src
_RemoveElementFinds the singleton for the element type given and detaches it from src You only need additional arguments beyond the type if you're using ELEMENT_BESPOKE
_SendSignalInternal proc to handle most all of the signaling procedure Will runtime if used on datums with an empty component list Use the SEND_SIGNAL define instead
deserialize_jsonDeserializes from JSON. Does not parse type.
deserialize_listAccepts a LIST from deserialize_datum. Should return src or another datum.
serialize_jsonSerializes into JSON. Does not encode type.
serialize_listReturn a LIST for serialize_datum to encode! Not the actual json!
ui_actpublic
ui_base_htmlpublic
ui_closepublic
ui_datapublic
ui_hostprivate
ui_interacttgui external
ui_static_datapublic
ui_statustgui states
update_static_datapublic

Var Details

active_timers

Active timers with this datum as the target

comp_lookup

Any datum registered to receive signals from this datum is in this list Lazy associated list in the structure of signal:registree/list of registrees

datum_components

Components attached to this datum Lazy associated list in the structure of type:component/list of components

datum_flags

Datum level flags

gc_destroyed

Tick count time when this object was destroyed.

If this is non zero then the object has been garbage collected and is awaiting either a hard del by the GC subsystme, or to be autocollected (if it has no references)

signal_enabled

Is this datum capable of sending signals? Set to true when a signal has been registered

signal_procs

Lazy associated list in the structure of signals:proctype that are run when the datum receives that signal

status_traits

Status traits attached to this datum

weak_reference

A weak reference to another datum

Proc Details

Destroy

Default implementation of clean-up code.

This should be overridden to remove all references pointing to the object being destroyed, if you do override it, make sure to call the parent and return it's return value by default

Return an appropriate QDEL_HINT to modify handling of your deletion; in most cases this is QDEL_HINT_QUEUE.

The base case is responsible for doing the following

Returns QDEL_HINT_QUEUE

GetComponent

Return any component assigned to this datum of the given type This will throw an error if it's possible to have more than one component of that type on the parent

Arguments:

GetComponents

Get all components of a given type that are attached to this datum

Arguments:

GetExactComponent

Return any component assigned to this datum of the exact given type This will throw an error if it's possible to have more than one component of that type on the parent

Arguments:

LoadComponent

Get existing component of type, or create it and return a reference to it

Use this if the item needs to exist at the time of this call, but may not have been created before now

Arguments:

RegisterSignal

Register to listen for a signal from the passed in target

This sets up a listening relationship such that when the target object emits a signal the source datum this proc is called upon, will recieve a callback to the given proctype Return values from procs registered must be a bitfield

Arguments:

TakeComponent

Transfer this component to another parent

Component is taken from source datum

Arguments:

Topic

Called when a href for this datum is clicked

Sends a COMSIG_TOPIC signal

TransferComponents

Transfer all components to target

All components from source datum are taken

Arguments:

UnregisterSignal

Stop listening to a given signal from target

Breaks the relationship between target and source datum, removing the callback when the signal fires Doesn't care if a registration exists or not

Arguments:

_AddComponent

Creates an instance of new_type in the datum and attaches to it as parent Sends the COMSIG_COMPONENT_ADDED signal to the datum Returns the component that was created. Or the old component in a dupe situation where COMPONENT_DUPE_UNIQUE was set If this tries to add an component to an incompatible type, the component will be deleted and the result will be null. This is very unperformant, try not to do it Properly handles duplicate situations based on the dupe_mode var

_AddElement

Finds the singleton for the element type given and attaches it to src

_RemoveElement

Finds the singleton for the element type given and detaches it from src You only need additional arguments beyond the type if you're using ELEMENT_BESPOKE

_SendSignal

Internal proc to handle most all of the signaling procedure Will runtime if used on datums with an empty component list Use the SEND_SIGNAL define instead

deserialize_json

Deserializes from JSON. Does not parse type.

deserialize_list

Accepts a LIST from deserialize_datum. Should return src or another datum.

serialize_json

Serializes into JSON. Does not encode type.

serialize_list

Return a LIST for serialize_datum to encode! Not the actual json!

ui_act

public

Called on a UI when the UI receieves a href. Think of this as Topic().

required action string The action/button that has been invoked by the user. required params list A list of parameters attached to the button.

return bool If the UI should be updated or not.

ui_base_html

public

Called on an object when a tgui object is being created, allowing you to customise the html For example: inserting a custom stylesheet that you need in the head

For this purpose, some tags are available in the html, to be parsed out with replacetext (customheadhtml) - Additions to the head tag

required html the html base text

ui_close

public

Called on a UI's object when the UI is closed, not to be confused with client/verb/uiclose(), which closes the ui window

ui_data

public

Data to be sent to the UI. This must be implemented for a UI to work.

required user mob The mob interacting with the UI.

return list Data to be sent to the UI.

ui_host

private

The UI's host object (usually src_object). This allows modules/datums to have the UI attached to them, and be a part of another object.

ui_interact

tgui external

Contains all external tgui declarations.

public

Used to open and update UIs. If this proc is not implemented properly, the UI will not update correctly.

required user mob The mob who opened/is using the UI. optional ui_key string The ui_key of the UI. optional ui datum/tgui The UI to be updated, if it exists. optional force_open bool If the UI should be re-opened instead of updated. optional master_ui datum/tgui The parent UI. optional state datum/ui_state The state used to determine status.

ui_static_data

public

Static Data to be sent to the UI. Static data differs from normal data in that it's large data that should be sent infrequently This is implemented optionally for heavy uis that would be sending a lot of redundant data frequently. Gets squished into one object on the frontend side, but the static part is cached.

required user mob The mob interacting with the UI.

return list Statuic Data to be sent to the UI.

ui_status

tgui states

Base state and helpers for states. Just does some sanity checks, implement a state for in-depth checks.

public

Checks the UI state for a mob.

required user mob The mob who opened/is using the UI. required state datum/ui_state The state to check.

return UI_state The state of the UI.

update_static_data

public

Forces an update on static data. Should be done manually whenever something happens to change static data.

required user the mob currently interacting with the ui optional ui ui to be updated optional ui_key ui key of ui to be updated