what is the Parameters:iIndex mean?

Seraphim8400

Warlord
Joined
Nov 7, 2010
Messages
112
Code:
GetUnit
<summary> 

Usage 

plot:getUnit(int iIndex); 

Parameters 

iIndex 
No Description Available 
Returns 

No Description Available. 

Example
what is unit iIndex of plot?
or how to get it?
or alway give 1 to this function?
 
Do an Edit->FindAndReplace->FindInFiles search in ModBuddy for "GetUnit(" through all the game's Assets *.lua files for examples of how the game itself uses it. Seems pretty straightforward. There can be multiple units in a "plot" (tile). Call plot:GetNumUnits() to get a count of how many there are, then loop through each one, calling plot->GetUnit(i), where i is the unit index. Example from UnitFlagManager.lua:
PHP:
    local cargoCount = 0;
    local numUnits = pPlot:GetNumUnits();
    
    -- count the air units
    for i = 0, numUnits - 1 do
        local pPlotUnit = pPlot:GetUnit( i );
        if( pPlotUnit:GetDomainType() == DomainTypes.DOMAIN_AIR ) then
            cargoCount = cargoCount + 1;
        end
    end
 
Back
Top Bottom