Skip to content

Commit

Permalink
Autocrafting: Don't delete items when craft grid is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
random-geek committed Mar 21, 2019
1 parent 4fed2b9 commit 6110f1b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions autocrafting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ end
cg.auto_craft = function(player, craft, num)
inv = player:get_inventory()

if not inv:is_empty("craft") then
-- Attempt to move items to the player's main inventory.
for idx, stack in ipairs(inv:get_list("craft")) do
if not stack:is_empty() then
stack = inv:add_item("main", stack)
inv:set_stack("craft", idx, stack)
end
end

-- Check again, and return if not all items were moved.
if not inv:is_empty("craft") then return end
end

if craft.width > inv:get_width("craft") or table.maxn(craft.items) > inv:get_size("craft") then return end

local width = craft.width == 0 and inv:get_width("craft") or craft.width
Expand Down

0 comments on commit 6110f1b

Please sign in to comment.