mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 21:18:37 +01:00
Fixes bugs with admin circuits, expands upon some admin circuit components and fixes duplicator runtiming when a port doesn't exist. (#61948)
Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com>
This commit is contained in:
co-authored by
Watermelon914
parent
9211ddbe31
commit
0ebf4891ad
@@ -8,6 +8,9 @@
|
||||
desc = "A component that gets a variable on an object."
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL|CIRCUIT_FLAG_ADMIN
|
||||
|
||||
/// Whether to grab a global variable or a variable from this entity.
|
||||
var/datum/port/input/option/getvar_options
|
||||
|
||||
/// Entity to get variable of
|
||||
var/datum/port/input/entity
|
||||
|
||||
@@ -21,21 +24,30 @@
|
||||
var/datum/port/output/output_value
|
||||
|
||||
/obj/item/circuit_component/get_variable/populate_options()
|
||||
getvar_options = add_option_port("Variable Options", list("Object", "Global"))
|
||||
expected_output_type = add_option_port("Expected Output Type", GLOB.wiremod_fundamental_types)
|
||||
|
||||
/obj/item/circuit_component/get_variable/populate_ports()
|
||||
entity = add_input_port("Target", PORT_TYPE_DATUM)
|
||||
variable_name = add_input_port("Variable Name", PORT_TYPE_STRING)
|
||||
|
||||
output_value = add_output_port("Output Value", PORT_TYPE_ANY)
|
||||
variable_name = add_input_port("Variable Name", PORT_TYPE_STRING, order = 2)
|
||||
output_value = add_output_port("Output Value", PORT_TYPE_ANY, order = 2)
|
||||
|
||||
/obj/item/circuit_component/get_variable/pre_input_received(datum/port/input/port)
|
||||
if(port == getvar_options)
|
||||
remove_input_port(entity)
|
||||
entity = null
|
||||
if(getvar_options.value == "Object")
|
||||
entity = add_input_port("Target", PORT_TYPE_DATUM)
|
||||
|
||||
if(port == expected_output_type)
|
||||
if(output_value.datatype != expected_output_type.value)
|
||||
output_value.set_datatype(expected_output_type.value)
|
||||
|
||||
/obj/item/circuit_component/get_variable/input_received(datum/port/input/port)
|
||||
var/atom/object = entity.value
|
||||
var/atom/object = entity?.value
|
||||
if(getvar_options.value == "Global")
|
||||
object = GLOB
|
||||
|
||||
var/var_name = variable_name.value
|
||||
if(!var_name || !object)
|
||||
output_value.set_output(null)
|
||||
|
||||
Reference in New Issue
Block a user