ContainerType Definition

From Space Engineers Wiki
Jump to navigation Jump to search

A tutorial on how to reference these in prefabs: Cargo Loot.

They can also be referenced by wildlife to have loot on their corpses, see Bots.sbc.

Wrapper & Entry Example

<?xml version="1.0"?>
<Definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <ContainerTypes>
    <!-- One or more ContainerType entries are placed here. -->
  </ContainerTypes>
</Definitions>
A typical ContainerType entry

The spider loot from the game's ContainerTypes.sbc.

<ContainerType CountMin="1" CountMax="2">
  <Id>
    <TypeId>ContainerTypeDefinition</TypeId>
    <SubtypeId>SpiderLoot</SubtypeId>
  </Id>
  <Items>
    <Item AmountMin="4" AmountMax="7">
      <Frequency>1.0</Frequency>
      <Id>
        <TypeId>Ingot</TypeId>
        <SubtypeId>Magnesium</SubtypeId>
      </Id>
    </Item>
    <Item AmountMin="2" AmountMax="8">
      <Frequency>5.0</Frequency>
      <Id>
        <TypeId>Component</TypeId>
        <SubtypeId>Motor</SubtypeId>
      </Id>
    </Item>
    <Item AmountMin="100" AmountMax="438">
      <Frequency>4.0</Frequency>
      <Id>
        <TypeId>Component</TypeId>
        <SubtypeId>SteelPlate</SubtypeId>
      </Id>
    </Item>
    <Item AmountMin="5" AmountMax="45">
      <Frequency>4.0</Frequency>
      <Id>
        <TypeId>Component</TypeId>
        <SubtypeId>Computer</SubtypeId>
      </Id>
    </Item>
    <Item AmountMin="2" AmountMax="5">
      <Frequency>1.0</Frequency>
      <Id>
        <TypeId>Component</TypeId>
        <SubtypeId>Display</SubtypeId>
      </Id>
    </Item>
    <Item AmountMin="10" AmountMax="30">
      <Frequency>4.0</Frequency>
      <Id>
        <TypeId>Component</TypeId>
        <SubtypeId>Construction</SubtypeId>
      </Id>
    </Item>
    <Item AmountMin="5" AmountMax="15">
      <Frequency>2.0</Frequency>
      <Id>
        <TypeId>Component</TypeId>
        <SubtypeId>LargeTube</SubtypeId>
      </Id>
    </Item>
    <Item AmountMin="1" AmountMax="1">
      <Frequency>0.25</Frequency>
      <Id>
        <TypeId>Component</TypeId>
        <SubtypeId>SabiroidPlushie</SubtypeId>
      </Id>
    </Item>
  </Items>
</ContainerType>

Elements

CountMin

CountMin (attribute[1])
Type: Int32Default0
Required. Random range between this inclusive and CountMax exclusive, for how many times to roll for items.

CountMax has to be 1 higher than the intended max amount of rolls.

Alternatively, if both numbers are equal then it will use that exact number and not be random.

CountMax

CountMax (attribute[1])
Type: Int32Default0
Required. See CountMin.

Items

<Items>
Type: ContainerTypeItem[]Defaultnull
Required. The loot table.

When the prefab using this definition spawns, it will randomly pick one of the entries. This can be repeated based on CountMin & CountMax.
Once an entry is picked, it cannot be picked again for the same container. Also, if the item being spawned happems to exist in the container, its existing amount is subtracted from the randomly picked amount.
If the target container's inventory has a constraint that doesn't allow certain items, those items won't be able to be spawned by this either.

Each <Item> can contain:

AmountMin (attribute[1])Type: MyFixedPointDefault(error!)
Required. The random range for the amount of this item to spawn if picked.

Both min and max are inclusive.

The value can have decimals and the randomized result will too, but only for Ore and Ingot types, for everything else it will round up.
AmountMax (attribute[1])Type: MyFixedPointDefault(error!)
Required. See AmountMin.
Set (attribute[1])Type: stringDefault(empty)
Makes all items with the same set name be spawned together when any of them is picked.
Does not work for sets outside of this definition.
<Id>Type: SerializableDefinitionIdDefault(invalid)
Required. Type and Subtype of an item to spawn if this is picked.
Example:
<Id Type="Component" Subtype="SteelPlate" />
<Frequency>Type: SingleDefault1
Weight for this item that affects its chance to spawn.

Its exact chance depends on the frequency added up from all the other items in this definition.

Cannot be lower than 0.
<StoryCategory>Type: stringDefaultGeneric
Only relevant if the item Id is a Datapad.

SubtypeId of a StoryCategory Definition, a random story from that is picked and written to the spawned datapad.

This will not do multiple stories if the spawned item amount is more than one. If you want multiple stories then duplicate entries and leave amounts to 1.
Example:
<Items>
  <Item AmountMin="1" AmountMax="3" Set="Tier1">
    <Id Type="Datapad" Subtype="Datapad" />
    <Frequency>2</Frequency>
	<StoryCategory>Spam</StoryCategory>
  </Item>
  <!-- ... -->
</Items>

(Top) | From DefinitionBase:

Common

Id

<Id>
Type: SerializableDefinitionIdDefault(invalid)
The type and subtype combined make up a unique identifier for this definition.

