From f50c83e622b4b3bc7e3ee7c4550ad8fe6cb1b23b Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 30 Aug 2019 01:22:41 +0200 Subject: [PATCH] Crafting: Double-click crafts single --- mods/crafting/api.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mods/crafting/api.lua b/mods/crafting/api.lua index 9546c14..329903c 100644 --- a/mods/crafting/api.lua +++ b/mods/crafting/api.lua @@ -381,7 +381,18 @@ local function on_player_receive_fields(player, form_name, fields) local name = player:get_player_name() - if fields.do_craft_1 or fields.do_craft_10 then + local do_craft_1, do_craft_10 + if fields.craft_list then + -- Double-click on list entry crafts single time + local selection = minetest.explode_table_event(fields.craft_list) + if selection.type == "DCL" then + do_craft_1 = true + end + else + do_craft_1 = fields.do_craft_1 ~= nil + end + do_craft_10 = fields.do_craft_10 ~= nil + if do_craft_1 or do_craft_10 then local craftitems = crafting.get_crafts(inv) local wanted_itemstack = ItemStack(craftitems[crafting.userdata[name].row]) @@ -394,9 +405,9 @@ local function on_player_receive_fields(player, form_name, fields) local count = 1 - if fields.do_craft_1 then + if do_craft_1 then count = 1 - elseif fields.do_craft_10 then + elseif do_craft_10 then count = 10 else return