mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-14 11:42:27 +00:00
* 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>
33 lines
1018 B
Plaintext
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
|