mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-18 03:26:31 +01:00
[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:
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* # Concatenate Component
|
||||
*
|
||||
* General string concatenation component. Puts strings together.
|
||||
*/
|
||||
/obj/item/circuit_component/concat
|
||||
display_name = "Concatenate"
|
||||
|
||||
/// The amount of input ports to have
|
||||
var/input_port_amount = 4
|
||||
|
||||
/// The result from the output
|
||||
var/datum/port/output/output
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
|
||||
|
||||
/obj/item/circuit_component/concat/Initialize()
|
||||
. = ..()
|
||||
for(var/port_id in 1 to input_port_amount)
|
||||
var/letter = ascii2text(text2ascii("A") + (port_id-1))
|
||||
add_input_port(letter, PORT_TYPE_STRING)
|
||||
|
||||
output = add_output_port("Output", PORT_TYPE_STRING)
|
||||
|
||||
/obj/item/circuit_component/concat/Destroy()
|
||||
output = null
|
||||
return ..()
|
||||
|
||||
/obj/item/circuit_component/concat/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
var/result = ""
|
||||
var/list/ports = input_ports.Copy()
|
||||
ports -= trigger_input
|
||||
|
||||
for(var/datum/port/input/input_port as anything in ports)
|
||||
var/value = input_port.input_value
|
||||
if(isnull(value))
|
||||
continue
|
||||
|
||||
result += "[value]"
|
||||
|
||||
output.set_output(result)
|
||||
|
||||
Reference in New Issue
Block a user