-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathlist_remove.dm
32 lines (26 loc) · 1018 Bytes
/
list_remove.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* # 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