SC2Mapster.com Wiki

SC2 API / Functions / CatalogFieldValueGet

CatalogFieldValueGet

string CatalogFieldValueGet (int catalog,  string entry,
                              string path, int player);

Value from a XML file.

Parameters

int catalog

XML File you want to read the data from. If you want to add it inside the map mpq, it must be located in the Base.SC2Data\GameData\ folder.

string entry

ID of the XML Root Node.

If this node contains a parent attribute and the value cannot be found in the current node, the search will be recursively called on the parent.

string path

Path of the value.

  • "Name": Simple node with a value attribute.
    <Name value="42" />
    
  • "Name.property": Simple node with a custom attribute.
    <Name property="42" />
    
  • "NameArray[First]": Array with an id.
    <NameArray id="First" value="42" />
    <NameArray id="Second" value="43" />
    
  • "NameArray[0]": Array without id.
    <NameArray value="42" />
    <NameArray value="43" />
    
  • "Name.SubName": Child element.
    <Name>
      <SubName value="42" />
    </Name>
    
int player

With set catalog field value, you can adjust the catalog for a specific player, thus this value here is for retrieving the value that might be adjusted for the given player.

Examples

Example #1: AbilData.xml
<?xml version="1.0" encoding="us-ascii"?>
<Catalog>
    <CAbilBuild default="1" id="TerranAddOns">
        <!-- "Type": "AddOn" -->
        <Type value="AddOn"/>

        <!-- "InfoArray[Build1].Unit": "TechLab" -->
        <InfoArray index="Build1" Unit="TechLab" Time="25"> 

            <!-- "InfoArray[Build1].Resource[Minerals]": "50" -->
            <Resource index="Minerals" value="50"/>
            <Resource index="Vespene" value="50"/>
        </InfoArray>
        <InfoArray index="Build2" Unit="NuclearReactor" Time="25">
        </InfoArray>
    </CAbilBuild>

    <CAbilBuild id="BarracksAddOns" parent="TerranAddOns">
        <BuildMorphAbil value="BarracksLiftOff"/>
        <!-- "Type": "Addon" -->
    </CAbilBuild>
Example #2: Get Values
// Simple node with a value attribute
CatalogFieldValueGet(c_gameCatalogAbil,
                     "TerranAddOns",
		     "Type",
		     -1);
// AddOn

// Array node with a custom attribute
CatalogFieldValueGet(c_gameCatalogAbil,
                     "TerranAddOns",
		     "InfoArray[Build1].Unit",
		     -1);
// TechLab

// Simple Sub array node with a value attribute
CatalogFieldValueGet(c_gameCatalogAbil,
                     "TerranAddOns",
		     "InfoArray[Build1].Resource[Minerals]",
		     -1);
// 50

// Inherited property from parent
CatalogFieldValueGet(c_gameCatalogAbil,
                     "BarracksAddOns",
		     "Type",
		     -1);
// AddOn

See also

You must login to post a comment. Don't have an account? Register to get one!

Facts

Date created
Mar 15, 2010
Last updated
Nov 27, 2010

Authors