Prevent taking worktable's output stack when player inventory is full

master
jp 2015-11-22 15:03:53 +01:00
parent f0d50395b9
commit 22cf219ca9
3 changed files with 15 additions and 7 deletions

View File

@ -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)

View File

@ -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
})

View File

@ -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