From c6da68ab6206b456a81111d94394e95eab2cbffd Mon Sep 17 00:00:00 2001 From: Tad Hardesty Date: Tue, 21 Nov 2017 03:13:59 -0800 Subject: [PATCH] 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 22e89ce3e32..c3a5bc5c491 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -355,9 +355,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 @@ -366,6 +365,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 aa644eb738a..cbdc28883f4 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 92a8f653dd2..6b465d71e17 100644 --- a/code/game/objects/items/devices/electroadaptive_pseudocircuit.dm +++ b/code/game/objects/items/devices/electroadaptive_pseudocircuit.dm @@ -29,7 +29,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 8f380772e21..578ba28317d 100644 --- a/code/game/objects/items/inducer.dm +++ b/code/game/objects/items/inducer.dm @@ -161,7 +161,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 c74116a4e9d..54333ea35fe 100644 --- a/code/modules/hydroponics/plant_genes.dm +++ b/code/modules/hydroponics/plant_genes.dm @@ -359,7 +359,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 5cd9ee34fc3..0941c033f64 100644 --- a/code/modules/integrated_electronics/passive/power.dm +++ b/code/modules/integrated_electronics/passive/power.dm @@ -12,7 +12,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 spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH diff --git a/code/modules/ninja/suit/gloves.dm b/code/modules/ninja/suit/gloves.dm index 6cf03d1c10b..c49ca072e80 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 4fd7a028751..4e7ad477e22 100644 --- a/code/modules/ninja/suit/suit.dm +++ b/code/modules/ninja/suit/suit.dm @@ -150,7 +150,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 005eec00b6b..4b159557bcc 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 c93f519b538..2e6cfc2781e 100644 --- a/code/modules/power/cell.dm +++ b/code/modules/power/cell.dm @@ -28,7 +28,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 f8147f95124..e8d9478174d 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" build_type = PROTOLATHE | AUTOLATHE |MECHFAB materials = list(MAT_METAL = 700, MAT_GLASS = 50) @@ -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" build_type = PROTOLATHE | AUTOLATHE | MECHFAB materials = list(MAT_METAL = 700, MAT_GLASS = 60) @@ -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" build_type = PROTOLATHE | MECHFAB materials = list(MAT_METAL = 700, MAT_GLASS = 70) @@ -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" build_type = PROTOLATHE | MECHFAB materials = list(MAT_METAL = 700, MAT_GOLD = 150, MAT_SILVER = 150, MAT_GLASS = 80) @@ -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" build_type = PROTOLATHE | MECHFAB materials = list(MAT_METAL = 800, MAT_GOLD = 120, MAT_GLASS = 160, MAT_DIAMOND = 160, MAT_TITANIUM = 300, MAT_BLUESPACE = 100)