function replacecreature()
while (1) do
sleep(2);
local herocr = GetHeroCreatures( "Sarge", CREATURE_ARCHER );
if herocr >= 1 and
GetTownBuildingLevel("cheast_town", TOWN_BUILDING_DWELLING_2 ) == 2 then
RemoveHeroCreatures( "Sarge", CREATURE_ARCHER, herocr );
AddHeroCreatures( "Sarge", CREATURE_LONGBOWMAN, herocr );
sleep(1);
break
end;
end;
end;
startThread(replacecreature);
It works great, thank you very much to everyone.
I just have a couple of small questions: why is it "==" and not "="?
And what needs to be done to make the script run constantly (as long as the building is constructed), and not just once?
Do I need to do something with this line "while (1) do"? Am I guessing correctly?