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.
The PlayObjectAnimation function doesn't work for heroes, or am I doing something wrong? In the properties, I set the correct AnimSet and HeroCharacterAdventure. Under the same conditions, a regular creature plays the animation, but there is no reaction from the hero.
I have a question: is it possible to use combat scripts (for heroes) in multiplayer maps, or do they only work for single-player games? And if it is possible, are there any maps on the site where I can see how they are implemented?
Hello everyone :) The questions are: Is it possible to call a function without using standard triggers? And is there a more or less detailed description of how while do and for work?
Is it possible to call a function without using standard triggers?
To call it at the start of the map, simply write the function call anywhere in the script. You can also call it from another function/thread.
And is there a more or less detailed description of how while do and for work?
Google Novik's guide – it contains general information about how scripts work, plus a good description of most functions in Russian. In general, these are standard Lua 4.0 loops.
Thank you. I'll try to figure out the streams, although, to be honest, Novik's language is quite complex, especially for someone who isn't familiar with programming languages.
Hello forum. Maybe someone can tell me how to add one to a variable? I'm running a loop with a check to see if my variable has changed by "+1" (in my case, it's GetHeroLevel). However, the game doesn't react at all, as if there's a syntax error.
Hello forum again. Maybe someone can tell me how to add one to a variable? I mean, I'm running a loop with a check to see if my variable has changed by "+1" (in my case, this is GetHeroLevel). However, the game doesn't react at all, as if there's a syntax error.
In general, to add one:
a = a + 1
In the case of a loop checking the level, I would do it like this:
a = 1; while 1 do sleep(2); if GetHeroLevel(hero) - a == 1 then ... end sleep(2); a = GetHeroLevel(hero); end
In the case of a loop to check the level, I would do it like this:
a = 1; while 1 do sleep(2); if GetHeroLevel(hero) - a == 1 then ... end sleep(2); a = GetHeroLevel(hero); end
And for this purpose, there is:
Trigger(HERO_LEVELUP_TRIGGER, hero, function)
Thank you :) The function works perfectly in a single case. But what if I need the action to be performed with Each level up? I apologize for the silly questions, but manipulating comparison signs didn't help.
Well, thank you both for your answers; indeed, everything works properly through a trigger. I tried to delve deeper into the maps of the esteemed 32MeTpa; everything is described there, albeit concisely, but my knowledge is insufficient. :smile15:
UPD: It stopped working altogether. It's simple and straightforward, but creatures are given only upon the first level-up, and nothing happens on subsequent level-ups. What's the mistake?
function a()
AddHeroCreatures("Sarge",CREATURE_ARCHER,20);
Trigger(HERO_LEVELUP_TRIGGER,"Sarge",nil)
end;
Trigger(HERO_LEVELUP_TRIGGER,"Sarge","a")
UPD: It stopped working completely. It's simple, but the creatures are given only upon the first level up, and nothing happens on subsequent level ups. What's the mistake? function a() AddHeroCreatures("Sarge",CREATURE_ARCHER,20); Trigger(HERO_LEVELUP_TRIGGER,"Sarge",nil) end; Trigger(HERO_LEVELUP_TRIGGER,"Sarge","a")
Trigger(HERO_LEVELUP_TRIGGER,"Sarge",nil)
This line resets the trigger, which is why it only runs once and then disables itself. Just remove it, and it will work every time the hero levels up.
This line resets the trigger, which is why it only executes once and then disables itself. Simply remove it, and it will work every time the hero levels up.
Thank you. By the way, do you know if it's possible to give a hero of one class perks from another class using scripts? (GiveHeroSkill can grant a skill of the first level, but it refuses to grant abilities). Or do I need to change something in GameMechanics within the hero's structure? Thank you again for your quick responses and for taking the time.