# Unit Type From String

Grammar — Unit type from s
FlagsNative | Function

Converts a string to a unit type. If the string does not match a valid unit type, the result will be empty.

# Arguments

  • string — String

Returns — string<gamelink::Unit>

native string UnitTypeFromString(string inString);

Category: Unit / Properties

# Examples

campaigns/libertystory.sc2campaignbase.sc2data/TriggerLibs/CampaignLib.galaxy:8982

    for ( ; ( (auto62551DF2_ai >= 0 && lv_index <= auto62551DF2_ae) || (auto62551DF2_ai < 0 && lv_index >= auto62551DF2_ae) ) ; lv_index += auto62551DF2_ai ) {
        if ((BankKeyExists(lp_sourceBank, lv__SectionName, IntToString(lv_index)) == true)) {
            libCamp_gf_TS_HelpUnitsPanel_AddEnabledUnitType(UnitTypeFromString(libCamp_gf_TS_LoadTransitionVarString(lp_sourceBank, lv__SectionName, IntToString(lv_index), "")));
        }

campaigns/libertystory.sc2campaignbase.sc2data/TriggerLibs/CampaignLib.galaxy:9721

        }

        libCamp_gv_tS_StoryRoomUnitTypes[lv_roomIndex][libCamp_gv_tS_StoryRoomUnitTypeCount[lv_roomIndex]] = UnitTypeFromString(lv_item);
    }
}

campaigns/swarmstory.sc2campaignbase.sc2data/TriggerLibs/SwarmCampaignLib.galaxy:13186

    lv_index = 1;
    for ( ; ( (auto3D41700D_ai >= 0 && lv_index <= auto3D41700D_ae) || (auto3D41700D_ai < 0 && lv_index >= auto3D41700D_ae) ) ; lv_index += auto3D41700D_ai ) {
        libSwaC_gf_ZS_HelpUnitsPanel_AddEnabledUnitType(UnitTypeFromString(libSwaC_gf_ZS_LoadTransitionVarString(lp_sourceBank, lv__SectionName, IntToString(lv_index), "")));
    }
    lv__SectionName = libSwaC_gf_ZS_BankSectionName(lp_map, "Tips");

campaigns/voidstory.sc2campaignbase.sc2data/TriggerLibs/VoidCampaignLib.galaxy:7177

    lv_index = 1;
    for ( ; ( (autoE1BE8001_ai >= 0 && lv_index <= autoE1BE8001_ae) || (autoE1BE8001_ai < 0 && lv_index >= autoE1BE8001_ae) ) ; lv_index += autoE1BE8001_ai ) {
        libVoiC_gf_ZS_HelpUnitsPanel_AddEnabledUnitType(UnitTypeFromString(libVoiC_gf_PC_LoadTransitionVarString(lp_sourceBank, lv__SectionName, IntToString(lv_index), "")));
    }
    lv__SectionName = libVoiC_gf_PC_BankSectionName(lp_map, "Tips");

mods/heroesbrawlmods/arenamodemods/arenashared.stormmodbase.stormdata/LibMArS.galaxy:83

    }

    if ((UnitGetType(lv_arenaHero) == UnitTypeFromString("HeroRagnaros"))) {
        SetTalentEnabled(("RagnarosLavaWave"), false);
    }

