From d4d7d8792f1a200aa46879b2d9ebf2b0a6bcfff0 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 1 Jun 2017 22:57:13 +0200 Subject: [PATCH] Fix no craftgrid drop after close; fix creative The 2nd bug in Creative Mode was that the inventory got reset each time you closed it. --- mods/HUD/mcl_inventory/creative.lua | 2 -- mods/HUD/mcl_inventory/init.lua | 19 ++++++------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/mods/HUD/mcl_inventory/creative.lua b/mods/HUD/mcl_inventory/creative.lua index 0d870b91dd..5460e4218c 100644 --- a/mods/HUD/mcl_inventory/creative.lua +++ b/mods/HUD/mcl_inventory/creative.lua @@ -335,8 +335,6 @@ mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, show, p end if pagenum ~= nil then formspec = formspec .. "p"..tostring(pagenum) end - -- inventory marker - formspec = formspec .. "cin" player:set_inventory_formspec(formspec) end diff --git a/mods/HUD/mcl_inventory/init.lua b/mods/HUD/mcl_inventory/init.lua index 45b3b8fa21..5ec6ea472a 100644 --- a/mods/HUD/mcl_inventory/init.lua +++ b/mods/HUD/mcl_inventory/init.lua @@ -103,10 +103,8 @@ local function set_inventory(player, armor_change_only) "listring[current_player;main]".. "listring[current_player;craft]".. "listring[current_player;main]".. - "listring[detached:"..player_name.."_armor;armor]".. - -- inventory marker - "inv" - + "listring[detached:"..player_name.."_armor;armor]" + player:set_inventory_formspec(form) end @@ -124,22 +122,17 @@ local function set_workbench(player) "image_button[8,0;1,1;craftguide_book.png;__mcl_craftguide;]".. "tooltip[__mcl_craftguide;Show crafting recipes]".. "listring[current_player;main]".. - "listring[current_player;craft]".. - -- inventory marker - "wob" + "listring[current_player;craft]" --player:set_inventory_formspec(form) minetest.show_formspec(player:get_player_name(), "main", form) end ---drop craf items and reset inventory on closing +-- Drop items in craft grid and reset inventory on closing minetest.register_on_player_receive_fields(function(player, formname, fields) if fields.quit then - local formspec = player:get_inventory_formspec() - local size = string.len(formspec) - local marker = string.sub(formspec,size-2) - if marker == "inv" or marker == "wob" or marker == "cin" then - drop_fields(player,"craft") + drop_fields(player,"craft") + if not minetest.setting_getbool("creative_mode") and formname == "" then set_inventory(player) end end