Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
6 years ago
Auto-translated
local a = 0 should be changed to simply a = 0. However, it would be even better to avoid using the new day trigger altogether and write it like this:
function zoloto()
local week = GetDate(WEEK)
SetObjectDwellingCreatures('houseInferno', 16, 35*week);
SetObjectDwellingCreatures('houseInferno', 18, 34*week);
SetObjectDwellingCreatures('houseInferno', 20, 18*week);
SetObjectDwellingCreatures('houseInferno', 22, 10*week);
SetObjectDwellingCreatures('houseInferno', 24, 7*week);
SetObjectDwellingCreatures('houseInferno', 26, 4*week);
SetObjectDwellingCreatures('houseInferno', 28, 2*week);

end;

Trigger( OBJECT_CAPTURE_TRIGGER, 'houseInferno', "zoloto")
In reply to Gerter
6 years ago
Auto-translated
Gerter
Change `local a = 0` to simply `a = 0`. Although, it would be even better to avoid using the "new day" trigger altogether and write it like this:
function zoloto()
local week = GetDate(WEEK)
SetObjectDwellingCreatures('houseInferno', 16, 35*week);
SetObjectDwellingCreatures('houseInferno', 18, 34*week);
SetObjectDwellingCreatures('houseInferno', 20, 18*week);
SetObjectDwellingCreatures('houseInferno', 22, 10*week);
SetObjectDwellingCreatures('houseInferno', 24, 7*week);
SetObjectDwellingCreatures('houseInferno', 26, 4*week);
SetObjectDwellingCreatures('houseInferno', 28, 2*week);

end;

Trigger( OBJECT_CAPTURE_TRIGGER, 'houseInferno', "zoloto")

Unfortunately, it doesn't work.
The recruitment button is grayed out, but even after building any structure, you can only recruit creatures whose structures you have built.
User Avatar
6 years ago
Auto-translated
So, if this function triggers, are there buildings in the town? If there are no buildings for recruitment, the script naturally won't add anyone.
In reply to Killer5029
6 years ago
Auto-translated
Killer5029
Unfortunately, it doesn't work (
the recruitment button is gray, but even after building some kind of structure, you can only recruit those creatures whose structures you have built.
Attachments 1
1 file attached • Total size: 101.6 KB
In reply to Gerter
6 years ago
Auto-translated
Gerter
So, are there buildings in the town when this function triggers? If there are no buildings for hiring, the script naturally won't add anyone.
There are no buildings, because if I build them, the AI will automatically buy creatures, but I need only the creatures that I initially assigned to be in the town's garrison.

Added 6 minutes later
Gerter
So, are there buildings in the town when this function triggers? If there are no buildings for hiring, the script naturally won't add anyone.
I just checked, and even if there are buildings, it still doesn't work.
User Avatar
6 years ago
Auto-translated
Okay, you can build structures at the moment of capturing a Castle. Alternatively, you can build them initially and reset the growth in 1 day of the week using a trigger for the new day (but the first reset will need to be done manually). Something like this:
for i = 16, 28, 2 do
local count = GetObjectDwellingCreatures('houseInferno', i)
if count ~= - 1 then
SetObjectDwellingCreatures('houseInferno', i, 0)
end
end

function NewDay()
if GetDate(DAY_OF_WEEK) == 1 then
for i = 16, 28, 2 do
local count = GetObjectDwellingCreatures('houseInferno', i)
if count ~= - 1 then
SetObjectDwellingCreatures('houseInferno', i, 0)
end
end
end
end

Trigger(NEW_DAY_TRIGGER, 'NewDay')
In reply to Gerter
6 years ago
Auto-translated
Gerter
Okay, you can build structures at the moment you capture a castle. Or, you can build them initially and reset the growth in 1 day of the week using a trigger for the new day (but you'll have to do the first reset manually). Something like this:
for i = 16, 28, 2 do
local count = GetObjectDwellingCreatures('houseInferno', i)
if count ~= - 1 then
SetObjectDwellingCreatures('houseInferno', i, 0)
end
end

function NewDay()
if GetDate(DAY_OF_WEEK) == 1 then
for i = 16, 28, 2 do
local count = GetObjectDwellingCreatures('houseInferno', i)
if count ~= - 1 then
SetObjectDwellingCreatures('houseInferno', i, 0)
end
end
end
end

Trigger(NEW_DAY_TRIGGER, 'NewDay')

This also doesn't work((( it still buys them every week.
User Avatar
6 years ago
Auto-translated
what if, instead of the numbers 16-28, you try using 15-27?
In reply to Gerter
6 years ago
Auto-translated
Gerter
what if, instead of the numbers 16-28, you try 15-27?
no, it doesn't work. (
Did I do everything correctly? I assigned the object's name in the "name" section and added the script in the "properties town" section.
User Avatar
6 years ago
Auto-translated
the script must be in the file specified in the Script property of the map.
check this line:
Attachments 1
1 file attached • Total size: 1.1 KB
In reply to Gerter
6 years ago
Auto-translated
Gerter
the script should be in the file specified in the Script property of the map.
check this line:
so, the script should be in the adventure map properties?
User Avatar
6 years ago
Auto-translated
yes. if there is nothing in this line, then you need to create a script through it. a file like MapScript.lua will appear in the map, and you need to write scripts in it. it is better to do this not through the Heroes editor, but to use some other text editor, and it is best to download the Homm5MapScriptEditor program and use it.
In reply to Gerter
6 years ago
Auto-translated
Gerter
Yes, if there's nothing in this line, you need to create a script through it. A file like MapScript.lua will appear in the map, and you need to write scripts in it. It's actually better to do this not through the Heroes editor, but using some other text editor, or even better, download the Homm5MapScriptEditor program and use it.
I did everything exactly as you said, but it doesn't work. ()
Attachments 1
1 file attached • Total size: 23.0 KB
In reply to MasteR
6 years ago
Auto-translated
MasteR
In the function parameter – prevOwner, and in the function body – prewOwner.
Okay, I see it now. The linter turned out to be useless :).
Killer5029
...
There’s a lot of information here in various formats. Take a look; it won't hurt.
/topic/13059/
In reply to Killer5029
User Avatar
6 years ago
Auto-translated
Killer5029
I did everything exactly as you said, but it doesn't work ()
Can you try clicking through 1 week and see if it works at the beginning of the second week?

Statistics

Welcome our newest member: recijeb