Makes the SMES display its capacity instead of precent and clarifies its charge (#12926)

* Autodocs, True capacity, and some modifications

* fixes children plus percentage

* Update Smes.js

* improve goals comment
This commit is contained in:
Redmoogle
2021-12-23 16:19:37 -05:00
committed by GitHub
parent e954417ee9
commit 4ff4c79147
4 changed files with 47 additions and 31 deletions

View File

@@ -1,11 +1,12 @@
/datum/department_goal/eng
account = ACCOUNT_ENG
// Store like 70e6 joules
// Which is like, 14 roundstart SMES' worth (so requires upgrades)
// Store 1.4e9J
// Which is around 21 roundstart SMES' worth (so requires upgrades)
// Or 6 fully upgraded SMES'
/datum/department_goal/eng/SMES
name = "Store 70MJ"
desc = "Store 70MJ of energy in the station's SMES'"
name = "Store 1.4GJ"
desc = "Store 1.4GJ of energy in the station's SMES"
reward = "50000"
/datum/department_goal/eng/SMES/check_complete()
@@ -14,7 +15,7 @@
if(!is_station_level(s.z))
continue
charge += s.charge
return charge >= 70e6
return charge >= 1.4e9
// Fire up a supermatter

View File

@@ -1,8 +1,6 @@
// the SMES
// stores power
#define SMESRATE 0.05 // rate of internal charge to external power
//Cache defines
#define SMES_CLEVEL_1 1
#define SMES_CLEVEL_2 2
@@ -22,19 +20,29 @@
use_power = NO_POWER_USE
circuit = /obj/item/circuitboard/machine/smes
var/capacity = 5e6 // maximum charge
var/charge = 0 // actual charge
var/input_attempt = TRUE // TRUE = attempting to charge, FALSE = not attempting to charge
var/inputting = TRUE // TRUE = actually inputting, FALSE = not inputting
var/input_level = 50000 // amount of power the SMES attempts to charge by
var/input_level_max = 200000 // cap on input_level
var/input_available = 0 // amount of charge available from input last tick
var/output_attempt = TRUE // TRUE = attempting to output, FALSE = not attempting to output
var/outputting = TRUE // TRUE = actually outputting, FALSE = not outputting
var/output_level = 50000 // amount of power the SMES attempts to output
var/output_level_max = 200000 // cap on output_level
/// Maximum charge of the SMES
var/capacity = 5e6
/// Current charge of the SMES
var/charge = 0
/// TRUE = attempting to charge, FALSE = not attempting to charge
var/input_attempt = TRUE
/// TRUE = actually inputting, FALSE = not inputting
var/inputting = TRUE
/// Desired Power Input Level
var/input_level = 50000
/// Maximum Power Input
var/input_level_max = 200000
/// Last power input
var/input_available = 0
/// TRUE = attempting to output, FALSE = not attempting to output
var/output_attempt = TRUE
/// TRUE = actually outputting, FALSE = not outputting
var/outputting = TRUE
/// Desired Power Output Level
var/output_level = 50000
/// Maximum Power Output
var/output_level_max = 200000
/// Last power output
var/output_used = 0 // amount of power actually outputted. may be less than output_level if the powernet returns excess power
var/obj/machinery/power/terminal/terminal = null
@@ -71,9 +79,9 @@
for(var/obj/item/stock_parts/cell/PC in component_parts)
MC += PC.maxcharge
C += PC.charge
capacity = MC / (15000) * 1e6
capacity = MC / (15000) * 2e7
if(!initial(charge) && !charge)
charge = C / 15000 * 1e6
charge = C / 15000 * 2e7
/obj/machinery/power/smes/attackby(obj/item/I, mob/user, params)
//opening using screwdriver
@@ -245,9 +253,9 @@
if(inputting)
if(input_available > 0) // if there's power available, try to charge
var/load = min(min((capacity-charge)/SMESRATE, input_level), input_available) // charge at set rate, limited to spare capacity
var/load = min(min((capacity-charge), input_level), input_available) // charge at set rate, limited to spare capacity
charge += load * SMESRATE // increase the charge
charge += load // increase the charge
terminal.add_load(load) // add the load to the terminal side network
@@ -263,10 +271,10 @@
//outputting
if(output_attempt)
if(outputting)
output_used = min( charge/SMESRATE, output_level) //limit output to that stored
output_used = min( charge, output_level) //limit output to that stored
if (add_avail(output_used)) // add output to powernet if it exists (smes side)
charge -= output_used*SMESRATE // reduce the storage (may be recovered in /restore() if excessive)
charge -= output_used // reduce the storage (may be recovered in /restore() if excessive)
else
outputting = FALSE
@@ -301,13 +309,13 @@
excess = min(output_used, excess) // clamp it to how much was actually output by this SMES last ptick
excess = min((capacity-charge)/SMESRATE, excess) // for safety, also limit recharge by space capacity of SMES (shouldn't happen)
excess = min((capacity-charge), excess) // for safety, also limit recharge by space capacity of SMES (shouldn't happen)
// now recharge this amount
var/clev = chargedisplay()
charge += excess * SMESRATE // restore unused power
charge += excess // restore unused power
powernet.netexcess -= excess // remove the excess from the powernet, so later SMESes don't try to use it
output_used -= excess
@@ -439,7 +447,6 @@
log_smes(user)
update_icon()
#undef SMESRATE
#undef SMES_CLEVEL_1
#undef SMES_CLEVEL_2

View File

@@ -68,6 +68,10 @@ export const formatPower = (value, minBase1000 = 0) => {
return formatSiUnit(value, minBase1000, 'W');
};
export const formatJoule = (value, minBase1000 = 0) => {
return formatSiUnit(value, minBase1000, 'J');
};
export const formatMoney = (value, precision = 0) => {
if (!Number.isFinite(value)) {
return value;

View File

@@ -1,6 +1,6 @@
import { useBackend } from '../backend';
import { Box, Button, Flex, LabeledList, ProgressBar, Section, Slider } from '../components';
import { formatPower } from '../format';
import { formatPower, formatJoule } from '../format';
import { Window } from '../layouts';
// Common power multiplier
@@ -45,7 +45,11 @@ export const Smes = (props, context) => {
good: [0.5, Infinity],
average: [0.15, 0.5],
bad: [-Infinity, 0.15],
}} />
}}>
<Box>
{formatJoule(charge) + " / " + formatJoule(capacity) + " (" + capacityPercent + "%)"}
</Box>
</ProgressBar>
</Section>
<Section title="Input">
<LabeledList>