Files
Bubberstation/code/modules/wiremod/components/list/list_remove.dm
SkyratBot 4f58adba08 [MIRROR] Adds basic list manipulation and fixes some performance issues with lists in integrated circuits [MDB IGNORE] (#11273)
* Adds basic list manipulation and fixes some performance issues with lists in integrated circuits (#64541)

Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com>

* Adds basic list manipulation and fixes some performance issues with lists in integrated circuits

Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com>
Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com>
2022-02-06 14:05:37 +00:00

33 lines
1018 B
Plaintext

/**
* # List Remove Component
*
* Removes an element to a list.
*/
/obj/item/circuit_component/variable/list/listremove
display_name = "List Remove"
desc = "Removes an element from a list variable."
category = "List"
/// Element to remove to the list
var/datum/port/input/to_remove
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
/obj/item/circuit_component/variable/list/listremove/populate_ports()
to_remove = add_input_port("To Remove", PORT_TYPE_ANY)
/obj/item/circuit_component/variable/list/listremove/pre_input_received(datum/port/input/port)
. = ..()
if(current_variable)
to_remove.set_datatype(current_variable.datatype_handler.get_datatype(1))
/obj/item/circuit_component/variable/list/listremove/input_received(datum/port/input/port, list/return_values)
if(!current_variable)
return
var/list/info = current_variable.value
var/value_to_remove = to_remove.value
if(isdatum(value_to_remove))
value_to_remove = WEAKREF(value_to_remove)
info -= value_to_remove