Fixed the chest id generation

master
Giov4 2020-12-21 15:53:07 +01:00
parent ecb1e283ec
commit bfbac33a9d
2 changed files with 15 additions and 2 deletions

View File

@ -10,6 +10,20 @@ end
function skywars.generate_chest_id(arena)
local max_id = 1
for i = 1, #arena.chests do
if arena.chests[i].id > max_id then
max_id = arena.chests[i].id
end
end
return max_id+1
end
function fill_chests(arena)
for i, chest in pairs(arena.chests) do
local treasures = skywars.select_random_treasures(chest, arena)

View File

@ -385,8 +385,7 @@ ChatCmdBuilder.new("skywars", function(cmd)
return
end
local chest_id = 1
if arena.chests[#arena.chests] then chest_id = arena.chests[#arena.chests].id+1 end
local chest_id = skywars.generate_chest_id(arena)
local chest =
{
pos = pos,