# Save Data Table Value (Unit)

Grammar — Save value as name in the scope|Global/Local data table
FlagsNative | Action

Saves a unit value into a data table. Data tables allow you to store and recall values using a string identifier. If you save a data table value using a string identifier that already exists, you will overwrite the old value, even if it is a different data type than the value you are saving.

# Arguments

  • bool<preset::DataScope> — Scope
  • string — Name
  • unit — Value

Returns — void

native void DataTableSetUnit(
	bool global,
	string name,
	unit val,
);

Category: Data Table / Save Value

# Examples

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/zexpedition02.sc2map/MapScript.galaxy:732

    // Implementation
    DataTableSetUnitGroup(true, ("EscortShuttles_" + IntToString(UnitGetTag(lp_escort))), lp_shuttles);
    DataTableSetUnit(true, ("EscortShuttle_" + IntToString(UnitGetTag(lp_escort))), UnitGroupUnit(lp_shuttles, 1));
    DataTableSetUnitGroup(true, ("ShuttleEscorts_" + IntToString(UnitGetTag(UnitGroupUnit(lp_shuttles, 1)))), lp_allEscorts);
}

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/zexpedition02.sc2mapMapScript.galaxy:732

    // Implementation
    DataTableSetUnitGroup(true, ("EscortShuttles_" + IntToString(UnitGetTag(lp_escort))), lp_shuttles);
    DataTableSetUnit(true, ("EscortShuttle_" + IntToString(UnitGetTag(lp_escort))), UnitGroupUnit(lp_shuttles, 1));
    DataTableSetUnitGroup(true, ("ShuttleEscorts_" + IntToString(UnitGetTag(UnitGroupUnit(lp_shuttles, 1)))), lp_allEscorts);
}

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

    }

    DataTableSetUnit(true, (libSwaC_gv_zSC_ArmyCustomEggUnitDataPrefix + (lp_armyCategory)), lv_eggUnit);
    if ((libSwaC_gf_StoryArmyCategoryStateCheck(lp_armyCategory, c_armyCategoryStateUnlocked) == true)) {
        libSwaC_gf_ZS_ArmyCalloutUpdate(lp_armyCategory);

mods/core.sc2modbase.sc2data/TriggerLibs/NativeLib.galaxy:5162

    // Implementation
    if (((lp_unit == null) || (UnitGetType(lp_unit) == lp_unitType))) {
        DataTableSetUnit(false, "%REPLACEDUNIT%", lp_unit);
        return ;
    }

mods/core.sc2modbase.sc2data/TriggerLibs/NativeLib.galaxy:5197

    }
    UnitRemove(lp_unit);
    DataTableSetUnit(false, "%REPLACEDUNIT%", lv_newUnit);
}

mods/core.stormmodbase.stormdata/TriggerLibs/NativeLib.galaxy:4407

    // Implementation
    if (((lp_unit == null) || (UnitGetType(lp_unit) == lp_unitType))) {
        DataTableSetUnit(false, "%REPLACEDUNIT%", lp_unit);
        return ;
    }

mods/core.stormmodbase.stormdata/TriggerLibs/NativeLib.galaxy:4442

    }
    UnitRemove(lp_unit);
    DataTableSetUnit(false, "%REPLACEDUNIT%", lv_newUnit);
}

mods/heroesbrawlmods/brawlmapmods/coop/pvebrawlmod.stormmodbase.stormdata/LibPVEB.galaxy:789

    // Implementation
    DataTableSetInt(false, TriggerEventParamName(libPVEB_gv_eventID_NPCHeroSpawn_C, libPVEB_gv_eventParam_NPCHeroSpawn_Player_C), lp_player);
    DataTableSetUnit(false, TriggerEventParamName(libPVEB_gv_eventID_NPCHeroSpawn_C, libPVEB_gv_eventParam_NPCHeroSpawn_HeroUnit_C), lp_heroUnit);
    TriggerSendEvent(libPVEB_gv_eventID_NPCHeroSpawn_C);
}

mods/heroesbrawlmods/brawlmapmods/coop/pvemod.stormmodbase.stormdata/LibPVEM.galaxy:996

    // Implementation
    DataTableSetInt(false, TriggerEventParamName(libPVEM_gv_pvEEventIDNPCHeroSpawn_C, libPVEM_gv_pvEEventParamNPCHeroSpawnPlayer_C), lp_player);
    DataTableSetUnit(false, TriggerEventParamName(libPVEM_gv_pvEEventIDNPCHeroSpawn_C, libPVEM_gv_pvEEventParamNPCHeroSpawnHeroUnit_C), lp_heroUnit);
    TriggerSendEvent(libPVEM_gv_pvEEventIDNPCHeroSpawn_C);
}

