Connection ErrorBad RequestThis page went staleSession ExpiredSign in requiredForbiddenNot FoundToo Many RequestsServer ErrorBad GatewayService UnavailableGateway TimeoutHTTP Version Not Supported
Session Expired
Your session has expired. Please log in to continue.
Sign in required
You need an account to do that. Sign in or create one — it only takes a minute.
This page went stale
Your security token was rejected, usually because the page sat open too long or you signed in elsewhere. Nothing was saved. Reload the page and try again.
Request Failed
We encountered an issue while processing your request.
Please check your internet connection and try again.
Hello everyone, could you please advise me on something?
Is it possible to configure a function to execute not based on a specific trigger from the list of triggers, but based on something else, such as the construction of a building or the appearance of a specific artifact or creature with a particular hero or player?
It seems that the command that starts a new thread does something similar (although I don't really know what a thread is).
`startThread(fProc, vParam1, vParam2, ...)`
Theoretically, if I understand correctly, it should constantly check for a specific condition, but I can't figure out how to use it.
Specifically, I need to replace one creature with another in a hero's army when a specific building is constructed in a town.
Currently, I have something like this:
```
function replacecreature ();
if GetHeroCreatures( "Sarge", CREATURE_ARCHER ) >= 1
and GetTownBuildingLevel( "cheast_town", TOWN_BUILDING_DWELLING_2 ) = 2;
then AddHeroCreatures( "Sarge", CREATURE_LONGBOWMAN, 1 );
RemoveHeroCreatures( "Sarge", CREATURE_ARCHER, 9999 );
else nil;
end;
end;
startThread( "replacecreature", TOWN_BUILDING_DWELLING_2 );
```
What's wrong with this, and is it even possible to do what I'm describing? If not, is there a similar alternative?
Thank you very much in advance for any advice.