-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathpressuresensor.dm
33 lines (29 loc) · 955 Bytes
/
pressuresensor.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
33
/**
* # Pressure Sensor
*
* Returns the pressure of the tile
*/
/obj/item/circuit_component/pressuresensor
display_name = "Pressure Sensor"
desc = "Outputs the current pressure of the tile"
category = "Sensor"
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/populate_ports()
result = add_output_port("Result", PORT_TYPE_NUMBER)
/obj/item/circuit_component/pressuresensor/input_received(datum/port/input/port)
//Get current turf
var/turf/location = get_location()
if(!location)
result.set_output(null)
return
//Get environment info
var/datum/gas_mixture/environment = location.unsafe_return_air()
var/total_moles = environment.total_moles
var/pressure = environment.returnPressure()
if(total_moles)
//If there's atmos, return pressure
result.set_output(round(pressure,1))
else
result.set_output(0)