diff --git a/code/modules/research/designs/wiremod_designs.dm b/code/modules/research/designs/wiremod_designs.dm index 1f3cb9c2245..5dcbd975e27 100644 --- a/code/modules/research/designs/wiremod_designs.dm +++ b/code/modules/research/designs/wiremod_designs.dm @@ -213,6 +213,16 @@ id = "comp_select_query" build_path = /obj/item/circuit_component/select +/datum/design/component/tempsensor + name = "Temperature Sensor" + id = "comp_tempsensor" + build_path = /obj/item/circuit_component/tempsensor + +/datum/design/component/pressuresensor + name = "Pressure Sensor" + id = "comp_pressuresensor" + build_path = /obj/item/circuit_component/pressuresensor + /datum/design/compact_remote_shell name = "Compact Remote Shell" desc = "A handheld shell with one big button." diff --git a/code/modules/research/techweb/all_nodes.dm b/code/modules/research/techweb/all_nodes.dm index e502923ddaa..4f84f54036e 100644 --- a/code/modules/research/techweb/all_nodes.dm +++ b/code/modules/research/techweb/all_nodes.dm @@ -214,6 +214,7 @@ "comp_mmi", "comp_multiplexer", "comp_not", + "comp_pressuresensor", "comp_radio", "comp_ram", "comp_random", @@ -225,6 +226,7 @@ "comp_speech", "comp_split", "comp_string_contains", + "comp_tempsensor", "comp_textcase", "comp_tostring", "comp_typecheck", diff --git a/code/modules/wiremod/components/sensors/pressuresensor.dm b/code/modules/wiremod/components/sensors/pressuresensor.dm new file mode 100644 index 00000000000..2faf6ae972e --- /dev/null +++ b/code/modules/wiremod/components/sensors/pressuresensor.dm @@ -0,0 +1,40 @@ +/** + * # Pressure Sensor + * + * Returns the pressure of the tile + */ +/obj/item/circuit_component/pressuresensor + display_name = "Pressure Sensor" + display_desc = "Outputs the current pressure of the tile" + + circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL + + /// The result from the output + var/datum/port/output/result + +/obj/item/circuit_component/pressuresensor/Initialize() + . = ..() + result = add_output_port("Result", PORT_TYPE_NUMBER) + +/obj/item/circuit_component/tempsensor/Destroy() + result = null + return ..() + +/obj/item/circuit_component/pressuresensor/input_received(datum/port/input/port) + . = ..() + if(.) + return + //Get current turf + var/turf/location = get_turf(src) + if(!location) + result.set_output(null) + return + //Get environment info + var/datum/gas_mixture/environment = location.return_air() + var/total_moles = environment.total_moles() + var/pressure = environment.return_pressure() + if(total_moles) + //If there's atmos, return pressure + result.set_output(round(pressure,1)) + else + result.set_output(0) diff --git a/code/modules/wiremod/components/sensors/tempsensor.dm b/code/modules/wiremod/components/sensors/tempsensor.dm new file mode 100644 index 00000000000..6c40c1dc76a --- /dev/null +++ b/code/modules/wiremod/components/sensors/tempsensor.dm @@ -0,0 +1,40 @@ +/** + * # Temperature Sensor + * + * Returns the temperature of the tile + */ +/obj/item/circuit_component/tempsensor + display_name = "Temperature Sensor" + display_desc = "Outputs the current temperature of the tile" + + circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL + + /// The result from the output + var/datum/port/output/result + +/obj/item/circuit_component/tempsensor/Initialize() + . = ..() + result = add_output_port("Result", PORT_TYPE_NUMBER) + +/obj/item/circuit_component/tempsensor/Destroy() + result = null + return ..() + +/obj/item/circuit_component/tempsensor/input_received(datum/port/input/port) + . = ..() + if(.) + return + //Get current turf + var/turf/location = get_turf(src) + if(!location) + result.set_output(null) + return + //Get environment info + var/datum/gas_mixture/environment = location.return_air() + var/total_moles = environment.total_moles() + if(total_moles) + //If there's atmos, return temperature + result.set_output(round(environment.temperature,1)) + else + result.set_output(0) + diff --git a/tgstation.dme b/tgstation.dme index f07bed38dc9..2d5e040f3bb 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -3601,6 +3601,8 @@ #include "code\modules\wiremod\components\math\logic.dm" #include "code\modules\wiremod\components\math\not.dm" #include "code\modules\wiremod\components\math\random.dm" +#include "code\modules\wiremod\components\sensors\pressuresensor.dm" +#include "code\modules\wiremod\components\sensors\tempsensor.dm" #include "code\modules\wiremod\components\string\concat.dm" #include "code\modules\wiremod\components\string\contains.dm" #include "code\modules\wiremod\components\string\textcase.dm"