Connection ErrorBad RequestSession ExpiredSign in requiredForbiddenNot FoundToo Many RequestsServer ErrorBad GatewayService UnavailableGateway TimeoutHTTP Version Not Supported
Session Expired
Your session has expired. Please log in to continue.
Sign in required
You need an account to do that. Sign in or create one — it only takes a minute.
Request Failed
We encountered an issue while processing your request.
Please check your internet connection and try again.
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.
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?
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.
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.
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).
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.
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:
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.
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?
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:
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?