From: JPG Date: Tue, 24 Jan 2017 23:45:23 +0000 (+0100) Subject: Polish previous fix X-Git-Tag: 1.0~6 X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=657311360759ab1f504e84fb8cd4cb94d0ae9d8e;p=xdecor.git Polish previous fix --- diff --git a/src/workbench.lua b/src/workbench.lua index ef94d71..32e0eb8 100644 --- a/src/workbench.lua +++ b/src/workbench.lua @@ -76,11 +76,6 @@ function workbench:repairable(stack) end function workbench:get_output(inv, input, name) - if inv:is_empty("input") then - inv:set_list("forms", {}) - return - end - local output = {} for _, n in pairs(self.defs) do local count = min(n[2] * input:get_count(), input:get_stack_max()) @@ -203,21 +198,9 @@ end function workbench.on_take(pos, listname, index, stack, player) local inv = minetest.get_meta(pos):get_inventory() local input = inv:get_stack("input", 1) - local fromlist = inv:get_stack(listname, index) local inputname = input:get_name() local stackname = stack:get_name() - if not fromlist:is_empty() and fromlist:get_name() ~= stackname then - local player_inv = player:get_inventory() - if player_inv:room_for_item("main", fromlist) then - player_inv:add_item("main", fromlist) - end - - inv:set_list("input", {}) - inv:set_list("forms", {}) - return - end - if listname == "input" then if stackname == inputname then workbench:get_output(inv, input, stackname) @@ -225,6 +208,14 @@ function workbench.on_take(pos, listname, index, stack, player) inv:set_list("forms", {}) end elseif listname == "forms" then + local fromstack = inv:get_stack(listname, index) + if not fromstack:is_empty() and fromstack:get_name() ~= stackname then + local player_inv = player:get_inventory() + if player_inv:room_for_item("main", fromstack) then + player_inv:add_item("main", fromstack) + end + end + input:take_item(ceil(stack:get_count() / workbench.defs[index][2])) inv:set_stack("input", 1, input) workbench:get_output(inv, input, inputname)