Auto-translated
Thank you, RedHeavenHero :) Everything is exactly as I wanted it to be :)
502 Bad Gateway
__________________________________
nginx/0.8.54
__________________________________
nginx/0.8.54
New here? I'm Roha — want a quick tour?
It is practically impossible to track when a hero interacts with a garrison.
Okay, I figured this one out. It takes names like BUILDING_ABANDONED_MINE, TOWN_NECROMANCY, and CREATURE_GENIE as arguments. They need to be enclosed in quotes; otherwise, the command won't work.
The function returns an array filled with adventure map references: a name if the object has one, otherwise its generic name, like "1-210-199-AdvMapDwelling-27624." You can refer to this by using the array index. For instance:
Imp_Cruc_Array=GetObjectNamesByType("BUILDING_IMP_CRUCIBLE");
GetObjectNamesByType('TOWN') - all towns on the map
GetObjectNamesByType('TOWN_DUNGEON') - all dungeon towns
GetObjectNamesByType('BUILDING_WITCH_HUT') - all witch huts.
It seems to search by a string prefix, because
GetObjectNamesByType('BUILDING_WITCH') and GetObjectNamesByType('BUILDING_WIT') give the same results as
GetObjectNamesByType('BUILDING_WITCH_HUT').
GetObjectNamesByType('TOWN') will return an array with the names of all towns on the map.
GetObjectNamesByType
GetObjectNamesByType — Retrieves all objects of a specified type
Syntax
GetObjectNamesByType(objectTypeName);
Description
Retrieves all objects of a specified type. For buildings, you need to specify the type (objectTypeName),
which is defined in Shared-Type. For monsters, it's Creature. For heroes, it's HeroClass. For
towns, it's TownRace. You can use substrings to specify more general types.
For example: BUILDING — all buildings. ABANDONED_MINE or BUILDING_ABANDONED_MINE — for
abandoned mines. DWELLING — for all dwellings. DWELLING_<dwelling type> —
specific dwellings. CREATURE — all monsters. CREATURE_PEASANT or simply PEASANT
— peasants. HERO — all heroes. HERO_CLASS_WIZARD — all heroes of the Academy. TOWN — all
towns. TOWN_HEAVEN — all towns of the HEAVEN race.
Where does it mention heroes here? If it's not a secret, it would be better to post the script. The error might have been somewhere else.
function GetPlayers()
local n = 0
for i=1,8 do
n = n + (GetPlayerState(i) == 1 or 0)
end
return n
end
And what about GetPlayerState?function GetPlayers()
local n = 0
for i=1,8 do
n = n + (GetPlayerState(i) == 1 or 0)
end
return n
end
-- Getting the number of players in the game
function getTotalPlayers()
local total = 0
for playerID = PLAYER_1, PLAYER_8 do
if GetPlayerState(playerID) == PLAYER_ACTIVE then
total = total + 1
end
end
return total
endYeah, I already managed to solve the problem using it.
Only instead of the "magic" numbers 1 and 0, I used the constant PLAYER_ACTIVE (which, apparently, corresponds to 1).-- Getting the number of players in the game
function getTotalPlayers()
local total = 0
for playerID = PLAYER_1, PLAYER_8 do
if GetPlayerState(playerID) == PLAYER_ACTIVE then
total = total + 1
end
end
return total
end
And why use the value PLAYER_NOT_IN_GAME (0)?
Why "magical"?
Where? Besides, players outside the game are indicated by 4.
n = n + (GetPlayerState(i) == 1 or 0)I completely don't understand what it does here, and due to the lack of parentheses, it is not even clear how this construct will be executed, whether the equality check will be performed first, and then OR, or vice versa.