Space Engineers

Space Engineers

65 ratings
Cargo Utilization Light v2.2
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
37.266 KB
7 Jun, 2018 @ 6:37pm
8 Apr, 2020 @ 7:03pm
30 Change Notes ( view )

Subscribe to download
Cargo Utilization Light v2.2

Description
Description:
Script checks storage blocks and calculates percentage filled, then uses a light block containing the name "Cargo Light" or a group of lights named "Cargo Lights" to indicate a color. Blinking GREEN when cargo is empty, then gradually changes to RED as the cargo is filled. When the cargo is completely full, the light will blink red.

Given 2 colors one for 0 % and one for 100%
Calculate the percentage of cargo space utilized
interpolate the colors with percent to determine indicator light color.

Modified using ibigpapa's script as inspiration.
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=387944893

Added:
- Run without timer block.
- Added Feed back to the PB to display progress, or error messages.
- Put the Block initializations inside a try-catch block. Avoids the issues with not having
the block named correctly and needing to recompile.
- Set Block Selection to only select blocks from the grid that the Program Block in attached to.
- Added Group support for light blocks. Just need to put your lights in a Group called "Cargo Lights".
- Added include Drills (changed to includeTools) option so that drills are added to the percentage count for mining.
Most times miners have more cargo in their drills than the storage, so including drills gives a
better indication of a full miner. <Optional: needs var includeTools = true>
- Added Settings controls within the Programmable block's Custom Data
- Added "reset" argument option. When entered into the Program block it resets all settings back to default.
- Added LCD, and Cockpit surface support.

============
Update: (Apr. 5 2020)
- Modified sub-grid exceptions.
Grids attached by Pistons or Rotors will automatically be accepted, grids attached through other means will need the includeSubGrid options enabled.

- Modified LCD options.
If both fontColor and backgroundColor are both set to True then LCD will clear the text and just show as a colored panel.

- Modified Color options.
Colors in the setting options will now accept ColorName, RGBA, RGB, and HSV.

example.., {Green}
Starting Color = Color[Green] -- ColorName Mode.
Starting Color = RGBA[0,255,0,255] -- RGBA Mode.
Starting Color = RGB[0,255,0] -- RGB Mode.
Starting Color = HSV[120,100,100] -- HSV Mode.


============
Update: (Jan. 7 2020)
- Modified settings configuration and update function.
- Added LCD support. LCD options can be set on the LCD's Custom Data.
- Added Cockpit and Control Station/Flight Seat Surface support. Shows cargo data on selected surface.

============

Update: (Dec. 17 2019)
- Modified cargo/tool block initialization.
- Added sub-grid support by setting either cargo and/or tool sub_grid to True.
- Modified cargo percentage calculations to try and fix an error with the light not blinking red with tools included.

============

Update: (May 28 2019)
Overhauled script to use PB's Custom Data section to handle all the Script's Settings options.

============

Update: (Mar. 1 2019)
Brought script up do date with current SE API standard for SE release 1.189(Feb. 28 2019).

============

Update: (Jan. 1 2019 )
- Made Updates to the cargo light selection function.

Found an issue when multiple ships having a Cargo Lights group lost track of the lights while connected to a base at the same time.

While working on the cargo light selection function I updated the Group naming options.

Valid names for Groups now include...
Cargo Lights
[Cargo Lights]
{Cargo Lights}
(Cargo Lights)
<Cargo Lights>

============

Update: (Dec. 10 2018) [OBSOLETE]

<<< These commands can now be found in the Custom Data section of the programming block. In the Cargo List section of the Custom data, change the, "Cargo =" to include whatever cargo block you want. For example, "CARGO = Container, Connector", to add Connectors. >>>

-Added custom cargo and tool inclusion lists for players to add additional inventory blocks to the calculations.
Just add the name of the block to the Include List.

Example, to add Connectors to the cargo list.
| string[] cargoIncludeList = {"Container" , "Connector" }; |
-Changed: Found in Custom Data under, "CARGO_INCLUSION_LIST"
| Cargo = Container, Connector |

Or if you want to just view a single container just change the name in the list to the name of the Container.
| string[] cargoIncludeList = {"My Widget Box" }; |
-Changed: Found in Custom Data under, "CARGO_INCLUSION_LIST"
| Cargo = My Widget Box |

