mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-19 20:15:47 +01:00
[MIRROR] Adds USB to arrest consoles. Adds list circuit components. (#6593)
* Adds USB to arrest consoles. Adds list circuit components. (#59850) Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com> Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com> * Adds USB to arrest consoles. Adds list circuit components. Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com> Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
/**
|
||||
* # Index Component
|
||||
*
|
||||
* Return the index of a list
|
||||
*/
|
||||
/obj/item/circuit_component/index
|
||||
display_name = "Index List"
|
||||
display_desc = "A component that returns the value of a list at a given index."
|
||||
|
||||
/// The input port
|
||||
var/datum/port/input/list_port
|
||||
var/datum/port/input/index_port
|
||||
|
||||
/// The result from the output
|
||||
var/datum/port/output/output
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
|
||||
|
||||
/obj/item/circuit_component/index/Initialize()
|
||||
. = ..()
|
||||
index_port = add_input_port("Index", PORT_TYPE_ANY)
|
||||
list_port = add_input_port("List", PORT_TYPE_LIST)
|
||||
|
||||
output = add_output_port("Value", PORT_TYPE_ANY)
|
||||
|
||||
/obj/item/circuit_component/index/Destroy()
|
||||
list_port = null
|
||||
index_port = null
|
||||
output = null
|
||||
return ..()
|
||||
|
||||
/obj/item/circuit_component/index/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
var/index = index_port.input_value
|
||||
var/list/list_input = list_port.input_value
|
||||
|
||||
if(!islist(list_input) || !index)
|
||||
output.set_output(null)
|
||||
return
|
||||
|
||||
if(isnum(index) && (index < 1 || index > length(list_input)))
|
||||
output.set_output(null)
|
||||
return
|
||||
|
||||
output.set_output(list_input[index])
|
||||
|
||||
Reference in New Issue
Block a user