Files
Bubberstation/code/modules/wiremod/components/math/comparison.dm
SkyratBot 5ab9aba9d4 [MIRROR] Added circuit component UI details, added multiplexer and allowed inserting components directly into shells. (#6479)
* Added circuit component UI details, added multiplexer and allowed inserting components directly into shells. (#59635)

Adds the multiplexer circuit component - en.wikipedia.org/wiki/Multiplexer
Circuit components can now be directly inserted into shells rather than having to take the integrated circuit out.
Special information can be accessed from components now through the "Info" button besides the eject button on a component.

* Added circuit component UI details, added multiplexer and allowed inserting components directly into shells.

Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com>
2021-06-23 22:50:59 +01:00

60 lines
1.7 KiB
Plaintext

/**
* # Comparison Component
*
* Compares two objects
*/
/obj/item/circuit_component/compare/comparison
display_name = "Comparison"
display_desc = "A component that compares two objects."
input_port_amount = 2
var/current_type = PORT_TYPE_ANY
/obj/item/circuit_component/compare/comparison/populate_options()
var/static/component_options = list(
COMP_COMPARISON_EQUAL,
COMP_COMPARISON_NOT_EQUAL,
COMP_COMPARISON_GREATER_THAN,
COMP_COMPARISON_LESS_THAN,
COMP_COMPARISON_GREATER_THAN_OR_EQUAL,
COMP_COMPARISON_LESS_THAN_OR_EQUAL,
)
options = component_options
/obj/item/circuit_component/compare/comparison/input_received(datum/port/input/port)
switch(current_option)
if(COMP_COMPARISON_EQUAL, COMP_COMPARISON_NOT_EQUAL)
if(current_type != PORT_TYPE_ANY)
current_type = PORT_TYPE_ANY
input_ports[1].set_datatype(PORT_TYPE_ANY)
input_ports[2].set_datatype(PORT_TYPE_ANY)
else
if(current_type != PORT_TYPE_NUMBER)
current_type = PORT_TYPE_NUMBER
input_ports[1].set_datatype(PORT_TYPE_NUMBER)
input_ports[2].set_datatype(PORT_TYPE_NUMBER)
return ..()
/obj/item/circuit_component/compare/comparison/do_comparisons(list/ports)
if(length(ports) < input_port_amount)
return FALSE
// Comparison component only compares the first two ports
var/input1 = input_ports[1].input_value
var/input2 = input_ports[2].input_value
switch(current_option)
if(COMP_COMPARISON_EQUAL)
return input1 == input2
if(COMP_COMPARISON_NOT_EQUAL)
return input1 != input2
if(COMP_COMPARISON_GREATER_THAN)
return input1 > input2
if(COMP_COMPARISON_GREATER_THAN_OR_EQUAL)
return input1 >= input2
if(COMP_COMPARISON_LESS_THAN)
return input1 < input2
if(COMP_COMPARISON_LESS_THAN_OR_EQUAL)
return input1 <= input2