Fixed the treasures id generation system not always working
parent
981b02ffaa
commit
ecb1e283ec
|
@ -3,6 +3,20 @@ local mod = "skywars"
|
|||
local function treasure_to_itemstack() end
|
||||
|
||||
|
||||
function skywars.generate_treasure_id(arena)
|
||||
local max_id = 1
|
||||
|
||||
for i = 1, #arena.treasures do
|
||||
if arena.treasures[i].id > max_id then
|
||||
max_id = arena.treasures[i].id
|
||||
end
|
||||
end
|
||||
|
||||
return max_id+1
|
||||
end
|
||||
|
||||
|
||||
|
||||
function skywars.reorder_treasures(arena)
|
||||
-- Sorting the table from the rarest to the least rare treasure.
|
||||
for j = #arena.treasures, 2, -1 do
|
||||
|
|
|
@ -121,8 +121,7 @@ ChatCmdBuilder.new("skywars", function(cmd)
|
|||
return
|
||||
end
|
||||
|
||||
local item_id = 1
|
||||
if arena.treasures[#arena.treasures] then item_id = arena.treasures[#arena.treasures].id+1 end
|
||||
local item_id = skywars.generate_treasure_id(arena)
|
||||
local treasure = {
|
||||
name = treasure_name,
|
||||
rarity = rarity,
|
||||
|
@ -153,8 +152,7 @@ ChatCmdBuilder.new("skywars", function(cmd)
|
|||
return
|
||||
end
|
||||
|
||||
local item_id = 1
|
||||
if arena.treasures[#arena.treasures] then item_id = arena.treasures[#arena.treasures].id+1 end
|
||||
local item_id = skywars.generate_treasure_id(arena)
|
||||
treasure = {
|
||||
name = wielded_itemstack.name,
|
||||
rarity = rarity,
|
||||
|
|
Loading…
Reference in New Issue