Space Engineers

Space Engineers

Not enough ratings
Cargo Utilization Light
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
2.221 KB
6 Feb, 2015 @ 10:46am
1 Change Note ( view )

Subscribe to download
Cargo Utilization Light

Description
Use a light to indicate Cargo Utilization

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.

Blocks Required:
Timer Block set to run the programmable block on interval and set to start timer (i use 5 seconds)
Programmable block
a light block or blocks (spotlight or interior light)
a cargo container or containers

Test Ship blueprint: https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=387942067

Args:
zeroPercent: Color to indicate 0% utilization
hundredPercent: Color to indicate 100% utilization
lightName: Name of Light to change color for
blinkOnEmpty: (Optional) Defaults to True
If utilization = 0% will blink starting color
blinkOnFull: (Optional) Defaults to True
if utilization = 100% will blink ending color
blinkInterval: Interval to blink in seconds
blinkLength: Percent of Interval where light is on
50% is 50.0F NOT 0.5F

Returns: Void

Raises: Void

Notes:
Reference Color by RGB:
new VRageMath.Color(int R, int G, int B)
There are 9 other options for creating a color based on different values
see mod documentation for more

Colors with names as of 2/6/2015:
A, AliceBlue, AntiqueWhite, Aqua, Aquamarine, Azure, B, Beige, Bisque
Black, BlanchedAlmond, Blue, BlueViolet, Brown, BurlyWood, CadetBlue
Chartreuse, Chocolate, Coral, CornflowerBlue, Cornsilk, Crimson, Cyan
DarkBlue, DarkCyan, DarkGoldenrod, DarkGray, DarkGreen, DarkKhaki
DarkMagenta, DarkOliveGreen, DarkOrange, DarkOrchid, DarkRed
DarkSalmon, DarkSeaGreen, DarkSlateBlue, DarkSlateGray, DarkTurquoise
DarkViolet, DeepPink, DeepSkyBlue, DimGray, DodgerBlue, Firebrick
FloralWhite, ForestGreen, Fuchsia, G, Gainsboro, GhostWhite, Gold
Goldenrod, Gray, Green, GreenYellow, Honeydew, HotPink, IndianRed
Indigo, Ivory, Khaki, Lavender, LavenderBlush, LawnGreen, LemonChiffon
LightBlue, LightCoral, LightCyan, LightGoldenrodYellow, LightGray
LightGreen, LightPink, LightSalmon, LightSeaGreen, LightSkyBlue
LightSlateGray, LightSteelBlue, LightYellow, Lime, LimeGreen, Linen
Magenta, Maroon, MediumAquamarine, MediumBlue, MediumOrchid
MediumPurple, MediumSeaGreen, MediumSlateBlue, MediumSpringGreen
MediumTurquoise, MediumVioletRed, MidnightBlue, MintCream, MistyRose
Moccasin, NavajoWhite, Navy, OldLace, Olive, OliveDrab, Orange
OrangeRed, Orchid, PackedValue, PaleGoldenrod, PaleGreen
PaleTurquoise, PaleVioletRed, PapayaWhip, PeachPuff, Peru, Pink, Plum
PowderBlue, Purple, R, Red, RosyBrown, RoyalBlue, SaddleBrown, Salmon
SandyBrown, SeaGreen, SeaShell, Sienna, Silver, SkyBlue, SlateBlue
SlateGray, Snow, SpringGreen, SteelBlue, Tan, Teal, Thistle, Tomato
Transparent, Turquoise, Violet, Wheat, White, WhiteSmoke, Yellow
YellowGreen
11 Comments
Ibigpapa  [author] 6 Jun, 2019 @ 2:47pm 
Jared_T Glad to hear someone took up the reigns and improved it. Wish i had put the code on github way back when, So you get to take the title :D
Jared_T 27 May, 2019 @ 11:23pm 
Actually, you may have already have noticed, but the script that W4stedspace used was this one, https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1405630071 .
Granted, I used your script as a base / inspiration for the script, it is quite different from yours although does the same thing. I do apologize for not asking you if I could take your script and overhaul it. However, the last time your script was updated was back in 2015, and while I have used your script for a long time it has become a bit outdated. Therefore, I thought it would fair game to do my own support for the script. My current version of the script has quite a few more features than the original, such as including and balancing drill inventory.
Ibigpapa  [author] 24 May, 2019 @ 1:10pm 
Thats awesome
xar582 12 May, 2019 @ 10:18pm 
W4stedspace used this script dack in december 2018 in the episode called, Space Engineers: The Danger Zone - Uncooperative Survival #61 at about the 2hrs 30min point and he had I think 6 lights on this small ship. it also showed him setting the script up to work.
Ibigpapa  [author] 12 May, 2019 @ 4:57pm 
I don't even think i have the code for this any longer. Been since 2015 for me. Sorry it's only using 2 lights
charmander1 12 May, 2019 @ 5:20am 
right now the script is only using 2 lights how do i get it to use more
Haram Bae 31 May, 2015 @ 12:50am 
Late to party, but can you force it to only read only certain containers?
jarhead 26 Feb, 2015 @ 6:57pm 
not bad
15 7 Feb, 2015 @ 2:08pm 
Cool idea!
Ibigpapa  [author] 6 Feb, 2015 @ 1:40pm 
Buzzed Bear,

This script generates a color value between the starting color and ending color using interpolation function built into the vrage library.

It technically handles every percent between 0 and 100. I believe there is an exception to that is if you choose 2 colors very close to each other.

an example though not correctly calculated

starting R: 0; G: 255; B: 0
ending R:255; G:0; B:0
currently at 55%

ending color will look something like R: 140.25; G: 140.25; B:0;

for the actual math behind it look at interpolation(LERP) http://en.wikipedia.org/wiki/Linear_interpolation