new GEN yalol code idea

shado20

Veteran endo
Joined
May 16, 2020
Messages
199
#1
it takes 1 second for 1% generator power up.
so this code will add 1 every second the battery's are under 9000.
when the battery's charge over 9000 it will not bounce back to zero, instead it will back 5 points every second, so if you have a ship say running at 60% it will go over 60 and charge the battery's, then back off a little and the battery's will lose some power and only need to power up a little rather from zero.
you could change the -=5 to -=1 and the generator will power down as fast as it powers up.


1| If :StoredBatteryPower<9000 THEN goto2 ELSE goto6 END
2| :FuelChamberUnitRateLimit+=1
3|
4|
5| goto1
6| :FuelChamberUnitRateLimit-=5
7|
8|
9| goto1
 

ChaosRifle

Veteran endo
Joined
Aug 11, 2020
Messages
226
#2
Basically a slower version of
Code:
:Gen = A*(100-((:Bat+1)/100))
(A is a multiplier to just make it more aggressive, personally I use 6, but setting it to 1 removes its effect.)
another favourite of mine is
Code:
bt = A*(100-((:Bat+1)/100)) :Gen=((bt<M)*M)+((bt>=M)*bt)
where M is a percentile threshold. This would mean if M is 40% then the reactor can spool up dynamically to be inversely proportional to battery level like before, but can never go below a minimum value. A minimum clamp. Useful with a goto2 at the end, and line two checking what power level the reactor should be running at (like goto7+:Switch to select between three lines: 6 7 and 8, for an off/thrusters only/full power draw)

I like the idea of retarding the ramp down.


Edited because auto-emoji bullshit
 

Askannon

Veteran endo
Joined
Feb 13, 2020
Messages
114
#3
You could also do it by having code that 1) calculates a value, but only assigns it if it is greater than the current generator value and 2) have the count down be managed by a lever with centering speed greater 0
Code:
d=(100-:bat/100)-:gen b=d>0 :gen+=d*b goto1
(an untested example code)
 

shado20

Veteran endo
Joined
May 16, 2020
Messages
199
#4
well you could do a 1 liner, but your already using a 20 line chip to do 1 thing.
i like to not charge up my battery's to 10,000 , the reason is that you cant turn off the generators with out overcharging, and there is no more over 10,000
so many of these codes get the generator pulsing on and off to top off the battery. but if you try to only charge to 9000, if the generators stop and over charge some , you get that power! where as if you charge to 10000, you get no overcharge power.
by only going to 9000, the overcharge will cause your system to use way less power on standby as your generators will turn on and charge back up way less often.
 

Askannon

Veteran endo
Joined
Feb 13, 2020
Messages
114
#5
A one-liner for you would then be
Code:
:gen=100-(:bat/100+10-(:gen>0)*5) goto 1
as it will not run if battery is above 9000, but once below it will run up to 9500, where it would turn off and wait for drain to go down to 9000 again.

That way you have your efficiency and the generators will flicker even less.
 

Askannon

Veteran endo
Joined
Feb 13, 2020
Messages
114
#6
Or, if you want to keep the stepping behaviour
Code:
:gen=:genCur+(:bat<9000)-:gen*(:bat>9500)-(:bat>9000)
where it will step up (bat<9000) or down (bat>9000), or even fully turn off (bat>9500)
(uses current Generator output for error protection, since I currently can't test if you can assign a negative value to the limit)
 
Top