BlzGetPlayerTownHallCount
- Parameters
-
whichPlayer player
- comment
-
Count player's town hall buildings of any race (probably using 'utyp' = "TownHall" for classification).
Each level 1 town hall is counted as 1; level 2 for 2 etc. Includes duplicate buildings: two level 1s count as 1+1=2.
Returns total counted number.
- note
-
Example (Lua, 2.0.3):
-- 3 Town hall IDs per each race (levels 1, 2, 3): humans, orcs, undead local townHalls = {"htow", "hkee", "hcas", "ogre", "ostr", "ofrt", "unpl", "unp1", "unp2"} print("Before spawning any town halls: ", BlzGetPlayerTownHallCount(Player(0))) for i, code in pairs(townHalls) do local u = CreateUnit(Player(0), FourCC(code), -2048 + i*384, 512, 90) print("Spawned town hall #".. i ..". Total count by API: ".. BlzGetPlayerTownHallCount(Player(0))) end
Prints: 0; 1, 3, 6; 7, 9, 12; 13, 15, 18
- patch
-
1.32.0.13369
- Source
- common.j (suggest an edit or discuss on Github)
- return type
-
integer
- Source code
-
native BlzGetPlayerTownHallCount takes player whichPlayer returns integer