From 22cf219ca9884eb7e896227295bd7bfae7c31e13 Mon Sep 17 00:00:00 2001 From: jp Date: Sun, 22 Nov 2015 15:03:53 +0100 Subject: [PATCH] Prevent taking worktable's output stack when player inventory is full --- enchanting.lua | 10 +++++++--- nodes.lua | 2 +- worktable.lua | 10 +++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/enchanting.lua b/enchanting.lua index 8c7c8bd..3ba2898 100644 --- a/enchanting.lua +++ b/enchanting.lua @@ -31,9 +31,13 @@ function enchanting.on_put(pos, listname, _, stack, _) local stn = stack:get_name() local meta = minetest.get_meta(pos) - if listname == "tool" and stn:find("sword") then - meta:set_string("formspec", enchanting.swords_fs()) - else meta:set_string("formspec", enchanting.tools_fs()) end + if listname == "tool" then + if stn:find("sword") then + meta:set_string("formspec", enchanting.swords_fs()) + else + meta:set_string("formspec", enchanting.tools_fs()) + end + end end function enchanting.is_allowed(toolname) diff --git a/nodes.lua b/nodes.lua index e307421..d274df6 100644 --- a/nodes.lua +++ b/nodes.lua @@ -149,7 +149,7 @@ if minetest.get_modpath("bucket") then return itemstack else if original_bucket_on_use then return original_bucket_on_use(itemstack, user, pointed_thing) - else return end + end end end }) diff --git a/worktable.lua b/worktable.lua index 4516c11..ebf4df3 100644 --- a/worktable.lua +++ b/worktable.lua @@ -104,14 +104,18 @@ function worktable.put(_, listname, _, stack, _) return 0 end -function worktable.take(pos, listname, _, stack, _) +function worktable.take(pos, listname, _, stack, player) local inv = minetest.get_meta(pos):get_inventory() + local user_inv = player:get_inventory() local inputstack = inv:get_stack("input", 1):get_name() local mod, node = inputstack:match("([%a_]+):([%a_]+)") if listname == "forms" then - if not worktable.contains(nodes[mod], node) then return 0 end - return -1 + if worktable.contains(nodes[mod], node) and + user_inv:room_for_item("main", stack:get_name()) then + return -1 + end + return 0 end return stack:get_count() end