mods/heroesdata.stormmodbase.stormdata/TriggerLibs/GameDataHelperLib.galaxy:464

    // Implementation
    DataTableSetInt(false, TriggerEventParamName(libGDHL_gv_eventID_AbathurUltimateEvolutionEnded_C, libGDHL_gv_eventParam_AbathurUltimateEvolution_AbathurPlayer_C), lp_abathurPlayer);
    DataTableSetUnit(false, TriggerEventParamName(libGDHL_gv_eventID_AbathurUltimateEvolutionEnded_C, libGDHL_gv_eventParam_AbathurUltimateEvolution_ClonedUnit_C), lp_clonedUnit);
    TriggerSendEvent(libGDHL_gv_eventID_AbathurUltimateEvolutionEnded_C);
}

mods/heroesdata.stormmodbase.stormdata/TriggerLibs/GameDataHelperLib.galaxy:516

    // Implementation
    DataTableSetInt(false, TriggerEventParamName(libGDHL_gv_eventID_AbathurSymbiote_C, libGDHL_gv_eventParam_AbathurSymbiote_AbathurPlayer_C), lp_abathurPlayer);
    DataTableSetUnit(false, TriggerEventParamName(libGDHL_gv_eventID_AbathurSymbiote_C, libGDHL_gv_eventParam_AbathurSymbiote_SymbioteUnit_C), lp_symbioteUnit);
    DataTableSetUnit(false, TriggerEventParamName(libGDHL_gv_eventID_AbathurSymbiote_C, libGDHL_gv_eventParam_AbathurSymbiote_SymbioteTarget_C), lp_symbioteTarget);
    TriggerSendEvent(libGDHL_gv_eventID_AbathurSymbiote_C);

mods/heroesdata.stormmodbase.stormdata/TriggerLibs/GameDataHelperLib.galaxy:517

    DataTableSetInt(false, TriggerEventParamName(libGDHL_gv_eventID_AbathurSymbiote_C, libGDHL_gv_eventParam_AbathurSymbiote_AbathurPlayer_C), lp_abathurPlayer);
    DataTableSetUnit(false, TriggerEventParamName(libGDHL_gv_eventID_AbathurSymbiote_C, libGDHL_gv_eventParam_AbathurSymbiote_SymbioteUnit_C), lp_symbioteUnit);
    DataTableSetUnit(false, TriggerEventParamName(libGDHL_gv_eventID_AbathurSymbiote_C, libGDHL_gv_eventParam_AbathurSymbiote_SymbioteTarget_C), lp_symbioteTarget);
    TriggerSendEvent(libGDHL_gv_eventID_AbathurSymbiote_C);
}

mods/heroesdata.stormmodbase.stormdata/TriggerLibs/GameLib.galaxy:3465

    // Implementation
    DataTableSetInt(false, TriggerEventParamName(libGame_gv_eventID_JungleDefenderAIDefenderKilled_C, libGame_gv_eventParam_JungleDefenderAIDefenderKilled_Index_C), lp_defenderAIIndex);
    DataTableSetUnit(false, TriggerEventParamName(libGame_gv_eventID_JungleDefenderAIDefenderKilled_C, libGame_gv_eventParam_JungleDefenderAIDefenderKilled_Unit_C), lp_unit);
    DataTableSetInt(false, TriggerEventParamName(libGame_gv_eventID_JungleDefenderAIDefenderKilled_C, libGame_gv_eventParam_JungleDefenderAIDefenderKilled_KillingPlayer_C), lp_killingPlayer);
    TriggerSendEvent(libGame_gv_eventID_JungleDefenderAIDefenderKilled_C);

mods/heroesdata.stormmodbase.stormdata/TriggerLibs/GameLib.galaxy:3638

    // Implementation
    DataTableSetInt(false, TriggerEventParamName(libGame_gv_eventID_HeroParticipatedInCreepTakedown_C, libGame_gv_eventParam_HeroParticipatedInCreepTakedown_Player_C), lp_player);
    DataTableSetUnit(false, TriggerEventParamName(libGame_gv_eventID_HeroParticipatedInCreepTakedown_C, libGame_gv_eventParam_HeroParticipatedInCreepTakedown_NPC_C), lp_unit);
    TriggerSendEvent(libGame_gv_eventID_HeroParticipatedInCreepTakedown_C);
}

