Measure energy values in joules

This commit is contained in:
Tad Hardesty
2017-12-02 16:05:31 -08:00
parent 74e3d9b1c9
commit c6da68ab62
11 changed files with 32 additions and 18 deletions
+17 -3
View File
@@ -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
+1 -1
View File
@@ -66,7 +66,7 @@
if(result_filters["Responsive"] && !APC.aidisabled)
continue
dat += "<a href='?src=[REF(src)];access_apc=[REF(APC)]'>[A]</a><br>\
<b>Charge:</b> [DisplayPower(APC.cell.charge)] / [DisplayPower(APC.cell.maxcharge)] ([round((APC.cell.charge / APC.cell.maxcharge) * 100)]%)<br>\
<b>Charge:</b> [DisplayEnergy(APC.cell.charge)] / [DisplayEnergy(APC.cell.maxcharge)] ([round((APC.cell.charge / APC.cell.maxcharge) * 100)]%)<br>\
<b>Area:</b> [APC.area]<br>\
[APC.aidisabled || APC.panel_open ? "<font color='#FF0000'>APC does not respond to interface query.</font>" : "<font color='#00FF00'>APC responds to interface query.</font>"]<br><br>"
dat += "<a href='?src=[REF(src)];check_logs=1'>Check Logs</a><br>"
@@ -29,7 +29,7 @@
to_chat(R, "<span class='warning'>You need a power cell installed for that.</span>")
return
if(!R.cell.use(circuit_cost))
to_chat(R, "<span class='warning'>You don't have the power for that (you need [DisplayPower(circuit_cost)].)</span>")
to_chat(R, "<span class='warning'>You don't have the energy for that (you need [DisplayEnergy(circuit_cost)].)</span>")
return
if(recharging)
to_chat(R, "<span class='warning'>[src] needs some time to recharge first.</span>")
+1 -1
View File
@@ -161,7 +161,7 @@
/obj/item/inducer/examine(mob/living/M)
..()
if(cell)
to_chat(M, "<span class='notice'>Its display shows: [DisplayPower(cell.charge)].</span>")
to_chat(M, "<span class='notice'>Its display shows: [DisplayEnergy(cell.charge)].</span>")
else
to_chat(M,"<span class='notice'>Its display is dark.</span>")
if(opened)
+1 -1
View File
@@ -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
@@ -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
+2 -2
View File
@@ -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, "<span class='notice'>Gained <B>[DisplayPower(.)]</B> of power from [A].</span>")
to_chat(H, "<span class='notice'>Gained <B>[DisplayEnergy(.)]</B> of energy from [A].</span>")
else
to_chat(H, "<span class='danger'>\The [A] has run dry of power, you must find another source!</span>")
to_chat(H, "<span class='danger'>\The [A] has run dry of energy, you must find another source!</span>")
else
. = 0 //as to not cancel attack_hand()
+1 -1
View File
@@ -150,7 +150,7 @@ Contents:
..()
if(s_initialized)
if(user == affecting)
to_chat(user, "All systems operational. Current energy capacity: <B>[DisplayPower(cell.charge)]</B>.")
to_chat(user, "All systems operational. Current energy capacity: <B>[DisplayEnergy(cell.charge)]</B>.")
to_chat(user, "The CLOAK-tech device is <B>[s_active?"active":"inactive"]</B>.")
to_chat(user, "There are <B>[s_bombs]</B> smoke bomb\s remaining.")
to_chat(user, "There are <B>[a_boost]</B> adrenaline booster\s remaining.")
@@ -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, "<span class='notice'>Primary system status: <B>ONLINE</B>.\nBackup system status: <B>ONLINE</B>.\nCurrent energy capacity: <B>[DisplayPower(cell.charge)]</B>.</span>")
to_chat(U, "<span class='notice'>Primary system status: <B>ONLINE</B>.\nBackup system status: <B>ONLINE</B>.\nCurrent energy capacity: <B>[DisplayEnergy(cell.charge)]</B>.</span>")
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)
+1 -1
View File
@@ -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()
@@ -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)