diff --git a/code/defines/global.dm b/code/defines/global.dm index 7f655e9420e..f9829f4595a 100644 --- a/code/defines/global.dm +++ b/code/defines/global.dm @@ -11,6 +11,11 @@ var/global defer_powernet_rebuild = 0 // true if net rebuild will be called manually after an event + powerreport = null //muskets 250810 these four are needed for the new engineering pda to work + powerreportnodes = null //might be a better way to do it but w/e + powerreportavail = null + powerreportviewload = null + var ////////////// diff --git a/code/game/machinery/computer/power.dm b/code/game/machinery/computer/power.dm index d9e5e8791c7..1c474cd4fa1 100644 --- a/code/game/machinery/computer/power.dm +++ b/code/game/machinery/computer/power.dm @@ -1,6 +1,9 @@ // the power monitoring computer // for the moment, just report the status of all APCs in the same powernet + +var/reportingpower = 0 //this tracks whether this power monitoring computer is the one reporting to engi PDAs - muskets + /obj/machinery/power/monitor/attack_ai(mob/user) add_fingerprint(user) @@ -74,6 +77,21 @@ if(!(stat & (NOPOWER|BROKEN)) ) use_power(250) + //muskets 250810 + //this handles updating the remote power monitoring globals + + if(!powerreport) //if no computer is updating the PDA power monitor + reportingpower = 1 //take over updating them + + if(reportingpower) //if this computer is updating the PDA power monitor + if(!powernet) //if it's not connected to a powernet, don't do anything + return + else + powerreport = powernet //update the globals from the current powernet - this is a bit of a hack, might need improving + powerreportnodes = powernet.nodes + powerreportavail = powernet.avail + powerreportviewload = powernet.viewload + src.updateDialog() @@ -81,6 +99,12 @@ if(stat & BROKEN) icon_state = "broken" + // the following four lines reset the pda power monitoring globals if the computer breaks + // this is to stop PDAs reporting incorrect information and to allow another computer to easily take over -- muskets + powerreport = null + powerreportnodes = null + powerreportavail = null + powerreportviewload = null else if( powered() ) icon_state = initial(icon_state) diff --git a/code/game/objects/devices/PDA.dm b/code/game/objects/devices/PDA.dm index a0f19bc8e81..91027f41035 100644 --- a/code/game/objects/devices/PDA.dm +++ b/code/game/objects/devices/PDA.dm @@ -477,7 +477,7 @@ if (!isnull(src.cartridge) && src.cartridge.access_engine) dat += "

Engineering Functions

" dat += "" if (!isnull(src.cartridge) && src.cartridge.access_medical) @@ -530,7 +530,39 @@ if (2) - //TO-DO: Engine monitor for whatever engine is used I guess + //muskets 250810 + //experimental PDA power monitoring code + //mostly ripped off from the power monitor computer + //powerreport, powerreportnodes, powerreportavail and powerreportviewload are new globals updated by the + //power monitor computer + // + //only the first power computer to come online will update, if that breaks you can build another and it'll take over + //an existing second power monitor should take over fine too + //see changes to /game/machinery/computer/power.dm + if(!powerreport) + dat += "\red No connection" + else + var/list/L = list() + for(var/obj/machinery/power/terminal/term in powerreportnodes) + if(istype(term.master, /obj/machinery/power/apc)) + var/obj/machinery/power/apc/A = term.master + L += A + + dat += "
Total power: [powerreportavail] W
Total load: [num2text(powerreportviewload,10)] W
" + + dat += "" + + if(L.len > 0) + dat += "Area Eqp./Lgt./Env. Load Cell
" + + var/list/S = list(" Off","AOff"," On", " AOn") + var/list/chg = list("N","C","F") + + for(var/obj/machinery/power/apc/A in L) + dat += copytext(add_tspace(A.area.name, 30), 1, 30) + dat += " [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"]
" + + dat += "
" if (3)