Auto-translated
function replacecreature ()
while 1 do
if GetHeroCreatures( "Sarge", CREATURE_ARCHER ) >= 1 and GetTownBuildingLevel( "cheast_town", TOWN_BUILDING_DWELLING_2 ) = 2 then
RemoveHeroCreatures( "Sarge", CREATURE_ARCHER, 9999 );
AddHeroCreatures( "Sarge", CREATURE_LONGBOWMAN, 1 );
end;
end;
end;
startThread( "replacecreature" );
I checked, it still doesn't work.
(It doesn't even start, whether the building is built at the beginning of the map or during the game).
I read somewhere that you should write not
startThread( "replacecreature")
but
startThread( replacecreature)
I tried this option too, but it didn't give any results.
In Novik's Manual, there is also this snippet about startThread:
while(1) do
local heroes = GetPlayerHeroes(PLAYER_1)
for i, h in heroes do
if....
but I have no idea how to apply it and what it means because I'm a newbie