circuit_datatype

A circuit datatype. Used to determine the datatype of a port and also handle any additional behaviour.
Vars | |
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 |
Procs | |
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. |
convert_value | Returns the value to be set for the port |
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 |
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() |
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. |
on_gain | Called when the datatype is given to a port. |
on_loss | Called 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:
- datatype_to_check - The datatype to check
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:
- port - The port sending the data.
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:
- port - The port sending the data.
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:
- port - The port to check if it is compatible.
on_gain
Called when the datatype is given to a port.
Arguments:
- gained_port - The gained port.
on_loss
Called when the datatype is removed from a port.
Arguments:
- lost_port - The removed port.