From 4204c889ed8e09c90d61831e0fef11a46c51ab29 Mon Sep 17 00:00:00 2001 From: oranges Date: Tue, 5 Dec 2017 20:42:25 +1300 Subject: [PATCH 1/2] Merge pull request #32964 from AutomaticFrenzy/patch/joules Measure energy values in joules --- code/__HELPERS/unsorted.dm | 20 ++++++++++++++++--- code/game/machinery/computer/apc_control.dm | 2 +- .../devices/electroadaptive_pseudocircuit.dm | 2 +- code/game/objects/items/inducer.dm | 2 +- code/modules/hydroponics/plant_genes.dm | 2 +- .../integrated_electronics/passive/power.dm | 2 +- code/modules/ninja/suit/gloves.dm | 4 ++-- code/modules/ninja/suit/suit.dm | 2 +- .../modules/ninja/suit/suit_initialisation.dm | 2 +- code/modules/power/cell.dm | 2 +- .../modules/research/designs/power_designs.dm | 10 +++++----- 11 files changed, 32 insertions(+), 18 deletions(-) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 5e266fdaa2..6fb7b08611 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -353,9 +353,8 @@ Turf and target are separate in case you want to teleport some distance from a t var/M = E/(SPEED_OF_LIGHT_SQ) return M -//Takes the value of energy used/produced/ect. -//Returns a text value of that number in W, kW, MW, or GW. -/proc/DisplayPower(var/powerused) +// Format a power value in W, kW, MW, or GW. +/proc/DisplayPower(powerused) if(powerused < 1000) //Less than a kW return "[powerused] W" else if(powerused < 1000000) //Less than a MW @@ -364,6 +363,21 @@ Turf and target are separate in case you want to teleport some distance from a t return "[round((powerused * 0.000001),0.001)] MW" return "[round((powerused * 0.000000001),0.0001)] GW" +// Format an energy value in J, kJ, MJ, or GJ. 1W = 1J/s. +/proc/DisplayEnergy(units) + // APCs process every (SSmachines.wait * 0.1) seconds, and turn 1 W of + // excess power into GLOB.CELLRATE energy units when charging cells. + // With the current configuration of wait=20 and CELLRATE=0.002, this + // means that one unit is 1 kJ. + units *= SSmachines.wait * 0.1 / GLOB.CELLRATE + if (units < 1000) // Less than a kJ + return "[round(units, 0.1)] J" + else if (units < 1000000) // Less than a MJ + return "[round(units * 0.001, 0.01)] kJ" + else if (units < 1000000000) // Less than a GJ + return "[round(units * 0.000001, 0.001)] MJ" + return "[round(units * 0.000000001, 0.0001)] GJ" + /proc/key_name(whom, include_link = null, include_name = 1) var/mob/M var/client/C diff --git a/code/game/machinery/computer/apc_control.dm b/code/game/machinery/computer/apc_control.dm index aa644eb738..cbdc28883f 100644 --- a/code/game/machinery/computer/apc_control.dm +++ b/code/game/machinery/computer/apc_control.dm @@ -66,7 +66,7 @@ if(result_filters["Responsive"] && !APC.aidisabled) continue dat += "[A]
\ - Charge: [DisplayPower(APC.cell.charge)] / [DisplayPower(APC.cell.maxcharge)] ([round((APC.cell.charge / APC.cell.maxcharge) * 100)]%)
\ + Charge: [DisplayEnergy(APC.cell.charge)] / [DisplayEnergy(APC.cell.maxcharge)] ([round((APC.cell.charge / APC.cell.maxcharge) * 100)]%)
\ Area: [APC.area]
\ [APC.aidisabled || APC.panel_open ? "APC does not respond to interface query." : "APC responds to interface query."]