-Changed: "includeDrills" to "includeTools" in order to add tools to the cargo calculation set "includeTools = True".
-Changed: Made changes to the drill ore load balancing, tried to fix an issue I was having with a ship with a lot of drills that kept getting "script to complex" error. I believe it is now fixed, but requires further testing.

============

Update: (Aug. 7 2018)
- Added a basic load balancing to the mining drills when the "includeTools" variable equals TRUE.

NOTE 1: Load balancing is based off of the percentage of volume filled. Therefore, Modded drills
with large volumes will not cause issues, where all non-modded drills are full and modded
drills are still mostly empty. All drills should fill in realation to the current drill full percentage.
NOTE 2: Drill load balancing will not begin until script determines that at least 10% of the drills total volume is full, and will stop load balancing when cargo full is determined.
69 Comments
Dots 22 Feb, 2023 @ 4:19am 
wil this script ever finish updating?
Derzuel 5 Oct, 2022 @ 3:16am 
would it be possible to add an option to not change the On / Off state of lights being used by the script? I've got a collector ship that's using a spot light as an indicator and it would be nice if it would stay off when I don't really need it.
Jared_T  [author] 11 Feb, 2022 @ 10:41am 
@Schmetterling
Thanks for letting me know about the bug, but I am not sure what the problem is. I have been busy with school, so I have not played with the lights in the DLC content yet. I will look into it as soon as I have some free time.
As for the adding additional inventory, I apologize, the "| string[] cargoIncludeList = {"Container" , "Connector" }; |" is a depreciated command, and I never got around to updating the comment section. All you need to do is in the "Custom Data" go to the section for "-= CARGO_INCLUSION_LIST =-" look for the line starting with "Cargo = " and add the connectors, and cockpits. I should look like this when done, "CARGO = Container, Connector, Cockpit".
Schmetterling 10 Feb, 2022 @ 7:21pm 
Great job, author. The script works just fine, but it doesn't support lights from Wasteland DLC. More precisely, they initially change to green and they blink, but as inventories are filled with ore, they do not change. Standard lights work fine. And it's still not clear how to add additional inventory, such as the Connector and Cockpit. Specify where to add the line "| string[] cargoIncludeList = {"Container" , "Connector" }; |" , in the code itself or in "Custom data".
Schmetterling 10 Feb, 2022 @ 7:21pm 
Прекрасная работа, Автор. Скрипт работает просто отлично, но не поддерживает огни из DLC Wasteland. Точнее они вначале изменяются на зеленный цвет и они моргают, но по мере заполнения рудой инвентарей они не меняются. Стандартные огни работают нормально. И еще непонятно как добавить дополнительные инвентори, такие как Коннектор и Кокпит. Уточните куда нужно добавить строку "| string[] cargoIncludeList = {"Container" , "Connector" }; |" , в сам код или в "Custom data".
Azariasz 27 Sep, 2021 @ 11:26am 
@Jared_T
Ok, now I do feel like a dolt. Just needed to read "the manual" XD Thank you for your reply.
Jared_T  [author] 23 Sep, 2021 @ 9:37am 
@Azariasz
First go to the programmable block and in the Text_Panel_Identifications section find the CockpitScreenID and set the number inside the [] to the screen you want. The script cannot restore the screen after it has changed it, so setting the number before tagging the cockpit is easiest. Or at the very least look and memorize what is on the screens in the cockpit, so you can put them back if you do not like the screen the script uses and decide to change it later. Then just rename the cockpit by putting the tag [Cargo Info] into the name of the cockpit.

Hope that helps.
Azariasz 22 Sep, 2021 @ 1:12am 
Kindda similar question to the assimilater's question - How do I put the image from the programmable block running this script ona LCD in a cockpit? I read the MMaster's manual, but I can't make heads or tails out of it. Is there a simpler way? Or one that is dolt-friendly? XD
assimilater 28 Jan, 2021 @ 3:16am 
@Jared_T You're awesome dude!
Jared_T  [author] 27 Jan, 2021 @ 6:37pm 
@assimilater
Sorry for the late reply, I was doing some maintenance on my computers water cooling, and I had neglected it for too long and it was in bad shape. But I am back up and running now, anyway, I guess I do not have the LCDs documented well.

You need to put the tag [Cargo LCD] into the NAME of the Display Block. After that, the script should load the settings into the custom data. If the script does not load the Custom Data, just clear everything from the custom data and it should load LCD default settings.