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

circuit_datatype

A circuit datatype. Used to determine the datatype of a port and also handle any additional behaviour.

Vars

abstractWhether this datatype should be loaded into the global circuit_datatypes list.
can_receive_fromThe datatypes that this datatype can receive from.
colorThe color of the port in the UI. Doesn't work with hex colours.
datatypeThe key. Used to identify the datatype. Should be a define.
datatype_flagsThe flags of the circuit datatype
is_extensiveWhether we should extensively convert this datatype, important for composite lists who may not have datatypes that need implicit conversions

Procs

can_receive_from_datatypeDetermines if a datatype is compatible with another port of a different type. Note: This is ALWAYS called on the input port, never on the output port. Inputs need to care about what types they're receiving, output ports don't have to care.
convert_valueReturns the value to be set for the port
convert_value_extensiveSimilar to convert value, however it doesn't get called by a port when a value is set. Useful for extensive conversions that may only need to be done for player inputs (e.g. lists)
datatype_ui_dataThe data to send to the UI attached to the port. Received by the type in FUNDAMENTAL_PORT_TYPES
get_datatypeUsed by composite datatypes. Returns a single datatype from the list if it exists by index.
get_datatypesUsed by composite datatypes. Returns all the datatypes that build this datatype up.
handle_manual_inputWhen an input is manually set by a player. This is where extra sanitizing can happen. Will still call convert_value()
is_compatibleDetermines if a port is compatible with this datatype. This WILL throw a runtime if it returns false. This is for sanity checking and it should not return false unless under extraordinary circumstances or people fail to write proper code.
on_gainCalled when the datatype is given to a port.
on_lossCalled when the datatype is removed from a port.

Var Details

abstract

Whether this datatype should be loaded into the global circuit_datatypes list.

can_receive_from

The datatypes that this datatype can receive from.

color

The color of the port in the UI. Doesn't work with hex colours.

datatype

The key. Used to identify the datatype. Should be a define.

datatype_flags

The flags of the circuit datatype

is_extensive

Whether we should extensively convert this datatype, important for composite lists who may not have datatypes that need implicit conversions

Proc Details

can_receive_from_datatype

Determines if a datatype is compatible with another port of a different type. Note: This is ALWAYS called on the input port, never on the output port. Inputs need to care about what types they're receiving, output ports don't have to care.

Arguments:

convert_value

Returns the value to be set for the port

Used for implicit conversions between outputs and inputs (e.g. number -> string) and applying/removing signals on inputs

convert_value_extensive

Similar to convert value, however it doesn't get called by a port when a value is set. Useful for extensive conversions that may only need to be done for player inputs (e.g. lists)

datatype_ui_data

The data to send to the UI attached to the port. Received by the type in FUNDAMENTAL_PORT_TYPES

Arguments:

get_datatype

Used by composite datatypes. Returns a single datatype from the list if it exists by index.

get_datatypes

Used by composite datatypes. Returns all the datatypes that build this datatype up.

handle_manual_input

When an input is manually set by a player. This is where extra sanitizing can happen. Will still call convert_value()

Arguments:

is_compatible

Determines if a port is compatible with this datatype. This WILL throw a runtime if it returns false. This is for sanity checking and it should not return false unless under extraordinary circumstances or people fail to write proper code.

Arguments:

on_gain

Called when the datatype is given to a port.

Arguments:

on_loss

Called when the datatype is removed from a port.

Arguments: