How to pull the mass of a subgrid (or total mass of all connected grids) into a programmable block script?

How to pull the mass of a subgrid (or total mass of all connected grids) into a programmable block script? - From above crop anonymous barefoot child in jeans standing on weigh scales on tiled floor of bathroom

Related to another question about how thrusters interact with subgrids, I've decided that this is an excuse to try learning C# Scripting for the Programmable Block (PB).

My plan is to have a pair of thrusters tasked to the PB, which will monitor the mass of the subgrids and set the thrust override for those two thrusters accordingly. This should roughly cancel out the variable mass of the drills as they go about their business. I figure I'll also have it monitoring the drill mass and automatically turn off the drills when they're full. (Why not, right?)

I've looked over the API information, but I'm new enough to this kind of coding that I'm not entirely sure what I'm even looking for, so I'm looking for a place to start:

What would the line of code be to take the mass of a subgrid(s) to assign it to a float variable?






Pictures about "How to pull the mass of a subgrid (or total mass of all connected grids) into a programmable block script?"

How to pull the mass of a subgrid (or total mass of all connected grids) into a programmable block script? - People Walking on Street
How to pull the mass of a subgrid (or total mass of all connected grids) into a programmable block script? - Masses Of Dark Clouds
How to pull the mass of a subgrid (or total mass of all connected grids) into a programmable block script? - People on Stadium Event





Space Engineers Tutorial: Intro to Scripts with Automatic LCDs by MMaster (survival tutorials, tips)




Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Ketut Subiyanto, Mo7sen Mohammad, Brett Sayles, Wendy Wei