Space Engineers

Space Engineers

36 ratings
Ammo Manager
2
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
269.961 KB
29 May, 2021 @ 9:03am
8 May, 2023 @ 11:20am
7 Change Notes ( view )

Subscribe to download
Ammo Manager

Description
Ammo Manager

Introduction

Weapons kinda suck at sharing ammo. In the event that one of them actually draws ammo from any containers, you just know its gonna hog it all rather than sharing. This script does a robin hood: it yoinks the excess ammo and shares it between the other weapons on the same network. Sound cool? That’s not all my friend, it also displays all your weapons ammo levels with pretty progress bars and colours!

Features

  • Equalizes ammo between all connected weapons. e.g. if there are 50 NATO cases and 2 connected turrets, each will get 25 cases
  • Works on a per network basis, if there are 50 NATO cases and 5 turrets but only 2 turrets are connected to each other, one of which has all the ammo, both of the connected turrets get 25 and the others get 0
  • Works on a per ammo basis. Meaning if there are 2 missile turrets and 2 gatling turrets on the same network, with 20 missiles, the missile turrets each get 10 (rather than 5)
  • Diverts ammo from inactive weapons toward currently engaged weapons. Even if you’re running a little low on ammo, your hot weapons will keep shooting until the very end
  • Works with WeaponCore or Vanilla turrets (although mostly tested with WeaponCore)
  • Lots of pretty (imo) display options with ammo and fill level stats for containers, weapons, or both, as well as single-line versions for quick combat checks ### Configuration

If you just want the ammo balancing part, no configuration is needed, just slap it in a PB and forget about it.

This scripts config for displaying on LCDs is a bit involved, see the top of the script for detailed instructions.

For a basic example however:

[AmmoMgr 0] type = Weapons

This will display a scrolling view of the weapons on the grid and their ammo levels. Change it to Containers to view the containers instead, or Full for both (see top of script for more options)

Docking via connectors

This script watches only inventories on the same grid. This means it will not cross connector boundaries but it will still manage custom turrets (i.e. connections through rotors or hinges). Currently connectors are the only supported way to dock if you wanna keep the script running on both grids.

Multiple instances on the same grid (or docking via merge-blocks)

This script will probably mess up and implode or something if you have multiple PBs running it on the same grid. I’m not gonna fix that one, if you have multiple instances of the script on the same grid you are doing something very wrong… or using merge blocks for docking. This script is NOT currently compatible with merge blocks. I personally don’t use them for docking and I lack the experience to implement compatibility without impacting performance. If for some god forsaken reason you do use them for docking, just turn one of the scripts off beforehand.

Compatibility with Isy’s inventory management script

This script will fight the management script by default. You can fix this by adding "Locked" to the name of each weapon (e.g. with a renamer script). This will prevent Isy’s from pulling items out of the block.

License

This script is GPLv3. That means you can reupload it or any script that contains it as long as you:

  • Keep all existing license notices intact
  • Credit me
  • List your changes (easiest way is with git and github repo)
  • Make all the source code of the relevant script available freely and publicly with no restrictions placed on its access.
  • Make your script GPLv3 as well
  • Give me your first born child

(ok that last one isn’t actually legally binding)

If in doubt, ask me in comments or the Keen discord (@Natomic). Full license is available here[github.com]. I reserve the right to ask for your script to be yeeted if you have reused my script without obeying the license.

Source

The full source code for this script can be found here: https://github.com/0x00002a/AmmoMgr

MDK

This script is developed and deployed using the MDK[github.com]. If you wanna get into SE scripting, check it out. Also check out the Keen Discord, lots of helpful people on there.

Stuff used in screenshots


Note for crash on startup

If you are getting something along the lines of "Object reference not set to an instance of an object" then make sure you are using the latest version of the script

Note for "script too complex errors"

Make sure you are running at least version 0.5.3. If it still happens, drop a comment preferably with a link to a world this happens in

72 Comments
Cosclouds 2 Oct, 2024 @ 4:32am 
So im reading your instruction and they dont really make any sense add AmmoMgrLCD to the name yes dose not display anything changed to to text and still nothing please can you explain in more detail how i get this to display on screen im gettting no errors program is running not displaying tho
Fallenq 29 Jul, 2024 @ 12:18pm 
Script too complex error.
I'm on the latest version.
The ship on which script is has a lot of inventories (around 400)
it crashes on grouping
Fallenq 8 Jul, 2024 @ 9:04am 
laggy af with a lot of turrets
Calmaria 15 Dec, 2023 @ 12:48am 
Vanilla Scrap based playthrough... Works perfectly keeping me alive :)
Roze-Assazin 11 Nov, 2023 @ 3:32am 
so if i mail you my fisrt born child cause i dont want it your take it
CDClone 30 Sep, 2023 @ 3:52am 
just loaded it up in a PB, it runs for a nano secund and then it says "Script execution terminated, script is too complex. Please edit and rebuild script.

now what do i do? O_O
jokerace45 12 May, 2023 @ 6:00pm 
It doesn't seem to balance or work correctly with Arynx Weapons Mod.
https://gtm.steamproxy.vip/sharedfiles/filedetails/?id=2530716039
Natomic  [author] 11 May, 2023 @ 10:52am 
Ah wait, does that prevent welders from working properly. That is a problem if so
Natomic  [author] 11 May, 2023 @ 10:51am 
@June are the turrets all full? Welders have an inventory so they should be a valid target for storing ammo, just not sharing it with turrets
Junebug 9 May, 2023 @ 5:16pm 
This script is putting ammo in welders? Any idea whats wrong?