Skip to content

Posts from Scripts for beginners.

4.5 (2 ratings)
User Avatar
Auto-translated
I suggest we post the most useful scripts here. Let me state upfront that this discussion is for useful scripts. So, share what you know. This will be a very helpful topic for beginner mapmakers. :smile02:

Added 5 minutes later
Here's the first very useful script: SetRegionBlocked (" desired region ",true,player number) - this script blocks a region on the map for a specifically designated player.
Script Example - SetRegionBlocked ("kamilla",true,1)

Added 7 minutes later
Here's the second script: GiveExp( "hero script name", specified amount of experience ) - This script gives the specified amount of experience to the specified hero at the beginning of the mission. :smile03:

Added 9 minutes later
Here's the third script: SetObjectEnabled(“object script name”, false) - this script removes the object's core function. This script is useful when you want to assign a script function to an object, but you want the core function not to interfere with the script (not mechanically, but conceptually).
Example: if you enter this script for a lumber mill, it will stop producing wood.

Added 4 minutes later
This script assigns a message to an object: Trigger(OBJECT_TOUCH_TRIGGER,"object script name","file name in Unicode format embedded in the created map")
Script Example: Trigger(OBJECT_TOUCH_TRIGGER,"kamilla","kamillaF")
User Avatar
Auto-translated
The last example seems incorrect. The last argument for the Trigger function should be the name of the function to be called when the object is touched, not a reference to text.

Added 1 hour 30 minutes ago
In general, all of this information is available in the manual.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to RedHeavenHero
User Avatar
Auto-translated
RedHeavenHero
The last example seems incorrect. The last argument for the Trigger function should be the name of the function to be called when the object is touched, not a reference to text.

Added 1 hour 30 minutes ago
Actually, all of this is in the manual.

Okay, write a couple more script examples.
User Avatar
Auto-translated
The idea is interesting, but I would modify it. Indeed, all these functions are already in the manual. And you could simply say that a good half of the manual is useful in one way or another. But if, instead of individual functions, you wrote ready-made scripts for the most common needs here, with a detailed explanation of what each script does... you could create a really good collection.
 

К А
Стикеры GBF в Telegram
In reply to ggroy
User Avatar
Auto-translated
ggroy
Sure, write a couple more script examples ;)
Ask what you need specifically – I'll answer. Besides, there are already manuals like "from beginner to beginner," and there's even a huge Excel table with descriptions of all the functions available in the game.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to RedHeavenHero
User Avatar
Auto-translated
RedHeavenHero
Ask me what you need specifically, and I'll answer.
I'm interested in learning about teleportation; tell me the script: you touch an object (or effect), and it teleports you to another location or the same object. :smile54: :smile14:

Added 3 minutes later
Ment
The idea is interesting, but I would modify it.
Thank you.
but I would modify it.
Tell me what you mean, and I'll modify it!:smile14:
User Avatar
Auto-translated
function teleport1(hero) SetObjectPosition(hero, x, y, floor) -- Replace x, y, and floor with the coordinates end -- Replace object with the object's name SetObjectEnabled(object, nil) Trigger(4, object, "teleport1")
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Well, ggroy, I explained it further down in that same post.
 

К А
Стикеры GBF в Telegram
User Avatar
Auto-translated
Hello, I'm back with a new question. How can I make it so that when I enter a region and it offers me to hire creatures for a certain amount, it first displays a message upon entering the region and then offers the hiring option? Please help – URGENTLY.
[url=Таверна (фулдилка) - заходите.


In reply to ggroy
User Avatar
Auto-translated
ggroy
Hello, I'm back with a new question. How can I make it so that when I enter a region and it offers me to hire creatures for a certain amount, upon entering the region, I receive a message and then it offers me to hire them. Help me - URGENTLY.
function hire1(hero)
hire1_hero = hero
MessageBox("path to the text message in Unicode format")
QuestionBox("path to the question text", "hire1_ok")
end

function hire1_ok()
local gold = GetPlayerResource(PLAYER_1, GOLD)
if gold >= hiring_cost then
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "region_name", nil)
SetPlayerResource(PLAYER_1, GOLD, gold - hiring_cost)
AddHeroCreatures(hire1_hero, creature_type, quantity)
else
-- here you can add a message about insufficient funds
end
end

Trigger(REGION_ENTER_AND_STOP_TRIGGER, "region_name", "hire1")
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
And what is the path to the text of the question?
[url=Таверна (фулдилка) - заходите.


User Avatar
Auto-translated
Basically, I tried it, but in the end, it displays messages, but doesn't offer any troops.
[url=Таверна (фулдилка) - заходите.


User Avatar
Auto-translated
I didn't write the path to the question text correctly.
And also, is the creature type written using the script name?
[url=Таверна (фулдилка) - заходите.


Statistics

Welcome our newest member: Emil