WC: Fix error when too few artifacts are defined
Previously the lua could stop working when there were less than 9 artifacts defined in [world_conquest_data]
This commit is contained in:
parent
8bbaba898d
commit
d5b7972c6f
1 changed files with 5 additions and 3 deletions
|
@ -8,9 +8,11 @@ function wc2_invest.add_items(side_num, num_items)
|
|||
local items_left = stringx.split(side.variables["wc2.items_left"] or "")
|
||||
local items_available = stringx.split(side.variables["wc2.items"] or "")
|
||||
for j = 1, num_items do
|
||||
local i = mathx.random(#items_left)
|
||||
table.insert(items_available, items_left[i])
|
||||
table.remove(items_left, i)
|
||||
if #items_left > 0 then
|
||||
local i = mathx.random(#items_left)
|
||||
table.insert(items_available, items_left[i])
|
||||
table.remove(items_left, i)
|
||||
end
|
||||
end
|
||||
|
||||
side.variables["wc2.items_left"] = table.concat(items_left, ",")
|
||||
|
|
Loading…
Add table
Reference in a new issue