Large grid small oxygen tank has empty BlockDefinition.SubtypeId

qqww shared this bug 4 months ago
Won't Fix

In the past I can use BlockDefinition.SubtypeId to determine is this tank is an oxygen tank or hydrogen tank in my in-game script in program block. but after recent update I found this subtypeid is empty for large grid small oxygen tank, make my script stop working. For small grid oxygen tank this id still exists. so, I think this could be a bug.

Replies (1)

photo
1

Hello Engineer,

Thank you for reaching out to us on the forum.

Could you please share the script where you’re encountering this issue? Also, please share the grid setup you’re using with this script. This information will help us investigate the issue further.

Kind regards,

Keen Software House: QA Department

photo
1

The grid is simple: one large grid oxygen tank and one hydrogen tank, and a program block and a battery. It use "Oxygen" keyword to determine if this tank is oxygen tank or hydrogen tank. after that, set tank to Stockpile.


Sorry I don't know how to export game grid as file.


Code snippet is as below:


var isDocked = true;
var handleHydrogenTank = true;
var handleOxygenTank = true;

List<IMyGasTank> blocks = new List<IMyGasTank>();
GridTerminalSystem.GetBlocksOfType(blocks, b =>
    b.CubeGrid == Me.CubeGrid &&
    (
        (handleHydrogenTank && b.BlockDefinition.SubtypeId.IndexOf("Hydrogen", StringComparison.OrdinalIgnoreCase) >= 0) ||
        (handleOxygenTank && b.BlockDefinition.SubtypeId.IndexOf("Oxygen", StringComparison.OrdinalIgnoreCase) >= 0)
    )
);
foreach (var block in blocks)
{
     block.Stockpile = isDocked;
}

photo
1

Hello Engineer,

Thank you for reaching our forum with this issue.

We have added it into our internal system.

Kind Regards,

Keen Software House: QA Department

photo
1

Hello Engineer,

After discussing this issue internally, we would like to inform that the SubtypeId is not missing it is simply not defined in this case. The OxygenTank represents the base definition and, as such, does not have a SubtypeId because it is the defining type itself.

This can sometimes cause confusion when a script assumes that every definition contains both a TypeId and a SubtypeId. There are several other blocks that do not have a SubtypeId, and this is expected behavior. Scripters and modders should account for this possibility and fall back to using the TypeId when a SubtypeId is not defined.

At this time, we do not plan to change this behavior, as doing so could potentially break existing builds or scripts that rely on the current definition structure.

Thank you for your understanding.

Kind Regards,

Keen Software House: QA Department

photo
Leave a Comment
 
Attach a file
You can't vote. Please authorize!
You can't vote. Please authorize!
You can't vote. Please authorize!
You can't vote. Please authorize!
You can't vote. Please authorize!
You can't vote. Please authorize!
You can't vote. Please authorize!
You can't vote. Please authorize!
You can't vote. Please authorize!