[MIRROR] More circuit components. Restructures the circuit components folder to be more organised. (#6142)

* More circuit components. Restructures the circuit components folder to be more organised.

* Mirror!

Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com>
Co-authored-by: Funce <funce.973@gmail.com>
This commit is contained in:
SkyratBot
2021-06-05 17:15:43 +12:00
committed by GitHub
co-authored by Watermelon914 Funce
parent 6e52d05e2e
commit cc5cf407b0
42 changed files with 630 additions and 106 deletions
@@ -0,0 +1,33 @@
/**
* # Length Component
*
* Return the length of an input
*/
/obj/item/circuit_component/length
display_name = "Length"
/// The input port
var/datum/port/input/input_port
/// The result from the output
var/datum/port/output/output
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
/obj/item/circuit_component/length/Initialize()
. = ..()
input_port = add_input_port("Input", PORT_TYPE_ANY)
output = add_output_port("Length", PORT_TYPE_NUMBER)
/obj/item/circuit_component/length/Destroy()
input_port = null
output = null
return ..()
/obj/item/circuit_component/length/input_received(datum/port/input/port)
. = ..()
if(.)
return
output.set_output(length(input_port.input_value))