Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
#1094
Auto-translated
It can be done differently, but then you'll have to adjust the paths. Therefore, it's better to do it exactly as it is there, so you won't have to change anything. And yes, keep in mind that there will probably be several files that you need.
 

К А
Стикеры GBF в Telegram
User Avatar
#1095
Auto-translated
That's exactly where I messed up, which is why nothing worked =) I only took one file when I needed more =)

Thanks to everyone.

Whatever
In reply to JORAJAN
#1096
Auto-translated
Please help. Why does this script
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?
User Avatar
#1097
Auto-translated
Create a new array for GetObjectArmySlotCreature; there’s no need to put everything into one array, especially one that’s organized differently.
 

К А
Стикеры GBF в Telegram
In reply to Ment
#1098
Auto-translated
Ment
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?
In reply to JORAJAN
User Avatar
#1099
Auto-translated
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][i] = {t, n} end end function capture_gar(oldowner, newowner, hero, gar) for i = 0, 6 do if garrisons[gar][i][1] ~= 0 then AddObjectCreatures(gar, garrisons[gar][i][1], garrisons[gar][i][2]*2) end end DenyGarrisonCreaturesTakeAway(gar, 1) Trigger(5, gar, nil) end ```

Added 10 minutes later
Ment
Create a new array for GetObjectArmySlotCreature, there's no need to put everything in one, and organize it differently.
Indeed, the loop executes the block for the values that it created itself.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
#1100
Auto-translated
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)
end
To 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.
 

К А
Стикеры GBF в Telegram
In reply to Ment
User Avatar
#1101
Auto-translated
Checked. The error still occurs because, after executing the block for all garrisons, the iterator starts iterating through the arrays of troop information that it created during that time; this explains the error invalid parameter type: object name must be string (and it's not a string, but a table).
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
#1102
Auto-translated
it's stuck in a loop.
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.
In reply to JORAJAN
User Avatar
#1103
Auto-translated
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:
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to RedHeavenHero
#1104
Auto-translated
I thought it would be more difficult to implement a geometric progression. But I decided to compensate for this with the strength of the monsters. A geometric progression will also work. I will be testing it.
User Avatar
#1105
Auto-translated
Hey everyone, I have a question:
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?

Whatever
User Avatar
#1106
Auto-translated
In the trigger, yes... But what is the problem?
 

К А
Стикеры GBF в Telegram
User Avatar
#1107
Auto-translated
The problem is that when writing a function inside another function, the inner function stops recognizing the `heroname` command, and you have to write `%heroname`. But then, the HeroesV_Map_Script_Editor (or something like that) throws a **non-existent** error, and it also stops displaying the other real errors in the script :smile18:

Whatever
User Avatar
#1108
Auto-translated
Hmm, I think I understand. So, the problem is that the talkbox refers to functions, but doesn't pass the heroname as an argument to them? What if we make heroname a global variable?
 

К А
Стикеры GBF в Telegram

Statistics

Welcome our newest member: dodoD0D0

Users Online 2 users 1379 guests