bane_
Howardianism High-Priest
- Joined
- Nov 27, 2013
- Messages
- 1,559
I made a research but couldn't get an answer. I can try to test it in-game, but it will be a pain to just try and figure it out blindly, so I came asking help.
Can I do "table.insert(tablewhatever, #t+1, value1, value2)?
Or should it be done like "table.insert(tablewhatever, #t+1, [value1]=value2)"?
I want them to be connected, because I want to link a value that will be increased by a variable to a Civilization ID, so, when I have to update that value I would just look for the right ID (with 'for _, v in ipairs' I suppose) and then change the value setting it to the sum of the old+new value.
The relevant snippet:
Where iTotalCS would be modified every turn when a certain function is fired, though I'm not absolutely sure it is this way (this one I can probably figure out on my on, though).
The table is cleaned every start of a turn.
Was it clear? I hope so.
[[Also, I'm a bit confused about the difference between global and local variables; do local only work for the function they are in? Anything trying to call it from the outside will get 'nil'?]]
Can I do "table.insert(tablewhatever, #t+1, value1, value2)?
Or should it be done like "table.insert(tablewhatever, #t+1, [value1]=value2)"?
I want them to be connected, because I want to link a value that will be increased by a variable to a Civilization ID, so, when I have to update that value I would just look for the right ID (with 'for _, v in ipairs' I suppose) and then change the value setting it to the sum of the old+new value.
The relevant snippet:
Code:
function HHLaBomba(pPlayer, pPlot, iPlotOwner, unit)
for k, v in pairs(BombBlameCount) do
if v == iPlotOwner then
iTotalCS = (k + unit:GetCombatStrength())
k = iTotalCS
else
iTotalCS = (iTotalCS + unit:GetCombatStrength())
table.insert(BombBlameCount, #t+1, [iTotalCS]=iPlotOwner)
end
end
end
Where iTotalCS would be modified every turn when a certain function is fired, though I'm not absolutely sure it is this way (this one I can probably figure out on my on, though).
The table is cleaned every start of a turn.
Was it clear? I hope so.

[[Also, I'm a bit confused about the difference between global and local variables; do local only work for the function they are in? Anything trying to call it from the outside will get 'nil'?]]