Files
Bubberstation/code/modules/wiremod/components/math/logic.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

46 lines
1.0 KiB
Plaintext

/**
* # Logic Component
*
* General logic unit with AND OR capabilities
*/
/obj/item/circuit_component/compare/logic
display_name = "Logic"
display_desc = "A component with 'and' and 'or' capabilities."
/obj/item/circuit_component/compare/logic/populate_options()
var/static/component_options = list(
COMP_LOGIC_AND,
COMP_LOGIC_OR,
COMP_LOGIC_XOR,
)
options = component_options
/obj/item/circuit_component/compare/logic/do_comparisons(list/ports)
. = FALSE
// Used by XOR
var/total_ports = 0
var/total_true_ports = 0
for(var/datum/port/input/port as anything in ports)
if(isnull(port.input_value) && isnull(port.connected_port))
continue
total_ports += 1
switch(current_option)
if(COMP_LOGIC_AND)
if(!port.input_value)
return FALSE
. = TRUE
if(COMP_LOGIC_OR)
if(port.input_value)
return TRUE
if(COMP_LOGIC_XOR)
if(port.input_value)
. = TRUE
total_true_ports += 1
if(current_option == COMP_LOGIC_XOR)
if(total_ports == total_true_ports)
return FALSE
if(.)
return TRUE