Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
11 years ago
Auto-translated
How to create a MessageBox? I found some old guide, but the script from it doesn't work at all... Here's the script: function sampleF () Trigger(REGION_ENTER_AND_STOP_TRIGGER, "sample", nil ); MessageBox ("Maps/SingleMissions/test/test.txt"); end; Trigger(REGION_ENTER_AND_STOP_TRIGGER, “sample”, “sampleF” ); The file test.txt is located inside the map at the path Maps/SingleMissions/test/test.txt, and its encoding is UTF-8.
In reply to RedHeavenHero
User Avatar
11 years ago
Auto-translated
RedHeavenHero
The encoding is incorrect; it should be Unicode (UTF-16).
Thank you! I'll try that now.)):)

Added 24 minutes later
Hmm... the encoding didn't help...
In reply to RedHeavenHero
User Avatar
11 years ago
Auto-translated
RedHeavenHero
The quotes in the script are incorrect; you need to use " or '.
Hmm... I'll try it now too.)

Added 6 minutes later
Thank you so much! It works now!)))
User Avatar
11 years ago
Auto-translated
Thank you. One more question. Using scripts, you can make UNITS of creatures fight on the map (attack, die, etc.), but how can you make the scripts play ONLY when the hero approaches?

Added 17 hours and 50 minutes ago
What does the NON_ESSENTIAL command do, and how can it be used?
In reply to inQizitOr
User Avatar
11 years ago
Auto-translated

function play_anims()
if GetCurrentPlayer() ~= 1 then return end
Trigger(REGION_ENTER_AND_STOP_TRIGGER, 'region_name', nil)
PlayObjectAnimation("creature", "animation", ANIMATION_PLAY_METHOD)
sleep(3) -- Pauses will likely be needed between animation plays
PlayObjectAnimation("creature", "animation", ANIMATION_PLAY_METHOD)
sleep(3)
PlayObjectAnimation("creature", "animation", ANIMATION_PLAY_METHOD)
-- ... --
end

Trigger(REGION_ENTER_AND_STOP_TRIGGER, 'region_name', 'play_anims')
To make the script work, you will need a region; when a hero enters it, the animation will be triggered.

Added 1 minute ago
What does the NON_ESSENTIAL command do, and how can it be used?
The animation will only be played if no other animation (other than "idle00") is currently playing on the object.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to RedHeavenHero
User Avatar
11 years ago
Auto-translated
RedHeavenHero

function play_anims()
if GetCurrentPlayer() ~= 1 then return end
Trigger(REGION_ENTER_AND_STOP_TRIGGER, 'region_name', nil)
PlayObjectAnimation("creature", "animation", ANIMATION_PLAY_METHOD)
sleep(3) -- pauses will likely be needed between animation plays
PlayObjectAnimation("creature", "animation", ANIMATION_PLAY_METHOD)
sleep(3)
PlayObjectAnimation("creature", "animation", ANIMATION_PLAY_METHOD)
-- ... --
end

Trigger(REGION_ENTER_AND_STOP_TRIGGER, 'region_name', 'play_anims')
To make the script work, you will need a region; when a hero enters it, the animation will be triggered.

Added 1 minute ago

The animation will only play if no other animation (other than "idle00") is currently playing on the object.
What are the different ways to play animations?
User Avatar
11 years ago
Auto-translated
ONESHOT - play the animation once; IDLE - loop the animation infinitely; ONESHOT_STILL - after the animation finishes playing, the object will remain in the position of the last frame of the animation and will not change it. This is typically used for death animations; there are also INVISIBLE and NON_ESSENTIAL, but they are rarely used.

Whatever
In reply to Heroist
User Avatar
11 years ago
Auto-translated
Heroist
ONESHOT - play the animation once; IDLE - continuously loop the animation; ONESHOT_STILL - after the animation finishes playing, the object will remain in the position of the last movement of that animation and will not change it. This is typically used for death animations; there are also INVISIBLE and NON_ESSENTIAL, but they are rarely used.
Thank you very much! This will be helpful.
User Avatar
11 years ago
Auto-translated
function play_anims() if GetCurrentPlayer() ~= 1 then return end Trigger(REGION_ENTER_AND_STOP_TRIGGER, '1', nil) PlayObjectAnimation("q12", "death", ONESHOT_STILL) sleep(3) end Trigger(REGION_ENTER_AND_STOP_TRIGGER, '1', 'play_anims') It doesn't work. What's the problem?
User Avatar
11 years ago
Auto-translated
It’s better not to refer to regions by numbers, but to give them ordinary names in Latin characters.

Whatever
In reply to Heroist
User Avatar
11 years ago
Auto-translated
Heroist
It's better not to use numbers to name regions, but to give them ordinary names in Latin.
Thank you very much.
User Avatar
11 years ago
Auto-translated
Which player’s hero entered the region? I created a version specifically for single-player mode; for multiplayer, the check for the current player needs to be removed.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to RedHeavenHero
User Avatar
11 years ago
Auto-translated
RedHeavenHero
Which player's hero entered the region? I made a version specifically for single-player; for multiplayer, you need to remove the check for the current player.
I made it for single-player. It still doesn't work. The other scripts play, but these don't.

Statistics

Welcome our newest member: recijeb