Skip to content

Scripts for beginners.

User Avatar
#146
Auto-translated
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.

Statistics

Welcome our newest member: artem

Users Online 2 users 1472 guests