From b486b6523156e5325f9436b298758e83ef3dd3cc Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Thu, 10 Dec 2020 15:41:59 +0100 Subject: [PATCH] Fix some bugs --- init.lua | 27 +++++++++++++++++---------- locale/craftguide.fr.tr | 2 +- locale/template | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/init.lua b/init.lua index 1117a12..5aa9d22 100644 --- a/init.lua +++ b/init.lua @@ -860,21 +860,28 @@ local function craft_stack(player, pname, data, _f) local scrbar_val = data[sprintf("scrbar_%s", _f.craft_rcp and "rcp" or "usg")] for name, count in pairs(data.export_counts[rcp_usg].rcp) do - if is_group(name) then - local groups = extract_groups(name) - local items = groups_to_items(groups, true) + local items = {[name] = count} - for _, item in ipairs(items) do + if is_group(name) then + items = {} + local groups = extract_groups(name) + local item_groups = groups_to_items(groups, true) + local remaining = count + + for _, item in ipairs(item_groups) do for _name, _count in pairs(data.export_counts[rcp_usg].inv) do - if item == _name and _count >= count then - name = _name - break + if item == _name and remaining > 0 then + local c = min(remaining, _count) + items[item] = c + remaining = remaining - c end end end end - inv:remove_item("main", sprintf("%s %s", name, count * scrbar_val)) + for k, v in pairs(items) do + inv:remove_item("main", sprintf("%s %s", k, v * scrbar_val)) + end end local count = stackcount * scrbar_val @@ -883,7 +890,7 @@ local function craft_stack(player, pname, data, _f) if inv:room_for_item("main", stack) then inv:add_item("main", stack) - msg(pname, sprintf(S"%s added to your inventory", message)) + msg(pname, sprintf("%s added in your inventory", message)) else local dir = player:get_look_dir() local ppos = player:get_pos() @@ -891,7 +898,7 @@ local function craft_stack(player, pname, data, _f) local look_at = vec_add(ppos, vec_mul(dir, 1)) core.add_item(look_at, stack) - msg(pname, sprintf(S"%s crafted", message)) + msg(pname, sprintf("%s crafted", message)) end end diff --git a/locale/craftguide.fr.tr b/locale/craftguide.fr.tr index 105a7e2..7c1e950 100644 --- a/locale/craftguide.fr.tr +++ b/locale/craftguide.fr.tr @@ -63,5 +63,5 @@ Cannot mark this item. Limit of bookmarks reached.=Impossible de mettre cet item Only drop if using one of these tools: @1=Tombe seulement si détruit avec un de ces outils : @1 Only drop if using this tool: @1=Tombe seulement si détruit avec cet outil : @1 Craft this stack=Fabriquer cet objet -@1 added to your inventory=@1 ajouté(s) à votre inventaire +@1 added in your inventory=@1 mis dans votre inventaire @1 crafted=@1 fabriqué(s) diff --git a/locale/template b/locale/template index d51aa59..3d77e16 100644 --- a/locale/template +++ b/locale/template @@ -63,5 +63,5 @@ Cannot mark this item. Limit of bookmarks reached.= Only drop if using one of these tools: @1= Only drop if using this tool: @1= Craft this stack= -@1 added to your inventory= +@1 added in your inventory= @1 crafted=