GitHub-TC / EmpyrionScripting

Displays various informations directly and live on LCD screens and will support conveyor and construction control
GNU General Public License v3.0
34 stars 5 forks source link

Deconstruct command: error with leading/trailing commas #40

Closed catt0 closed 4 weeks ago

catt0 commented 2 months ago

Describe the bug Deconstruct command does not handle leading/trailing commas in RemoveItemsIds parameter.

Additionally the bug also appears whenever the parameter contains an empty member, e.g. "1,,2".

To Reproduce Steps to reproduce the behavior:

  1. Install 2 LCDs, name one "Script: Run" and the other "LCD Debug"
  2. Install Cargo Controller and name it "A Sort 640K"
  3. Create new base with some devices, tested: Fridge, Elevator, Small Constructor
  4. Name new base Des-1 and Core DesMe-IDHERE
  5. Paste this code into Script: Run
    
    Targets:LCD Debug

{{#entitiesbyname 'Des-*' 500}} {{#each .}} {{#test @root.E.Id neq Id}} {{Name}}: {{#deconstruct . 'A Sort 640K' 'DesMe' @root.Ids.DeviceL }}

TotalBlocks: {{TotalBlocks}} CheckedBlocks: {{CheckedBlocks}} RemovedBlocks: {{RemovedBlocks}} {{else}}

{{/deconstruct}} {{/test}} {{/each}} {{/entitiesbyname}}


**Expected behavior**
Base gets deconstructed and devices placed in specified inventory.

**Screenshots**
![2024-06-23-225709_2560x1440_scrot](https://github.com/GitHub-TC/EmpyrionScripting/assets/3472645/60919a04-5048-421f-8d6c-3a686ab4ef6b)

**Additional context**
Using concat with some dummy IDs to swallow the leading and trailing commas works. This script works:

Targets:LCD Debug

{{#entitiesbyname 'Des-*' 500}} {{#each .}} {{#test @root.E.Id neq Id}} {{Name}}: {{#deconstruct . 'A Sort 640K' 'DesMe' (concat '468' @root.Ids.DeviceL '584' ) }}

TotalBlocks: {{TotalBlocks}} CheckedBlocks: {{CheckedBlocks}} RemovedBlocks: {{RemovedBlocks}} {{else}}

{{/deconstruct}} {{/test}} {{/each}} {{/entitiesbyname}}



After some initial digging, I assume [this](https://github.com/GitHub-TC/EmpyrionScripting/blob/e1677d671b8f75aee22f5a3d4c46a82452670124/EmpyrionScripting/CustomHelpers/ConveyorHelpers.cs#L948) line is the problem.
GitHub-TC commented 4 weeks ago

Thanks, fixed with https://github.com/GitHub-TC/EmpyrionScripting/commit/5b5c17eb156ec3417f7468fd9e32011816a76655 in https://github.com/GitHub-TC/EmpyrionScripting/releases/tag/13.2.0