mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-21 04:57:57 +01:00
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>
This commit is contained in:
@@ -24,11 +24,7 @@
|
||||
|
||||
/obj/item/circuit_component/light/get_ui_notices()
|
||||
. = ..()
|
||||
. += list(list(
|
||||
"icon" = "lightbulb",
|
||||
"content" = "Maximum Brightness: [max_power]",
|
||||
"color" = "orange"
|
||||
))
|
||||
. += create_ui_notice("Maximum Brightness: [max_power]", "orange", "lightbulb")
|
||||
|
||||
/obj/item/circuit_component/light/Initialize()
|
||||
. = ..()
|
||||
|
||||
@@ -19,11 +19,7 @@
|
||||
|
||||
/obj/item/circuit_component/speech/get_ui_notices()
|
||||
. = ..()
|
||||
. += list(list(
|
||||
"icon" = "stopwatch",
|
||||
"content" = "Speech Cooldown: [DisplayTimeText(speech_cooldown)]",
|
||||
"color" = "orange",
|
||||
))
|
||||
. += create_ui_notice("Speech Cooldown: [DisplayTimeText(speech_cooldown)]", "orange", "stopwatch")
|
||||
|
||||
/obj/item/circuit_component/speech/Initialize()
|
||||
. = ..()
|
||||
|
||||
@@ -26,11 +26,7 @@
|
||||
|
||||
/obj/item/circuit_component/direction/get_ui_notices()
|
||||
. = ..()
|
||||
. += list(list(
|
||||
"icon" = "info",
|
||||
"content" = "Maximum Range: [max_range] tiles",
|
||||
"color" = "orange",
|
||||
))
|
||||
. += create_ui_notice("Maximum Range: [max_range] tiles", "orange", "info")
|
||||
|
||||
/obj/item/circuit_component/direction/Initialize()
|
||||
. = ..()
|
||||
|
||||
@@ -27,11 +27,7 @@
|
||||
|
||||
/obj/item/circuit_component/health/get_ui_notices()
|
||||
. = ..()
|
||||
. += list(list(
|
||||
"icon" = "info",
|
||||
"content" = "Maximum Range: [max_range] tiles",
|
||||
"color" = "orange",
|
||||
))
|
||||
. += create_ui_notice("Maximum Range: [max_range] tiles", "orange", "info")
|
||||
|
||||
/obj/item/circuit_component/health/Initialize()
|
||||
. = ..()
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* # Concat List Component
|
||||
*
|
||||
* Concatenates a list with a separator
|
||||
*/
|
||||
/obj/item/circuit_component/concat_list
|
||||
display_name = "Concatenate List"
|
||||
display_desc = "A component that joins up a list with a separator into a single string."
|
||||
|
||||
/// The input port
|
||||
var/datum/port/input/list_port
|
||||
|
||||
/// The seperator
|
||||
var/datum/port/input/separator
|
||||
|
||||
/// The result from the output
|
||||
var/datum/port/output/output
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
|
||||
|
||||
/obj/item/circuit_component/concat_list/Initialize()
|
||||
. = ..()
|
||||
list_port = add_input_port("List", PORT_TYPE_LIST)
|
||||
separator = add_input_port("Seperator", PORT_TYPE_STRING)
|
||||
|
||||
output = add_output_port("Output", PORT_TYPE_STRING)
|
||||
|
||||
/obj/item/circuit_component/concat_list/Destroy()
|
||||
list_port = null
|
||||
separator = null
|
||||
output = null
|
||||
return ..()
|
||||
|
||||
/obj/item/circuit_component/concat_list/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
var/seperator = separator.input_value
|
||||
if(!seperator)
|
||||
return
|
||||
|
||||
var/list/list_input = list_port.input_value
|
||||
if(!list_input)
|
||||
return
|
||||
|
||||
var/list/text_list = list()
|
||||
for(var/entry in list_input)
|
||||
if(isatom(entry))
|
||||
text_list += PORT_TYPE_ATOM
|
||||
else
|
||||
text_list += "[entry]"
|
||||
|
||||
output.set_output(text_list.Join(seperator))
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* # Get Column Component
|
||||
*
|
||||
* Gets the column of a table and returns it as a regular list.
|
||||
*/
|
||||
/obj/item/circuit_component/get_column
|
||||
display_name = "Get Column"
|
||||
display_desc = "Gets the column of a table and returns it as a regular list."
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
|
||||
|
||||
/// The list to perform the filter on
|
||||
var/datum/port/input/received_table
|
||||
|
||||
/// The name of the column to check
|
||||
var/datum/port/input/column_name
|
||||
|
||||
/// The filtered list
|
||||
var/datum/port/output/output_list
|
||||
|
||||
/obj/item/circuit_component/get_column/Initialize()
|
||||
. = ..()
|
||||
received_table = add_input_port("Input", PORT_TYPE_TABLE)
|
||||
column_name = add_input_port("Column Name", PORT_TYPE_STRING)
|
||||
output_list = add_output_port("Output", PORT_TYPE_LIST)
|
||||
|
||||
/obj/item/circuit_component/get_column/Destroy()
|
||||
received_table = null
|
||||
column_name = null
|
||||
output_list = null
|
||||
return ..()
|
||||
|
||||
/obj/item/circuit_component/get_column/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
var/list/input_list = received_table.input_value
|
||||
if(!islist(input_list) || isnum(column_name.input_value))
|
||||
return
|
||||
|
||||
var/list/new_list = list()
|
||||
for(var/list/entry in input_list)
|
||||
var/anything = entry[column_name.input_value]
|
||||
if(islist(anything))
|
||||
continue
|
||||
new_list += anything
|
||||
|
||||
output_list.set_output(new_list)
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* # Index Table Component
|
||||
*
|
||||
* Gets the row of a table using the index inputted. Will return no value if the index is invalid or a proper table is not returned.
|
||||
*/
|
||||
/obj/item/circuit_component/index_table
|
||||
display_name = "Index Table"
|
||||
display_desc = "Gets the row of a table using the index inputted. Will return no value if the index is invalid or a proper table is not returned."
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
|
||||
|
||||
/// The list to perform the filter on
|
||||
var/datum/port/input/received_table
|
||||
|
||||
/// The target index
|
||||
var/datum/port/input/target_index
|
||||
|
||||
/// The filtered list
|
||||
var/datum/port/output/output_list
|
||||
|
||||
/obj/item/circuit_component/index_table/Initialize()
|
||||
. = ..()
|
||||
received_table = add_input_port("Input", PORT_TYPE_TABLE)
|
||||
target_index = add_input_port("Index", PORT_TYPE_NUMBER)
|
||||
|
||||
output_list = add_output_port("Output", PORT_TYPE_TABLE)
|
||||
|
||||
/obj/item/circuit_component/index_table/Destroy()
|
||||
received_table = null
|
||||
target_index = null
|
||||
output_list = null
|
||||
return ..()
|
||||
|
||||
/obj/item/circuit_component/index_table/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
var/list/target_list = received_table.input_value
|
||||
if(!islist(target_list) || !length(target_list))
|
||||
output_list.set_output(null)
|
||||
return
|
||||
|
||||
var/index = target_index.input_value
|
||||
if(index < 1 || index > length(target_list))
|
||||
output_list.set_output(null)
|
||||
return
|
||||
|
||||
output_list.set_output(target_list[index])
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* # Select Component
|
||||
*
|
||||
* Selects a list from a list of lists by a specific column. Used only by USBs for communications to and from computers with lists of varying sizes.
|
||||
*/
|
||||
/obj/item/circuit_component/select
|
||||
display_name = "Select Query"
|
||||
display_desc = "A component used with USB cables that can perform select queries on a list based on the column name selected. The values are then compared with the comparison input."
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
|
||||
|
||||
/// The list to perform the filter on
|
||||
var/datum/port/input/received_table
|
||||
|
||||
/// The name of the column to check
|
||||
var/datum/port/input/column_name
|
||||
|
||||
/// The input to compare with
|
||||
var/datum/port/input/comparison_input
|
||||
|
||||
/// The filtered list
|
||||
var/datum/port/output/filtered_table
|
||||
|
||||
var/current_type = PORT_TYPE_ANY
|
||||
|
||||
/obj/item/circuit_component/select/populate_options()
|
||||
var/static/component_options = list(
|
||||
COMP_COMPARISON_EQUAL,
|
||||
COMP_COMPARISON_NOT_EQUAL,
|
||||
COMP_COMPARISON_GREATER_THAN,
|
||||
COMP_COMPARISON_LESS_THAN,
|
||||
COMP_COMPARISON_GREATER_THAN_OR_EQUAL,
|
||||
COMP_COMPARISON_LESS_THAN_OR_EQUAL,
|
||||
)
|
||||
options = component_options
|
||||
|
||||
/obj/item/circuit_component/select/Initialize()
|
||||
. = ..()
|
||||
received_table = add_input_port("Input", PORT_TYPE_TABLE)
|
||||
column_name = add_input_port("Column Name", PORT_TYPE_STRING)
|
||||
comparison_input = add_input_port("Comparison Input", PORT_TYPE_ANY)
|
||||
|
||||
filtered_table = add_output_port("Output", PORT_TYPE_TABLE)
|
||||
|
||||
/obj/item/circuit_component/select/Destroy()
|
||||
received_table = null
|
||||
column_name = null
|
||||
comparison_input = null
|
||||
filtered_table = null
|
||||
return ..()
|
||||
|
||||
/obj/item/circuit_component/select/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
switch(current_option)
|
||||
if(COMP_COMPARISON_EQUAL, COMP_COMPARISON_NOT_EQUAL)
|
||||
if(current_type != PORT_TYPE_ANY)
|
||||
current_type = PORT_TYPE_ANY
|
||||
comparison_input.set_datatype(PORT_TYPE_ANY)
|
||||
else
|
||||
if(current_type != PORT_TYPE_NUMBER)
|
||||
current_type = PORT_TYPE_NUMBER
|
||||
comparison_input.set_datatype(PORT_TYPE_NUMBER)
|
||||
|
||||
if(.)
|
||||
return
|
||||
|
||||
var/list/input_list = received_table.input_value
|
||||
if(!islist(input_list) || isnum(column_name.input_value))
|
||||
return
|
||||
|
||||
var/comparison_value = comparison_input.input_value
|
||||
var/list/new_list = list()
|
||||
for(var/list/entry in input_list)
|
||||
var/anything = entry[column_name.input_value]
|
||||
if(islist(anything))
|
||||
continue
|
||||
if(current_option != COMP_COMPARISON_EQUAL && current_option != COMP_COMPARISON_NOT_EQUAL && !isnum(anything))
|
||||
continue
|
||||
var/add_to_list = FALSE
|
||||
switch(current_option)
|
||||
if(COMP_COMPARISON_EQUAL)
|
||||
add_to_list = anything == comparison_value
|
||||
if(COMP_COMPARISON_NOT_EQUAL)
|
||||
add_to_list = anything != comparison_value
|
||||
if(COMP_COMPARISON_GREATER_THAN)
|
||||
add_to_list = anything > comparison_value
|
||||
if(COMP_COMPARISON_GREATER_THAN_OR_EQUAL)
|
||||
add_to_list = anything >= comparison_value
|
||||
if(COMP_COMPARISON_LESS_THAN)
|
||||
add_to_list = anything < comparison_value
|
||||
if(COMP_COMPARISON_LESS_THAN_OR_EQUAL)
|
||||
add_to_list = anything <= comparison_value
|
||||
|
||||
if(add_to_list)
|
||||
new_list += list(entry)
|
||||
|
||||
filtered_table.set_output(new_list)
|
||||
@@ -15,11 +15,7 @@
|
||||
|
||||
/obj/item/circuit_component/clock/get_ui_notices()
|
||||
. = ..()
|
||||
. += list(list(
|
||||
"icon" = "clock",
|
||||
"content" = "Clock Interval: [DisplayTimeText(COMP_CLOCK_DELAY)]",
|
||||
"color" = "orange",
|
||||
))
|
||||
. += create_ui_notice("Clock Interval: [DisplayTimeText(COMP_CLOCK_DELAY)]", "orange", "clock")
|
||||
|
||||
/obj/item/circuit_component/clock/Initialize()
|
||||
. = ..()
|
||||
|
||||
@@ -39,6 +39,6 @@
|
||||
var/delay = delay_amount.input_value
|
||||
if(delay > COMP_DELAY_MIN_VALUE)
|
||||
// Convert delay into deciseconds
|
||||
addtimer(CALLBACK(output, /datum/port/output.proc/set_output, trigger.input_value), delay*10, timer_subsystem =SScircuit_component)
|
||||
addtimer(CALLBACK(output, /datum/port/output.proc/set_output, trigger.input_value), delay*10)
|
||||
else
|
||||
output.set_output(trigger.input_value)
|
||||
|
||||
Reference in New Issue
Block a user