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 stn = stack:get_name()
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
if listname == "tool" and stn:find("sword") then if listname == "tool" then
meta:set_string("formspec", enchanting.swords_fs()) if stn:find("sword") then
else meta:set_string("formspec", enchanting.tools_fs()) end meta:set_string("formspec", enchanting.swords_fs())
else
meta:set_string("formspec", enchanting.tools_fs())
end
end
end end
function enchanting.is_allowed(toolname) function enchanting.is_allowed(toolname)

View File

@ -149,7 +149,7 @@ if minetest.get_modpath("bucket") then
return itemstack return itemstack
else if original_bucket_on_use then else if original_bucket_on_use then
return original_bucket_on_use(itemstack, user, pointed_thing) return original_bucket_on_use(itemstack, user, pointed_thing)
else return end end
end end
end end
}) })

View File

@ -104,14 +104,18 @@ function worktable.put(_, listname, _, stack, _)
return 0 return 0
end end
function worktable.take(pos, listname, _, stack, _) function worktable.take(pos, listname, _, stack, player)
local inv = minetest.get_meta(pos):get_inventory() local inv = minetest.get_meta(pos):get_inventory()
local user_inv = player:get_inventory()
local inputstack = inv:get_stack("input", 1):get_name() local inputstack = inv:get_stack("input", 1):get_name()
local mod, node = inputstack:match("([%a_]+):([%a_]+)") local mod, node = inputstack:match("([%a_]+):([%a_]+)")
if listname == "forms" then if listname == "forms" then
if not worktable.contains(nodes[mod], node) then return 0 end if worktable.contains(nodes[mod], node) and
return -1 user_inv:room_for_item("main", stack:get_name()) then
return -1
end
return 0
end end
return stack:get_count() return stack:get_count()
end end