From b8333cf82a43d40fd06d6bd286959654e35d9c79 Mon Sep 17 00:00:00 2001 From: "jeanpatrick.guerrero@gmail.com" Date: Sat, 28 Nov 2015 17:29:46 +0100 Subject: [PATCH] Speed-up creative inventory initializing (~10x faster) --- mods/creative/init.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mods/creative/init.lua b/mods/creative/init.lua index 68d5180e..7bcf687f 100644 --- a/mods/creative/init.lua +++ b/mods/creative/init.lua @@ -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)