Skip to content

Commit

Permalink
Speed-up creative inventory initializing (~10x faster)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanpatrick.guerrero@gmail.com authored and paramat committed Dec 6, 2015
1 parent abf0ca9 commit b8333cf
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions mods/creative/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ minetest.after(0, function()
for name,def in pairs(minetest.registered_items) do
if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0)
and def.description and def.description ~= "" then
table.insert(creative_list, name)
creative_list[#creative_list+1] = name
end
end
table.sort(creative_list)
inv:set_size("main", #creative_list)
for _,itemstring in ipairs(creative_list) do
inv:add_item("main", ItemStack(itemstring))
end
inv:set_list("main", creative_list)
creative_inventory.creative_inventory_size = #creative_list
--print("creative inventory size: "..dump(creative_inventory.creative_inventory_size))
end)
Expand Down

0 comments on commit b8333cf

Please sign in to comment.