If two definitions use the same Type+Subtype (Subtypes are only unique per Type), then the last to load will override the first one(s). For more details see Things to know about SBC.

<TypeId>Type: stringDefault(invalid)
Must be an existing type with or without the "MyObjectBuilder_" prefix.

Some types require an xsi:type, refer to the vanilla files for the exact pairing.

TypeId vs xsi:type
<SubtypeId>Type: stringDefault(empty)
This can be invented and only needs to be unique per TypeId.

Vanilla game re-uses some subtypes over multiple types (e.g. Iron is used for Ore type and Ingot type).

An empty value is also a valid subtype (which vanilla also uses on at least 5 blocks).
Type (attribute[1])Type: stringDefault(invalid)
Same behavior as <TypeId>, do not define both.
Subtype (attribute[1])Type: stringDefault(empty)
Same behavior as <SubtypeId>, do not define both.
Example:
<Id>
  <TypeId>CubeBlock</TypeId>
  <SubtypeId>FancyTable</SubtypeId>
</Id>

Because it has attribute alternatives it can also be declared as:

<Id Type="CubeBlock" Subtype="FancyTable" />

DisplayName

<DisplayName>
Type: StringDefaultnull
If the object defined here is visible anywhere in the game GUI, this would be the name shown for it. In cases where it is used, it is very much required.

Can be plain-text.
If the text contains DisplayName_ then:

Description

<Description>
Type: StringDefaultnull
Optional. If the object defined here is shown with a description in the game GUI (Hotbar/G-menu, HUD, etc) then this is the place to write it.

Can be plain-text.
If the text contains Description_ then:

If the final text (plain, localized or variable-replaced) contains {0}, {1}, etc, then they will replaced by kb&m control binds defined in <DescriptionArgs>.

DescriptionArgs

<DescriptionArgs>
Type: StringDefaultnull
Optional. A comma-separated list of control IDs which are referenced in <Description> by {number} tags, which then get replaced by the keyboard or mouse bind that the viewer has for those controls.
Example:
<Description>Press {0} to fire, {1} to change color, {2} to interact.</description>
<DescriptionArgs>PRIMARY_TOOL_ACTION,CUBE_COLOR_CHANGE,USE</DescriptionArgs>

And each player will see their current binds for those actions.

The control IDs can be found in your %appdata%/SpaceEngineers/SpaceEngineers.cfg at the ControlsButtons section.

Icon

<Icon>
Type: String[]Defaultnull
Icon(s) for the definition which may or may not be used depending on the definition type.

Path to a .dds or .png file relative to current mod's folder. Falls back to game folder if not found in current mod. Referencing assets in other mods

Can be declared multiple times which will stack icons on top of eachother, however it will not work for all definitions.

Known definitions to work or not work with multiple icons
  • Working: Blocks, BlockVariantGroups and component items seen in G-menu, BlockInfo (HUD right side) and toolbars; Blueprints in terminal production tab; Blocks and PhysicalItems in gamepad HUD.
  • Partial: Blocks seen in terminal.
  • Not working: HandItems (uses PhysicalItem's icon instead); Blocks and BlockVariantGroups seen in build planner, radial menu and some economy GUIs; PhysicalItems in economy GUIs and stores; Prefabs in stores; BlueprintClass (tabs) in terminal production tab; BankingSystemDefinition (Game\BankingSystem.sbc); Emotes (both kinds of definitions) in gamepad HUD; Block skins; RespawnShips.
  • Special cases: Economy contracts, FactionIcons Definition.

DLC

<DLC>
Type: String[]Defaultnull
Optional. The DLC subtypeId that this definition will require.

For the IDs, refer to <SE>\Content\Data\Game\DLCs.sbc.
Can be declared multiple times to require multiple DLCs.

Most definition types won't check for this, the ones that do: blocks, emotes and possibly anything else that can be placed in the toolbar.

AvailableInSurvival

<AvailableInSurvival>
Type: BooleanDefaulttrue
Depends on the definition if it uses this, and if it does then this determines whether it can be accessible in survival game mode.

Currently known definitions that do use this:

Public

<Public>
Type: BooleanDefaulttrue
If the definition is visible or accessible in some cases.
For blocks, this only hides them and they can still be built using projectors and other means.

Enabled

Enabled (attribute[1])
Type: BooleanDefaulttrue
If set to false it will remove the definition after it's been loaded.
Example usage:
<Definition Enabled="false">

The "Definition" above is the opening element that for the entire definition, not an inner node like <DisplayName> is.

The opening node can have a different name for other definitions, some examples <Component>, <Blueprint>, etc.

xsi:type

xsi:type (attribute[1])
Type: stringDefaultnull

Name of an object that this definition will be deserialized as.
Sometimes required, depends on the definition. The wiki page for any given definition will mention at the top what xsi:type it requires, if any. The game's sbc files are also a reference on what xsi:types are required for a given definition.

This attribute is available on all elements and comes from the XML specification. This game relies on this attribute to change which sub-definition object is used to deserialize that element's contents. It's what allows, for example, a thruster to have unique elements (such as <MinPlanetaryInfluence>) that no other block definitions have.

For more details on how this relates to the TypeId, and usage examples, see: Things to know about SBC - TypeId vs xsi:type.