Added remote APC control from power_monitor computers.

Fixed a bug where APCs would recharge when main breakers were off.
This commit is contained in:
hobnob13
2008-04-26 00:26:39 +00:00
parent 9a34819c0c
commit 1fb903dc70
3 changed files with 60 additions and 17 deletions
+2
View File
@@ -342,6 +342,8 @@ obj/machinery/power/apc
area.power_light = 0
area.power_equip = 0
area.power_environ = 0
chargecount = 0 // H9.6 FIX: If breaker is off, stop charging
charging = 0
area.power_change()
+56 -6
View File
@@ -1,7 +1,7 @@
/*
* Power Monitor - reports the available power, load, and status of APCs on the same power network.
*
* TODO: Make the power monitor also able to remote-control APCs (with sufficient ID access) to shut down things remotely.
* Also allows (limited) remote control of APCs on same network
*/
obj/machinery/power/monitor
@@ -10,6 +10,10 @@ obj/machinery/power/monitor
icon_state = "power_computer"
density = 1
anchored = 1
var
control = 0 // true if remote APC control is enabled
access = "4000/2030/3004" // ID card access levels needed to enable remote control
allowed = "Systems" // ID card job assignment needed to enable remote control
// Attack with hand, show report window
@@ -22,6 +26,23 @@ obj/machinery/power/monitor
interact(user)
// Attack with item
// If ID card, check access and enable/disable remote APC control
attackby(obj/item/weapon/W, mob/user)
if(stat & (BROKEN|NOPOWER))
return
if (istype(W, /obj/item/weapon/card/id) ) // trying to toggle remote control with an ID card
var/obj/item/weapon/card/id/I = W
if (I.check_access(access, allowed))
control = !control
user << "You [ control ? "enable" : "disable"] remote APC control."
else
user << "\red Access denied."
else
attack_hand(user) // otherwise interact as usual
// Show the interaction window to the user
proc/interact(mob/user)
@@ -52,7 +73,12 @@ obj/machinery/power/monitor
if(L.len > 0)
t += "Area Eqp./Lgt./Env. Load Cell<HR>"
if(control)
t += "<I><BIG>(Swipe ID card to disable remote control.)</BIG></I><BR>"
else
t += "<I><BIG>(Swipe ID card to enable remote control.)</BIG></I><BR>"
t += "Area Brkr./Eqp./Lgt./Env. Load Cell<HR>"
var/list/S = list(" Off","AOff"," On", " AOn")
var/list/chg = list("N","C","F")
@@ -60,23 +86,47 @@ obj/machinery/power/monitor
for(var/obj/machinery/power/apc/A in L)
t += copytext(add_tspace(A.area.name, 30), 1, 30)
if(control)
t += " (<A href='?src=\ref[src];apc=\ref[A];breaker=1'>[A.operating? " On" : "Off"]</A>)"
else
t += " ([A.operating? "On " : "Off"])"
t += " [S[A.equipment+1]] [S[A.lighting+1]] [S[A.environ+1]] [add_lspace(A.lastused_total, 6)] [A.cell ? "[add_lspace(round(A.cell.percent()), 3)]% [chg[A.charging+1]]" : " N/C"]<BR>"
t += "</FONT></PRE>"
t += "<BR><HR><A href='?src=\ref[src];close=1'>Close</A></TT>"
user << browse(t, "window=powcomp;size=420x700")
user << browse(t, "window=powcomp;size=450x740")
// Handle topic links from the interaction window (close only at the moment)
// Handle topic links from the interaction window
Topic(href, href_list)
..()
if( href_list["close"] )
if (usr.stat || usr.restrained() )
return
if ((!( istype(usr, /mob/human) ) && (!( ticker ) || (ticker && ticker.mode != "monkey"))))
usr << "\red You don't have the dexterity to do this!"
return
if (( (get_dist(src, usr) <= 1 && istype(src.loc, /turf))))
usr.machine = src
if (href_list["breaker"])
var/obj/machinery/power/apc/APC = locate(href_list["apc"])
APC.operating = !APC.operating
APC.update()
APC.updateicon()
for(var/mob/M in viewers(1, src))
if ((M.client && M.machine == src))
src.interact(M)
else if( href_list["close"] )
usr << browse(null, "window=powcomp")
usr.machine = null
return
else
usr << browse(null, "window=powcomp")
usr.machine = null
return
// Timed process - use power, update window to viewers
+2 -11
View File
@@ -3,17 +3,8 @@
Contining reorg of obj/machinery code
Changed how solar panel directions are displayed, to fix the rotation display bug.
Added remote APC control the power_monitor
Fixed a bug where APCs would continue to draw power for cell charging even when the breaker was off.