Files
vgstation13/code/modules/atmos_automation/implementation/digital_valves.dm
clusterfack 147c5bd5a7 A process scheduler thing
Included:
-The process lists use |= instead of += due to the increased stability of the former against double additions.

-Atmospherics machinery is moved under the pipenet processing.

-Modified the atmospherics processes to return 1 when theyve done something, and 0 if they aint done jack shit. Then called scheck() if they return 1, possibly  reducing unnecessary scheck calls while still managing to smooth out the atmospherics processing.

-If a powernet happens to get rebuilt by either powernets or power machinery scheck() is also called
2015-05-08 01:15:19 -05:00

42 lines
1.1 KiB
Plaintext

/datum/automation/set_valve_state
name = "Digital Valve: Set Open/Closed"
var/valve=null
var/state=0
Export()
var/list/json = ..()
json["valve"]=valve
json["state"]=state
return json
Import(var/list/json)
..(json)
valve = json["valve"]
state = text2num(json["state"])
process()
if(valve)
parent.send_signal(list ("tag" = valve, "command"="valve_set","state"=state))
return 0
GetText()
return "Set digital valve <a href=\"?src=\ref[src];set_subject=1\">[fmtString(valve)]</a> to <a href=\"?src=\ref[src];set_state=1\">[state?"open":"closed"]</a>."
Topic(href,href_list)
if(href_list["set_state"])
state=!state
parent.updateUsrDialog()
return 1
if(href_list["set_subject"])
var/list/valves=list()
for(var/obj/machinery/atmospherics/binary/valve/digital/V in atmos_machines)
if(!isnull(V.id_tag) && V.frequency == parent.frequency)
valves|=V.id_tag
if(valves.len==0)
usr << "<span class='warning'>Unable to find any digital valves on this frequency.</span>"
return
valve = input("Select a valve:", "Sensor Data", valve) as null|anything in valves
parent.updateUsrDialog()
return 1