Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to Ment
User Avatar
Auto-translated
Ment
Oh, I'm still a bit slow.

Is that all? There's no loop or startThread? That's not right; you need to run this function, not just declare it. And you need an infinite loop.

function pokushenie()
while 1 do
if GetDate(DAY) == 42 then
MessageBox("Maps/SingleMissions/Five Plunderers/podzhigatel.txt", TeleporateHero);
break;
end;
sleep(2);
end;
end;

function TeleporateHero()
SetObjectPosition("Biara", 31, 129, 0);
end;
It doesn't work. Maybe I didn't arrange the paragraphs correctly? Could you provide more details about where the paragraphs should be?

Added 2 hours 39 minutes ago
And in the 3rd line, at the end, is the semicolon not needed?
And the path to the message... Did I put the slashes in the right direction? / or \?
Автор карт:
Долина расхитителей
Выбор мира
User Avatar
Auto-translated
Indentation, line breaks, and other whitespace do not affect the execution of the code. Almost the same can be said about the semicolon ";".
The path to the message is written correctly, but for universality, it is usually written like this: `
GetMapDataPath() .. "file_name.txt"
` or the path is stored in a variable: `
path = GetMapDataPath()
` and then it is used: `
path.."file_name.txt"
`.
Also, the function name in the MessageBox parameters is written in quotes.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
That's quite convenient. So, two dots are automatically interpreted as a path to the root folder? That's handy. But it still doesn't work.
Автор карт:
Долина расхитителей
Выбор мира
User Avatar
Auto-translated
Check the encoding of your text file. Also, make sure the filename is correct, with all letters in the proper case.
 

К А
Стикеры GBF в Telegram
User Avatar
Auto-translated
Well, only the console. Try activating it. Or were you complaining about it not working in the cheats thread earlier?
 

К А
Стикеры GBF в Telegram
User Avatar
Auto-translated
I don't know about the cheat topic, but
Firstly, I have a file called imput or something like that, but it also contains the bindings for all the buttons. I put the line in there. Everything according to the instructions. But nothing happens. Once, it worked for me. About a year or two ago. But since I reinstalled Windows, I have to start all over again.

Added after 12 hours and 19 minutes
I've set everything up. The console doesn't complain. But it still doesn't work. Also, the editor has started just eating my maps. After opening my copies, they all weigh a kilobyte. Luckily, I have many copies. Maybe... could someone help with finishing the scripts for the map?
Автор карт:
Долина расхитителей
Выбор мира
User Avatar
Auto-translated
OrnsteinDragonslayer, maps are often saved incorrectly because the path to the game folder is too long or contains Cyrillic characters. You can try moving/renaming it to a higher-level directory for testing, say to D:/Heroes 5. If that doesn't help, you can try reinstalling the game. Regarding scripts, I recently wrote a few tips that might be relevant to you:
There are several directions you can take:
Write scripts in editors with syntax checking, such as HoMM5 MapScriptsEditor. At a minimum, it will immediately issue warnings for minor typos, plus it offers autocompletion of function names and parameter hints (although this works somewhat glitchy).
Comment out the entire script code, then uncomment it in small chunks, a few lines at a time, and check if it works, or fix it until it works, and only then move on to the next part. You can mark what already works in some way so that you don't have to check it again next time.
Place test debug messages in the code, such as print('this function has been executed'). This makes it easy to see which section of code has been executed and which has not.
A particularly useful feature is debugging code without leaving the game. Create a .lua file in Unicode encoding in the "path_to_heroes/data" folder, write the code you are unsure about in it, and you can add, for example, print('script OK') at the end of the file. Load the map, open the console, and type @doFile('filename.lua'). If you see the green message 'script OK' in the console, the code is working; if not, close Heroes, work on the file, don't forget to save, return to Heroes, and enter the same command in the console (you can just press the up arrow button). Repeat until the code works.
User Avatar
Auto-translated
I tried different paths. It doesn't help. I can't reinstall because I don't have internet access, and it downloads from Steam, so there's no setup file.
I would have worked on the scripts myself if I could access the editor. In this case, I'm just asking for help from someone else to finish the scripts based on my idea, since the rest of the map is ready. + I'm already demoralized. I should have made the first map multiplayer and without scripts. I'll do that later...
Автор карт:
Долина расхитителей
Выбор мира
User Avatar
Auto-translated
I encountered a problem: why don't heroes with AI disabled want to pass through a hostile garrison? I place a hero, set EnableHeroAI and MoveHero, in MoveHero I set the coordinates, the only road to which leads through a hostile (empty) garrison, and... the hero stands still. If I set the coordinates in front of the garrison, he walks perfectly. He also attacks the garrison without any problems, but he doesn't want to simply pass through it. Can you tell me what the problem is?
User Avatar
Auto-translated
I place a hero, enter EnableHeroAI and MoveHero, in MoveHero I set the coordinates, and the only path to them leads through a hostile (empty) garrison, and... the hero stays put. If I set the coordinates in front of the garrison, he walks there perfectly. He also attacks the garrison without any problems, but he doesn't want to simply pass through it. Can you tell me what the problem is?
Enter MoveHero for the cell next to the garrison, then another MoveHero (for the garrison cell), and then continue.
Or you can also include MakeHeroInteractWithObject in this sequence for aesthetics (I assume that if there is someone in the garrison, the script will only become more stable because of this).
 

К А
Стикеры GBF в Telegram
In reply to Ment
User Avatar
Auto-translated
Ment
Write MoveHero to a cell next to the garrison, then another MoveHero (to the garrison cell), and then continue.
Or you can also include MakeHeroInteractWithObject in this sequence for aesthetics (I assume that if someone is in the garrison, the script will only become more stable because of this).

Thank you, it helped)

And could you tell me why the game doesn't display "Objectives updated" when the list of objectives is updated?

SetObjectiveState("obj_8",OBJECTIVE_COMPLETED);
sleep(2);
SetObjectiveVisible("obj_9",true);
sleep(2);
SetObjectiveState("obj_9",OBJECTIVE_ACTIVE);

In the game itself, it only displays "Objectives completed," and after that, it doesn't display "Objectives updated" for some reason, which isn't critical, but it's annoying.
In reply to Ment
User Avatar
Auto-translated
Ment
I don't know.
That's a shame. Well, I guess I'll have to use a message box to display "Tasks updated." And another question: is it possible to create an artifact in a specific location on the map? I need the artifact to appear at specific coordinates when a quest is completed. I tried moving it using SetObjectPosition, but for some reason, artifacts ignore this command...

Statistics

Welcome our newest member: Emil