mods/heroesmapmods/battlegroundmapmods/blackheartsbay.stormmodbase.stormdata/LibBBAY.galaxy:494

    lv_townHall = libGame_gv_townTownData[lv_town].lv_structureUnits[libGame_gv_townTownData[lv_town].lv_townHallIndex];
    if ((UnitIsAlive(lv_townHall) == false)) {
        UnitGroupRemove(lv_buildings, UnitGroupUnit(libNtve_gf_UnitsInRegionWithAllianceToPlayerMatchingCondition(UnitTypeFromString("RagnarosBigRag"), "", "", c_playerAny, c_unitAllianceAny, libGame_gv_townTownData[lv_town].lv_townRegion, UnitFilter(0, (1 << (c_targetFilterAITargetableStructure - 32)), (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0), 1));
        return UnitGroupRandomUnit(lv_buildings, c_unitCountAlive);
    }

mods/heroesmapmods/battlegroundmapmods/skytemple.stormmodbase.stormdata/LibMLCP.galaxy:1105

    lv_townHall = libGame_gv_townTownData[lv_town].lv_structureUnits[libGame_gv_townTownData[lv_town].lv_townHallIndex];
    if ((UnitIsAlive(lv_townHall) == false)) {
        UnitGroupRemove(lv_buildings, UnitGroupUnit(libNtve_gf_UnitsInRegionWithAllianceToPlayerMatchingCondition(UnitTypeFromString("RagnarosBigRag"), "", "", c_playerAny, c_unitAllianceAny, libGame_gv_townTownData[lv_town].lv_townRegion, UnitFilter(0, (1 << (c_targetFilterAITargetableStructure - 32)), (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0), 1));
        return UnitGroupClosestToPoint(lv_buildings, UnitGetPosition(libMLCP_gv_mMSkyTemples[lp_templeIndex].lv_temple));
    }

mods/heroesmapmods/battlegroundmapmods/skytemple.stormmodbase.stormdata/LibMLCP.galaxy:1209

    lv_townHall = libGame_gv_townTownData[lv_town].lv_structureUnits[libGame_gv_townTownData[lv_town].lv_townHallIndex];
    if ((UnitIsAlive(lv_townHall) == false)) {
        UnitGroupRemove(lv_buildings, UnitGroupUnit(libNtve_gf_UnitsInRegionWithAllianceToPlayerMatchingCondition(UnitTypeFromString("RagnarosBigRag"), "", "", c_playerAny, c_unitAllianceAny, libGame_gv_townTownData[lv_town].lv_townRegion, UnitFilter(0, (1 << (c_targetFilterAITargetableStructure - 32)), (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0), 1));
        return libMLCP_gf_MMSkyTempleClosestUnits(lv_buildings, 3, UnitGetPosition(libMLCP_gv_mMSkyTemples[lp_templeIndex].lv_temple));
    }

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:3567


    // Implementation
    return UnitTypeFromString(CatalogFieldValueGet(c_gameCatalogAbil, lv_link, "InfoArray[" + IntToString(lv_index) + "].Unit[" + IntToString(lp_unitIndex) + "]", lp_p));
}

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMU.galaxy:7564

    for ( ; ( (auto9AFF4A66_ai >= 0 && lv_catalogIndex <= auto9AFF4A66_ae) || (auto9AFF4A66_ai < 0 && lv_catalogIndex >= auto9AFF4A66_ae) ) ; lv_catalogIndex += auto9AFF4A66_ai ) {
        lv_stringUnitID = (CatalogEntryGet(c_gameCatalogUnit, lv_catalogIndex));
        if ((UnitTypeTestAttribute(UnitTypeFromString(lv_stringUnitID), c_unitAttributeMapBoss) == true)) {
            continue;
        }

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMU.galaxy:7567

            continue;
        }
        else if ((UnitTypeTestAttribute(UnitTypeFromString(lv_stringUnitID), c_unitAttributeStructure) == true)) {
            if ((libCOOC_gf_CC_UnitTypeIsTownHall((lv_stringUnitID)) == true) && (libNtve_gf_CatalogFieldValueGetAsReal(c_gameCatalogUnit, (lv_stringUnitID), "Speed", c_playerAny) <= 0.0)) {
                lv_sightRange = libCOMI_gf_MinimumDifficultyValueCoopReal(9.0, 9.0, 7.0, 7.0, 7.0, 7.0);

mods/voidprologue.sc2modbase.sc2data/LibA3DDD02B.galaxy:6312

    lv_index = 1;
    for ( ; ( (auto3D41700D_ai >= 0 && lv_index <= auto3D41700D_ae) || (auto3D41700D_ai < 0 && lv_index >= auto3D41700D_ae) ) ; lv_index += auto3D41700D_ai ) {
        libA3DDD02B_gf_PP_HelpUnitPanel_AddEnabledUnitType(UnitTypeFromString(libA3DDD02B_gf_PP_LoadTransitionVarString(lp_sourceBank, lv__SectionName, IntToString(lv_index), "")));
    }
    lv__SectionName = libA3DDD02B_gf_PP_BankSectionName(lp_map, "Tips");