Space Engineers

Space Engineers

27 ratings
Cargo Capacity Script
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
3.660 KB
Apr 26, 2019 @ 12:57am
Apr 26, 2019 @ 1:52am
2 Change Notes ( view )

Subscribe to download
Cargo Capacity Script

Description
This is a simple script that I use for my mining ships, but can be used to monitor the capacity of any cargo containers, connectors or other storage blocks used on any ship of any grid. It is set up for vanilla gaming mode but supports the DLC Pack Industrial Cockpit. Any other modded cockpit can also be used to determine the screen you want start at the top listed display surface which will be "0" and proceed down the list numerically. It requires at a minimum, 1 cockpit, 1 storage block with a group name, 2 timers, optionally lights can be used as a visual alert.

How to Use
Build a ship with any number of storage blocks including drills, connectors, cargo containers, cockpits, etc, Group these and give them any name you wish. change the name Capacity in the script to that name...
// What the your cargo group.
const string groupName = "Capacity"; to

// What the your cargo group.
const string groupName = "Miner Capacity";

next do the same for the cockpit
// What the cockpits name needs to be.
const string displayName = "Cockpit"; to

// What the cockpits name needs to be.
const string displayName = "Miner Cockpit";

The timers can be set to the below names or renamed the same way as the above strings were
// The Timer to be triggered When Full
const string timerName = "Timer Full Cap";

// The Timer to be Triggered When Capacity of Cargo Group is at 0 pct for unloading
const string timerName2 = "Timer Unloaded";

Finally select the cockpit display you want to script to display on and set it to text and images
In the script do the following:

//Change the number in the following line to match the selected display you want. Used list below for Reference
display = cockpit.GetSurface(2);

//GetSurface Locations within Cockpits
//Large Grid
// Industrial - 0= Large Display, 1= Top Left, 2= Top Center, 3= Top Right. 4= Keyboard, 5= Number Pad
// Utility - 0= Top Center Screen, 1= Top Left, 2= Top Right, 3= Keyboard, 4= Bottom Left, 5= Bottom Right
//Small Grid
// Fighter - 0= Top Center Screen, 1= Top Left, 2= Top Right, 3= Keyboard, 4= Bottom Center, 5= Number Pad
// Industrial - 0= Top Left, 1= Top Center, 2= Top Right. 3= Keyboard, 4= Number Pad
// Utility - 0 = Center Display, 1 = Left Display, 2 = Right Display, 3 = Keyboard
Adjust the display screens settings to what ever you want one exception is location, I recommend center as it is set up for that.

If you get an exception error that means one of your user defined blocks are not named correctly, or you have blocks in the group that are not storage blocks, ie Large Ion Thruster, these will cause an exception. If you get an exception and correct the discrepancy you will have to go back into the script and check it again.

How it works
As you are mining or transferring cargo to you cargo group, the script monitors that groups given capacity, as it fills up it will give a visual display in text of percentage as well as a visual representation of the level used. when it reaches 99 percent capacity it will trigger the full timer, when cargo is moved out of the storage containers when capacity reaches 0 it triggers the cargo empty timer.

Setting up you timers, timers are basically used as relays, in my case I group my drills together and place them in the full timer, I also place a interior light on the outside of my ship usually somewhere near the real central axis. I set it to turn on when the timer is activated and my drills are turned off. the second timer can be used to turn the light back off but I don't recommend using it to turn drills back on.

Once every thing is up and running the program block should display capacity percent in the right hand column of the control panel.

If you have any question please leave them below, If you don't like this script, oh well don't use it. Any suggestions can be left below but fair warning, I'm not a programmer I took me a long time to get this working and with out all the help form people on Keen's discord channel answering my questions and talking me through setting this up I would of said heck with it so thanks Malware and the rest for helping me get this finished.
27 Comments
★UP | julius ★TeamPyro★ Sep 18, 2021 @ 1:26pm 
Join single player, load it into a programmable block, copy past it from there in a text document, go back to multiplayer, past it there.
Red_Death Sep 11, 2021 @ 2:31pm 
The "Browse Scripts" button doesn't work on our multi player server. Where can I go to copy the script text directly to paste it into the program block? Thanks
★UP | julius ★TeamPyro★ Feb 14, 2021 @ 11:46am 
@wlan___kabel it does work, the only thing stupid is the person complaining that he cant get it to work.
wifi___cable Feb 14, 2021 @ 9:06am 
stupid shit, doesn't work.
★UP | julius ★TeamPyro★ Jan 2, 2021 @ 1:53pm 
@Steve2para I sadly dont know how to help you with this, copy pasted the whole script and not just the changed lines, maybe you can try that.
steve2para Dec 28, 2020 @ 12:43pm 
But where is the script kept in the game folders? I did copy the text and try to paste it from the clipboard while using the in-game editor but the option to paste wasn't there.
I started looking in all the game folders and searched for the script by name but I'm lost.

Thanks for your help.
★UP | julius ★TeamPyro★ Dec 28, 2020 @ 6:37am 
@steve2para In the comment from the redditor it says what lines he added. You could also just copy the whole LCD script and use it to replace the other one completely, its essentially the same script with LCDs added so it shouldnt be a problem.
steve2para Dec 27, 2020 @ 11:18pm 
How do I paste the edits for the LCDs into the original script? Where is it?
DonDepresor Dec 22, 2020 @ 3:13am 
@lylesonders I just published a variation on your script. It allows to disable pinting to the cockpit screen with a boolean flag.

Check it out here: https://steamcommunity.com/sharedfiles/filedetails/?id=2329686551
★UP | julius ★TeamPyro★ Nov 11, 2020 @ 8:41am 
lylesonders's i hope you dont mind me posting this here, if you dont want this here feel free to remove it.

For anyone who wants to project the text on an LCD screen: https://www.reddit.com/r/spaceengineers/comments/jr0qd4/help_with_makingmodifying_scripts/gbw8ytz?utm_source=share&utm_medium=web2x&context=3

I asked on reddit for help and this amazing redditor called DieDae helped me out. The script that he links in his comment is the script from lylesonders's which he *upgraded* to now also work with LCD pannels. All credit for the original script goes to lylesonders's and all credit for the upgrade goes to the redditor DieDae.