Skip to content

Commit

Permalink
Added support for getting the input/output limits for batteries. Also…
Browse files Browse the repository at this point in the history
… add helm keyword for cockpits. (#258)
  • Loading branch information
MerlinofMines authored Jan 2, 2023
1 parent 425cc72 commit a4be06d
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,30 @@ public void GetTheBatteryInput() {
}
}

[TestMethod]
public void GetTheBatteryOutputLimit() {
using (ScriptTest test = new ScriptTest(@"Print ""Battery Output Limit: "" + the ""test battery"" output limit")) {
Mock<IMyBatteryBlock> mockBattery = new Mock<IMyBatteryBlock>();
test.MockBlocksOfType("test battery", mockBattery);
mockBattery.Setup(b => b.MaxOutput).Returns(12f);
test.RunUntilDone();

Assert.AreEqual("Battery Output Limit: 12", test.Logger[0]);
}
}

[TestMethod]
public void GetTheBatteryInputLimit() {
using (ScriptTest test = new ScriptTest(@"Print ""Battery Input Limit: "" + the ""test battery"" input limit")) {
Mock<IMyBatteryBlock> mockBattery = new Mock<IMyBatteryBlock>();
test.MockBlocksOfType("test battery", mockBattery);
mockBattery.Setup(b => b.MaxInput).Returns(2f);
test.RunUntilDone();

Assert.AreEqual("Battery Input Limit: 2", test.Logger[0]);
}
}

[TestMethod]
public void IsTheBatteryRecharging() {
using (ScriptTest test = new ScriptTest(@"Print ""Charging: "" + the ""test battery"" is recharging")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public void CameraSelector() {
[TestMethod]
public void CockpitSelector() {
TestExpectedSelectorWords<IMyCockpit>(
Words("cockpit", "ship", "rover", "seat", "station"),
Words("cockpits", "ships", "rovers", "seats", "stations")
Words("cockpit", "ship", "rover", "seat", "station", "helm"),
Words("cockpits", "ships", "rovers", "seats", "stations", "helms")
);
}

Expand Down
2 changes: 2 additions & 0 deletions EasyCommands/BlockHandlers/BatteryBlockHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public BatteryBlockHandler() {
AddNumericHandler(Property.INPUT, b => b.CurrentInput);
AddNumericHandler(Property.VOLUME, b => b.CurrentOutput);
AddNumericHandler(Property.LEVEL, b => b.CurrentStoredPower);
AddPropertyHandler(NewList(Property.VOLUME, Property.RANGE), NumericHandler(b => b.MaxOutput));
AddPropertyHandler(NewList(Property.INPUT, Property.RANGE), NumericHandler(b => b.MaxInput));
defaultPropertiesByPrimitive[Return.NUMERIC] = Property.RATIO;
defaultPropertiesByDirection[Direction.UP] = Property.RATIO;
}
Expand Down
2 changes: 1 addition & 1 deletion EasyCommands/CommandParsers/ParameterParsers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public void InitializeParsers() {
AddBlockWords(Words("sensor"), Block.SENSOR);
AddBlockWords(Words("beacon"), Block.BEACON);
AddBlockWords(Words("antenna"), Block.ANTENNA);
AddBlockWords(Words("ship", "rover", "cockpit", "seat", "station"), Block.COCKPIT);
AddBlockWords(Words("ship", "rover", "cockpit", "seat", "station", "helm"), Block.COCKPIT);
AddBlockWords(Words("cryo"), Block.CRYO_CHAMBER);
AddBlockWords(Words("drone", "remote", "robot"), Block.REMOTE);
AddBlockWords(Words("thruster"), Block.THRUSTER);
Expand Down
26 changes: 24 additions & 2 deletions docs/EasyCommands/blockHandlers/battery.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ set the "Ship Batteries" to auto
* Primitive Type: Numeric
* Keywords: ```limit, limits```

Gets the maximum amount of power that the given battery is able to store.
Gets the maximum amount of power that the given battery is able to store, in MW.

```
Print "Max Stored Power: " + the "Ship Batteries" limit, in MW
Print "Max Stored Power: " + the "Ship Batteries" limit
```

## "Ratio" Property
Expand Down Expand Up @@ -140,6 +140,17 @@ Returns a value representing the current input power to the battery, in MW / s.
Print "Current Power Input: " + "Ship Batteries" input
```

## "Input Limit" Property
* Read-only
* Primitive Type: Numeric
* Keywords: ```input limit, input limits```

Gets the maximum amount of power that the given battery can receive as input, in MW.

```
Print "Max Power Input: " + the "Ship Batteries" input limit
```

## "Output" Property
* Read-only
* Primitive Type: Numeric
Expand All @@ -150,3 +161,14 @@ Returns a value representing the current output power from the battery, in MW /
```
Print "Current Power Output: " + "Ship Batteries" output
```

## "Output Limit" Property
* Read-only
* Primitive Type: Numeric
* Keywords: ```output limit, output limits```

Gets the maximum amount of power that the given battery is able to output, in MW.

```
Print "Max Power Output: " + the "Ship Batteries" output limit
```
4 changes: 2 additions & 2 deletions docs/EasyCommands/blockHandlers/cockpit.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ This handler enables you to listen for user input, which has all kinds of potent

This Block Handler will only briefly touch on handling user input. For much more information, see [Handling User Input](https://spaceengineers.merlinofmines.com/EasyCommands/input "Handling User Input")

* Block Type Keywords: ```ship, rover, cockpit, seat, station```
* Block Type Group Keywords: ```ships, rovers, cockpits, seats, stations```
* Block Type Keywords: ```ship, rover, cockpit, seat, station, helm```
* Block Type Group Keywords: ```ships, rovers, cockpits, seats, stations, helms```

Default Primitive Properties:
* Boolean - Enabled
Expand Down
4 changes: 2 additions & 2 deletions docs/EasyCommands/cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ These words are (mostly) ignored when parsing your script, but feel free to use
* ```camera```
* ```cameras```
* Cockpit
* ```cockpit, ship, rover, seat, station```
* ```cockpits, ships, rovers, seats, stations```
* ```cockpit, ship, rover, seat, station, helm```
* ```cockpits, ships, rovers, seats, stations, helms```
* Collector
* ```collector```
* ```collectors```
Expand Down

0 comments on commit a4be06d

Please sign in to comment.