mods/heroesdata.stormmodbase.stormdata/TriggerLibs/GameLib.galaxy:3676

    // Implementation
    DataTableSetInt(false, TriggerEventParamName(libGame_gv_eventID_HeroExitedTransport_C, libGame_gv_eventParam_HeroExitedTransport_Player_C), lp_player);
    DataTableSetUnit(false, TriggerEventParamName(libGame_gv_eventID_HeroExitedTransport_C, libGame_gv_eventParam_HeroExitedTransport_Transport_C), lp_unit);
    TriggerSendEvent(libGame_gv_eventID_HeroExitedTransport_C);
}

mods/heroesdata.stormmodbase.stormdata/TriggerLibs/GameLib.galaxy:3702

    // Implementation
    DataTableSetInt(false, TriggerEventParamName(libGame_gv_eventID_HeroEnteredTransport_C, libGame_gv_eventParam_HeroEnteredTransport_Player_C), lp_player);
    DataTableSetUnit(false, TriggerEventParamName(libGame_gv_eventID_HeroEnteredTransport_C, libGame_gv_eventParam_HeroEnteredTransport_Transport_C), lp_transportUnit);
    DataTableSetUnit(false, TriggerEventParamName(libGame_gv_eventID_HeroEnteredTransport_C, libGame_gv_eventParam_HeroEnteredTransport_CargoUnit_C), lp_cargoUnit);
    TriggerSendEvent(libGame_gv_eventID_HeroEnteredTransport_C);

mods/heroesdata.stormmodbase.stormdata/TriggerLibs/GameLib.galaxy:3703

    DataTableSetInt(false, TriggerEventParamName(libGame_gv_eventID_HeroEnteredTransport_C, libGame_gv_eventParam_HeroEnteredTransport_Player_C), lp_player);
    DataTableSetUnit(false, TriggerEventParamName(libGame_gv_eventID_HeroEnteredTransport_C, libGame_gv_eventParam_HeroEnteredTransport_Transport_C), lp_transportUnit);
    DataTableSetUnit(false, TriggerEventParamName(libGame_gv_eventID_HeroEnteredTransport_C, libGame_gv_eventParam_HeroEnteredTransport_CargoUnit_C), lp_cargoUnit);
    TriggerSendEvent(libGame_gv_eventID_HeroEnteredTransport_C);
}

mods/heroesdata.stormmodbase.stormdata/TriggerLibs/GameLib.galaxy:3780

    // Implementation
    DataTableSetInt(false, TriggerEventParamName(libGame_gv_eventID_HeroPortedBackToTown_C, libGame_gv_eventParam_HeroPortedBackToTown_Player_C), lp_player);
    DataTableSetUnit(false, TriggerEventParamName(libGame_gv_eventID_HeroPortedBackToTown_C, libGame_gv_eventParam_HeroPortedBackToTown_Unit_C), lp_unit);
    TriggerSendEvent(libGame_gv_eventID_HeroPortedBackToTown_C);
}

mods/heroesdata.stormmodbase.stormdata/TriggerLibs/GameLib.galaxy:3806

    // Implementation
    DataTableSetInt(false, TriggerEventParamName(libGame_gv_eventID_HeroParticipatedInNPCTakedown_C, libGame_gv_eventParam_HeroParticipatedInNPCTakedown_Player_C), lp_player);
    DataTableSetUnit(false, TriggerEventParamName(libGame_gv_eventID_HeroParticipatedInNPCTakedown_C, libGame_gv_eventParam_HeroParticipatedInNPCTakedown_NPC_C), lp_unit);
    TriggerSendEvent(libGame_gv_eventID_HeroParticipatedInNPCTakedown_C);
}

mods/heroesdata.stormmodbase.stormdata/TriggerLibs/GameLib.galaxy:3832

    // Implementation
    DataTableSetInt(false, TriggerEventParamName(libGame_gv_eventID_HeroWitnessedAlliedNPCDeath_C, libGame_gv_eventParam_HeroWitnessedAlliedNPCDeath_Player_C), lp_player);
    DataTableSetUnit(false, TriggerEventParamName(libGame_gv_eventID_HeroWitnessedAlliedNPCDeath_C, libGame_gv_eventParam_HeroWitnessedAlliedNPCDeath_NPC_C), lp_unit);
    TriggerSendEvent(libGame_gv_eventID_HeroWitnessedAlliedNPCDeath_C);
}

