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")
Posts from Scripts
Auto-translated
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.
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.
Added 6 minutes later
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.
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')
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.
what if, instead of the numbers 16-28, you try 15-27?
Did I do everything correctly? I assigned the object's name in the "name" section and added the script in the "properties town" section.
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.
In the function parameter –prevOwner, and in the function body –prewOwner.
...
/topic/13059/