Bugfixes / Power capacity sensor

This commit is contained in:
Anuken
2020-08-09 20:18:47 -04:00
parent 15572cdd7a
commit f00510a508
14 changed files with 6 additions and 3 deletions

View File

@@ -1177,6 +1177,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
if(sensor == LSensor.powerNetIn && power != null) return power.graph.getPowerProduced();
if(sensor == LSensor.powerNetOut && power != null) return power.graph.getPowerNeeded();
if(sensor == LSensor.powerNetStored && power != null) return power.graph.getLastPowerStored();
if(sensor == LSensor.powerNetCapacity && power != null) return power.graph.getBatteryCapacity();
return 0;
}

View File

@@ -68,7 +68,7 @@ public class LAssembler{
String[] lines = data.split("[;\n]+");
for(String line : lines){
//comments
//if(line.startsWith("#")) continue;
if(line.startsWith("#")) continue;
String[] tokens = line.split(" ");
LStatement st = LogicIO.read(tokens);

View File

@@ -5,6 +5,7 @@ public enum LSensor{
totalLiquids,
totalPower,
powerNetStored,
powerNetCapacity,
powerNetIn,
powerNetOut,
health,

View File

@@ -24,11 +24,12 @@ public abstract class LStatement{
public abstract LCategory category();
public abstract LInstruction build(LAssembler builder);
//TODO doesn't work with modded stuff
public LStatement copy(){
StringBuilder build = new StringBuilder();
write(build);
return LogicIO.read(build.toString().split(" "));
String[] split = build.toString().split(" ");
LStatement result = LogicIO.read(split);
return result == null && LAssembler.customParsers.containsKey(split[0]) ? LAssembler.customParsers.get(split[0]).get(split) : result;
}
//protected methods are only for internal UI layout utilities