Remove set_inventory_formspec in default, remove delay in sfinv
authorsfan5 <sfan5@live.de>
Wed, 17 May 2017 18:56:39 +0000 (20:56 +0200)
committerparamat <mat.gregory@virginmedia.com>
Thu, 18 May 2017 08:54:18 +0000 (09:54 +0100)
mods/creative/inventory.lua
mods/default/player.lua
mods/sfinv/api.lua

index 1363e294a0b1dddc285723d400c4ec975e96cc87..0e1d813eafc81313f7661e47a1a8ee4bd36d78b4 100644 (file)
@@ -33,16 +33,14 @@ function creative.init_creative_inventory(player)
                end,
        }, player_name)
 
-       creative.update_creative_inventory(player_name, minetest.registered_items)
+       return player_inventory[player_name]
 end
 
 function creative.update_creative_inventory(player_name, tab_content)
        local creative_list = {}
+       local inv = player_inventory[player_name] or
+                       creative.init_creative_inventory(minetest.get_player_by_name(player_name))
        local player_inv = minetest.get_inventory({type = "detached", name = "creative_" .. player_name})
-       local inv = player_inventory[player_name]
-       if not inv then
-               creative.init_creative_inventory(minetest.get_player_by_name(player_name))
-       end
 
        for name, def in pairs(tab_content) do
                if not (def.groups.not_in_creative_inventory == 1) and
@@ -161,7 +159,7 @@ function creative.register_tab(name, title, items)
 end
 
 minetest.register_on_joinplayer(function(player)
-       creative.init_creative_inventory(player)
+       creative.update_creative_inventory(player:get_player_name(), minetest.registered_items)
 end)
 
 creative.register_tab("all", "All", minetest.registered_items)
index cd89a24c5c3361d1a4d8b6defee3db4c766b4683..0a2078d6f7e0d5b9bc8cf2a90168e235b3235544 100644 (file)
@@ -95,11 +95,6 @@ minetest.register_on_joinplayer(function(player)
        default.player_set_model(player, "character.b3d")
        player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30)
 
-       -- set GUI
-       if not (creative and creative.is_enabled_for
-                       and creative.is_enabled_for(player:get_player_name())) then
-               player:set_inventory_formspec(default.gui_survival_form)
-       end
        player:hud_set_hotbar_image("gui_hotbar.png")
        player:hud_set_hotbar_selected_image("gui_hotbar_selected.png")
 end)
index ff6433b9bdc2a05b28f2a68108c1802ecb3296a4..bd6de1edfbce9178adccec22fd0aae08c2a0c556 100644 (file)
@@ -129,9 +129,7 @@ end
 
 minetest.register_on_joinplayer(function(player)
        if sfinv.enabled then
-               minetest.after(0.5, function()
-                       sfinv.set_player_inventory_formspec(player)
-               end)
+               sfinv.set_player_inventory_formspec(player)
        end
 end)