Files
Bubberstation/code/modules/wiremod/components/string/tostring.dm
Watermelon914 f92403f3ed 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.
2021-06-23 18:34:19 -03:00

46 lines
1.0 KiB
Plaintext

/**
* # To String Component
*
* Converts any value into a string
*/
/obj/item/circuit_component/tostring
display_name = "To String"
display_desc = "A component that converts its input to text."
/// 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
var/max_range = 5
/obj/item/circuit_component/tostring/Initialize()
. = ..()
input_port = add_input_port("Input", PORT_TYPE_ANY)
output = add_output_port("Output", PORT_TYPE_STRING)
/obj/item/circuit_component/tostring/Destroy()
input_port = null
output = null
return ..()
/obj/item/circuit_component/tostring/input_received(datum/port/input/port)
. = ..()
if(.)
return
var/input_value = input_port.input_value
if(isatom(input_value))
var/turf/location = get_turf(src)
var/atom/object = input_value
if(object.z != location.z || get_dist(location, object) > max_range)
output.set_output(PORT_TYPE_ATOM)
return
output.set_output("[input_value]")