mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-17 05:03:28 +00:00
* Circuit component descriptions and module names are now visible to the naked eye. (#60545) * Circuit component descriptions and module names are now visible to the naked eye. Co-authored-by: Gurkenglas <gurkenglas@hotmail.de>
49 lines
1.1 KiB
Plaintext
49 lines
1.1 KiB
Plaintext
/**
|
|
* # Concat List Component
|
|
*
|
|
* Concatenates a list with a separator
|
|
*/
|
|
/obj/item/circuit_component/concat_list
|
|
display_name = "Concatenate List"
|
|
desc = "A component that joins up a list with a separator into a single string."
|
|
|
|
/// The input port
|
|
var/datum/port/input/list_port
|
|
|
|
/// The seperator
|
|
var/datum/port/input/separator
|
|
|
|
/// 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_list/Initialize()
|
|
. = ..()
|
|
list_port = add_input_port("List", PORT_TYPE_LIST)
|
|
separator = add_input_port("Seperator", PORT_TYPE_STRING)
|
|
|
|
output = add_output_port("Output", PORT_TYPE_STRING)
|
|
|
|
/obj/item/circuit_component/concat_list/input_received(datum/port/input/port)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
|
|
var/seperator = separator.input_value
|
|
if(!seperator)
|
|
return
|
|
|
|
var/list/list_input = list_port.input_value
|
|
if(!list_input)
|
|
return
|
|
|
|
var/list/text_list = list()
|
|
for(var/entry in list_input)
|
|
if(isatom(entry))
|
|
text_list += PORT_TYPE_ATOM
|
|
else
|
|
text_list += "[entry]"
|
|
|
|
output.set_output(text_list.Join(seperator))
|
|
|