Posts from Scripts
Thanks to everyone.
garrisons={'G1', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8', 'G9'}
for j, gar in garrisons do
Trigger(5, gar, 'capture_gar')
garrisons[gar] = {}
for i = 0, 6 do
local t, n = GetObjectArmySlotCreature(gar, i)
garrisons[gar]= {t, n}
end
end
function capture_gar(oldowner, newowner, hero, gar)
for i = 0, 6 do
if garrisons[gar][1] ~= 0 then
AddObjectCreatures(gar, garrisons[gar][1], garrisons[gar][2]*2)
end
end
DenyGarrisonCreaturesTakeAway(gar, 1)
Trigger(5, gar, nil)
end
produce this error: invalid parameter type: object name must be string?
Create a new array for GetObjectArmySlotCreature; there's no need to put everything into one array, especially one that's organized differently.
I'm sorry, but I don't understand programming, so I didn't understand anything.
Could you help me?
Added 10 minutes later
Create a new array for GetObjectArmySlotCreature, there's no need to put everything in one, and organize it differently.
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
I'm sorry, but I don't understand programming, and I naturally didn't understand anything.
Could you help me?
garrisons={'G1', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8', 'G9'}
garrisons_army={}
for j, gar in garrisons do
Trigger(5, gar, 'capture_gar')
for i = 0, 6 do
local t, n = GetObjectArmySlotCreature(gar, i)
garrisons_army[gar]= {t, n}
end
end
function capture_gar(oldowner, newowner, hero, gar)
for i = 0, 6 do
if garrisons_army[gar][1] ~= 0 then
AddObjectCreatures(gar, garrisons_army[gar][1], garrisons_army[gar][2]*2)
end
end
DenyGarrisonCreaturesTakeAway(gar, 1)
Trigger(5, gar, nil)
endTo be honest, I'm not sure if it will work. I'm just not sure if the variable will be initialized correctly as a three-dimensional array. And yes, it might be better to use a less elegant but more formal method that is guaranteed to work. To do this, we need to avoid using three-dimensional arrays, and two-dimensional arrays are also not desirable. But this is only if we can't create a working version of the "beautiful" option.
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
but the second time, it doesn't double the troops in the garrison; it just adds the same amount.
it needs to double the troops each time the garrison is cleared.
garrison_names={'G1', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8', 'G9'}
garrisons={}
for j, gar in garrison_names do
Trigger(5, gar, 'capture_gar')
garrisons[gar] = {}
for i = 0, 6 do
local t, n = GetObjectArmySlotCreature(gar, i)
garrisons[gar]= {t, n}
end
end
function capture_gar(oldowner, newowner, hero, gar)
for i = 0, 6 do
if garrisons[gar][1] ~= 0 then
garrisons[gar][2] = garrisons[gar][2] * 2
AddObjectCreatures(gar, garrisons[gar][1], garrisons[gar][2])
end
end
DenyGarrisonCreaturesTakeAway(gar, 1)
Trigger(5, gar, nil)
end
But a geometric progression is a dangerous thing :smile51:
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
I created a decent talkbox. I added everything that was needed. Then I created a function, and it works. However, a question arose:
What should I do if I need, for example, that when a hero touches an object, he receives a question with answer options, each of which means giving him an artifact? Should I put the talkbox function inside the touch trigger function (heroname) with the %heroname specified, or can I leave it separate, but then the script simply doesn't understand who to give the artifact to? What should I do?