mods/heroesdata.stormmodbase.stormdata/TriggerLibs/GameLib.galaxy:3858

    // Implementation
    DataTableSetInt(false, TriggerEventParamName(libGame_gv_eventID_SpecialCaseUnitParticipatedInNPCTakedown_C, libGame_gv_eventParam_SpecialCaseUnitParticipatedInNPCTakedown_Player_C), lp_player);
    DataTableSetUnit(false, TriggerEventParamName(libGame_gv_eventID_SpecialCaseUnitParticipatedInNPCTakedown_C, libGame_gv_eventParam_SpecialCaseUnitParticipatedInNPCTakedown_NPC_C), lp_unit);
    TriggerSendEvent(libGame_gv_eventID_SpecialCaseUnitParticipatedInNPCTakedown_C);
}

mods/heroesdata.stormmodbase.stormdata/TriggerLibs/GameLib.galaxy:3892

    DataTableSetInt(false, TriggerEventParamName(libGame_gv_eventID_HeroParticipatedInTakedown_C, libGame_gv_eventParam_HeroParticipatedInTakedown_PlayerKilling_C), lp_playerKilling);
    DataTableSetInt(false, TriggerEventParamName(libGame_gv_eventID_HeroParticipatedInTakedown_C, libGame_gv_eventParam_HeroParticipatedInTakedown_PlayerKilled_C), lp_playerKilled);
    DataTableSetUnit(false, TriggerEventParamName(libGame_gv_eventID_HeroParticipatedInTakedown_C, libGame_gv_eventParam_HeroParticipatedInTakedown_HeroKilled_C), lp_heroKilled);
    DataTableSetPoint(false, TriggerEventParamName(libGame_gv_eventID_HeroParticipatedInTakedown_C, libGame_gv_eventParam_HeroParticipatedInTakedown_HeroKilledPosition_C), lp_heroKilledPosition);
    TriggerSendEvent(libGame_gv_eventID_HeroParticipatedInTakedown_C);

mods/heroesdata.stormmodbase.stormdata/TriggerLibs/HeroesLib.galaxy:3391

    // Automatic Variable Declarations
    // Implementation
    DataTableSetUnit(true, libCore_gf__UnitDataName(libCore_ge__UnitDataType_Unit, lp_unit, lp_index), lp_value);
}

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

    // Automatic Variable Declarations
    // Implementation
    DataTableSetUnit(false, TriggerEventParamName((lp_event), "ZeratulEventUnit"), libCOMI_gv_cM_HeroUnit[lp_zeratulPlayer]);
    DataTableSetUnit(false, TriggerEventParamName((lp_event), "ZeratulEventArtifactUnit"), lp_artifactUnit);
    DataTableSetInt(false, TriggerEventParamName((lp_event), "ZeratulEventPlayer"), lp_zeratulPlayer);

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

    // Implementation
    DataTableSetUnit(false, TriggerEventParamName((lp_event), "ZeratulEventUnit"), libCOMI_gv_cM_HeroUnit[lp_zeratulPlayer]);
    DataTableSetUnit(false, TriggerEventParamName((lp_event), "ZeratulEventArtifactUnit"), lp_artifactUnit);
    DataTableSetInt(false, TriggerEventParamName((lp_event), "ZeratulEventPlayer"), lp_zeratulPlayer);
    DataTableSetInt(false, TriggerEventParamName((lp_event), "ZeratulEventArtifactNumber"), lp_artifactNumber);

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

        lv_itUnitType = UserDataGetUnit(libCOMI_gv_cM_Tychus_UserTypeHeroList, lv_heroInstance, "Unit Type", 1);
        if ((lv_itUnitType == lv_heroType)) {
            DataTableSetUnit(false, TriggerEventParamName(lv_event, "EventHero"), lv_hero);
            DataTableSetString(false, TriggerEventParamName(lv_event, "EventHeroInstance"), (lv_heroInstance));
            TriggerSendEvent(lv_event);

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

    }

    DataTableSetUnit(false, TriggerEventParamName(lv_event, "EventStructure"), lv_structure);
    TriggerSendEvent(lv_event);
    return true;

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

        lv_event = "ZeratulEvent_VisionNotReady";
    }
    DataTableSetUnit(false, TriggerEventParamName((lv_event), "ZeratulEventUnit"), EventUnit());
    DataTableSetInt(false, TriggerEventParamName((lv_event), "ZeratulEventPlayer"), UnitGetOwner(EventUnit()));
    TriggerSendEvent((lv_event));

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

    else {
    }
    DataTableSetUnit(false, TriggerEventParamName((lv_event), "ZeratulEventUnit"), EventUnit());
    DataTableSetInt(false, TriggerEventParamName((lv_event), "ZeratulEventPlayer"), UnitGetOwner(EventUnit()));
    TriggerSendEvent((lv_event));