Auto-translated
My dear friends! Could anyone spare a few minutes to help me out?
I'm trying to create a script that doubles the army size. I borrowed the script from "Random Wars" as a base.
[spoiler=This works, but only for one hero]
function incom()
local day = GetDate(3)
if day == 2 then
local hero = GetPlayerHeroes(5)[0]
local types = {}
types[0], types[1], types[2], types[3], types[4], types[5],types[6] = GetHeroCreaturesTypes(hero)
for i = 0, 6 do
if HasHeroCreature(hero, types)
then
--local stack = GetCreatureById(types)
local amount = GetHeroCreatures(hero, types)
AddHeroCreatures(hero, types, amount, i)
end
end
end
end
Trigger(NEW_DAY_TRIGGER, "incom")
[/spoiler]
I want to implement a scheme with multiple heroes, but I don't know how to write it correctly.
[spoiler=Doesn't work]
function incom()
local day = GetDate(3)
if day == 2 then
local hero = {}
hero[0], hero[1], hero[2], hero[3] = GetPlayerHeroes(5)
for k = 0, 3 do
if IsHeroAlive(hero)
then
local types = {}
types[0], types[1], types[2], types[3], types[4], types[5],types[6] = GetHeroCreaturesTypes(hero)
for i = 0, 6 do
if HasHeroCreature(hero, types)
then
local stack = GetCreatureById(types)
local amount = GetHeroCreatures(hero, types)
AddHeroCreatures(hero, types, amount, i)
end
end
end
end
end
end
Trigger(NEW_DAY_TRIGGER, "incom")
[/spoiler]
The function IsHeroAlive(hero) produces an invalid argument #1, i.e., instead of 'hero', something inedible appears.
I'm trying to create a script that doubles the army size. I borrowed the script from "Random Wars" as a base.
[spoiler=This works, but only for one hero]
function incom()
local day = GetDate(3)
if day == 2 then
local hero = GetPlayerHeroes(5)[0]
local types = {}
types[0], types[1], types[2], types[3], types[4], types[5],types[6] = GetHeroCreaturesTypes(hero)
for i = 0, 6 do
if HasHeroCreature(hero, types)
then
--local stack = GetCreatureById(types)
local amount = GetHeroCreatures(hero, types)
AddHeroCreatures(hero, types, amount, i)
end
end
end
end
Trigger(NEW_DAY_TRIGGER, "incom")
[/spoiler]
I want to implement a scheme with multiple heroes, but I don't know how to write it correctly.
[spoiler=Doesn't work]
function incom()
local day = GetDate(3)
if day == 2 then
local hero = {}
hero[0], hero[1], hero[2], hero[3] = GetPlayerHeroes(5)
for k = 0, 3 do
if IsHeroAlive(hero)
then
local types = {}
types[0], types[1], types[2], types[3], types[4], types[5],types[6] = GetHeroCreaturesTypes(hero)
for i = 0, 6 do
if HasHeroCreature(hero, types)
then
local stack = GetCreatureById(types)
local amount = GetHeroCreatures(hero, types)
AddHeroCreatures(hero, types, amount, i)
end
end
end
end
end
end
Trigger(NEW_DAY_TRIGGER, "incom")
[/spoiler]
The function IsHeroAlive(hero) produces an invalid argument #1, i.e., instead of 'hero', something inedible appears.