" dat += "Check Logs
" diff --git a/code/game/objects/items/devices/electroadaptive_pseudocircuit.dm b/code/game/objects/items/devices/electroadaptive_pseudocircuit.dm index 204a1f81d9..7f9a53557c 100644 --- a/code/game/objects/items/devices/electroadaptive_pseudocircuit.dm +++ b/code/game/objects/items/devices/electroadaptive_pseudocircuit.dm @@ -30,7 +30,7 @@ to_chat(R, "You need a power cell installed for that.") return if(!R.cell.use(circuit_cost)) - to_chat(R, "You don't have the power for that (you need [DisplayPower(circuit_cost)].)") + to_chat(R, "You don't have the energy for that (you need [DisplayEnergy(circuit_cost)].)") return if(recharging) to_chat(R, "[src] needs some time to recharge first.") diff --git a/code/game/objects/items/inducer.dm b/code/game/objects/items/inducer.dm index e720644055..a2d69764c5 100644 --- a/code/game/objects/items/inducer.dm +++ b/code/game/objects/items/inducer.dm @@ -162,7 +162,7 @@ /obj/item/inducer/examine(mob/living/M) ..() if(cell) - to_chat(M, "Its display shows: [DisplayPower(cell.charge)].") + to_chat(M, "Its display shows: [DisplayEnergy(cell.charge)].") else to_chat(M,"Its display is dark.") if(opened) diff --git a/code/modules/hydroponics/plant_genes.dm b/code/modules/hydroponics/plant_genes.dm index c6e17a63a4..92b6b8abaf 100644 --- a/code/modules/hydroponics/plant_genes.dm +++ b/code/modules/hydroponics/plant_genes.dm @@ -375,7 +375,7 @@ pocell.maxcharge *= CG.rate*1000 pocell.charge = pocell.maxcharge pocell.name = "[G.name] battery" - pocell.desc = "A rechargeable plant based power cell. This one has a power rating of [DisplayPower(pocell.maxcharge)], and you should not swallow it." + pocell.desc = "A rechargeable plant-based power cell. This one has a rating of [DisplayEnergy(pocell.maxcharge)], and you should not swallow it." if(G.reagents.has_reagent("plasma", 2)) pocell.rigged = 1 diff --git a/code/modules/integrated_electronics/passive/power.dm b/code/modules/integrated_electronics/passive/power.dm index 7c7439d45b..1e65a2b67d 100644 --- a/code/modules/integrated_electronics/passive/power.dm +++ b/code/modules/integrated_electronics/passive/power.dm @@ -13,7 +13,7 @@ /obj/item/integrated_circuit/passive/power/solar_cell name = "tiny photovoltaic cell" desc = "It's a very tiny solar cell, generally used in calculators." - extended_desc = "The cell generates 1W of power per second in optimal lighting conditions. Less light will result in less power being generated." + extended_desc = "The cell generates 1 W of power in optimal lighting conditions. Less light will result in less power being generated." icon_state = "solar_cell" complexity = 8 origin_tech = list(TECH_POWER = 3, TECH_ENGINEERING = 3, TECH_DATA = 2) diff --git a/code/modules/ninja/suit/gloves.dm b/code/modules/ninja/suit/gloves.dm index 6cf03d1c10..c49ca072e8 100644 --- a/code/modules/ninja/suit/gloves.dm +++ b/code/modules/ninja/suit/gloves.dm @@ -63,9 +63,9 @@ if(isnum(.)) //Numerical values of drained handle their feedback here, Alpha values handle it themselves (Research hacking) if(.) - to_chat(H, "Gained [DisplayPower(.)] of power from [A].") + to_chat(H, "Gained [DisplayEnergy(.)] of energy from [A].") else - to_chat(H, "\The [A] has run dry of power, you must find another source!") + to_chat(H, "\The [A] has run dry of energy, you must find another source!") else . = 0 //as to not cancel attack_hand() diff --git a/code/modules/ninja/suit/suit.dm b/code/modules/ninja/suit/suit.dm index 1dcfed99c0..128997cb98 100644 --- a/code/modules/ninja/suit/suit.dm +++ b/code/modules/ninja/suit/suit.dm @@ -152,7 +152,7 @@ Contents: ..() if(s_initialized) if(user == affecting) - to_chat(user, "All systems operational. Current energy capacity: [DisplayPower(cell.charge)].") + to_chat(user, "All systems operational. Current energy capacity: [DisplayEnergy(cell.charge)].") to_chat(user, "The CLOAK-tech device is [s_active?"active":"inactive"].") to_chat(user, "There are [s_bombs] smoke bomb\s remaining.") to_chat(user, "There are [a_boost] adrenaline booster\s remaining.") diff --git a/code/modules/ninja/suit/suit_initialisation.dm b/code/modules/ninja/suit/suit_initialisation.dm index 0084ff1995..e19e67404d 100644 --- a/code/modules/ninja/suit/suit_initialisation.dm +++ b/code/modules/ninja/suit/suit_initialisation.dm @@ -42,7 +42,7 @@ addtimer(CALLBACK(src, .proc/ninitialize_six, delay, U), delay) /obj/item/clothing/suit/space/space_ninja/proc/ninitialize_six(delay, mob/living/carbon/human/U) - to_chat(U, "Primary system status: ONLINE.\nBackup system status: ONLINE.\nCurrent energy capacity: [DisplayPower(cell.charge)].") + to_chat(U, "Primary system status: ONLINE.\nBackup system status: ONLINE.\nCurrent energy capacity: [DisplayEnergy(cell.charge)].") addtimer(CALLBACK(src, .proc/ninitialize_seven, delay, U), delay) /obj/item/clothing/suit/space/space_ninja/proc/ninitialize_seven(delay, mob/living/carbon/human/U) diff --git a/code/modules/power/cell.dm b/code/modules/power/cell.dm index acbebea458..625f99a040 100644 --- a/code/modules/power/cell.dm +++ b/code/modules/power/cell.dm @@ -29,7 +29,7 @@ START_PROCESSING(SSobj, src) charge = maxcharge if(ratingdesc) - desc += " This one has a power rating of [DisplayPower(maxcharge)], and you should not swallow it." + desc += " This one has a rating of [DisplayEnergy(maxcharge)], and you should not swallow it." update_icon() /obj/item/stock_parts/cell/Destroy() diff --git a/code/modules/research/designs/power_designs.dm b/code/modules/research/designs/power_designs.dm index d5526e9509..a6ef6cd2bf 100644 --- a/code/modules/research/designs/power_designs.dm +++ b/code/modules/research/designs/power_designs.dm @@ -4,7 +4,7 @@ /datum/design/basic_cell name = "Basic Power Cell" - desc = "A basic power cell that holds 1 kW of power." + desc = "A basic power cell that holds 1 MJ of energy." id = "basic_cell" req_tech = list("powerstorage" = 1) build_type = PROTOLATHE | AUTOLATHE |MECHFAB @@ -15,7 +15,7 @@ /datum/design/high_cell name = "High-Capacity Power Cell" - desc = "A power cell that holds 10 kW of power." + desc = "A power cell that holds 10 MJ of energy." id = "high_cell" req_tech = list("powerstorage" = 2) build_type = PROTOLATHE | AUTOLATHE | MECHFAB @@ -26,7 +26,7 @@ /datum/design/super_cell name = "Super-Capacity Power Cell" - desc = "A power cell that holds 20 kW of power." + desc = "A power cell that holds 20 MJ of energy." id = "super_cell" req_tech = list("powerstorage" = 3, "materials" = 3) build_type = PROTOLATHE | MECHFAB @@ -37,7 +37,7 @@ /datum/design/hyper_cell name = "Hyper-Capacity Power Cell" - desc = "A power cell that holds 30 kW of power." + desc = "A power cell that holds 30 MJ of energy." id = "hyper_cell" req_tech = list("powerstorage" = 5, "materials" = 5, "engineering" = 5) build_type = PROTOLATHE | MECHFAB @@ -48,7 +48,7 @@ /datum/design/bluespace_cell name = "Bluespace Power Cell" - desc = "A power cell that holds 40 kW of power." + desc = "A power cell that holds 40 MJ of energy." id = "bluespace_cell" req_tech = list("powerstorage" = 6, "materials" = 5, "engineering" = 5, "bluespace" = 5) build_type = PROTOLATHE | MECHFAB