Prevent placing items in some slots and rename itemframe file

This commit is contained in:
jp 2015-07-05 12:08:33 +02:00
parent 89b1db07c8
commit e9e255908f
4 changed files with 25 additions and 5 deletions

View File

@ -15,6 +15,7 @@ end
local function hive_dig(pos, player) local function hive_dig(pos, player)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
if not inv:is_empty("honey") then if not inv:is_empty("honey") then
return false return false
end end
@ -37,7 +38,14 @@ xdecor.register("hive", {
on_punch = function(pos, node, puncher, pointed_thing) on_punch = function(pos, node, puncher, pointed_thing)
local health = puncher:get_hp() local health = puncher:get_hp()
puncher:set_hp(health-4) puncher:set_hp(health-4)
end end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local to_stack = inv:get_stack(listname, index)
if listname == "honey" then return 0 end
end,
}) })
minetest.register_abm({ minetest.register_abm({

View File

@ -5,7 +5,7 @@ dofile(modpath.."/handlers/nodeboxes.lua")
dofile(modpath.."/handlers/registration.lua") dofile(modpath.."/handlers/registration.lua")
dofile(modpath.."/crafts.lua") dofile(modpath.."/crafts.lua")
dofile(modpath.."/hive.lua") dofile(modpath.."/hive.lua")
dofile(modpath.."/itemframes.lua") dofile(modpath.."/itemframe.lua")
dofile(modpath.."/mailbox.lua") dofile(modpath.."/mailbox.lua")
dofile(modpath.."/rope.lua") dofile(modpath.."/rope.lua")
dofile(modpath.."/nodes.lua") dofile(modpath.."/nodes.lua")

View File

@ -102,10 +102,21 @@ local function xdig(pos, player)
or not inv:is_empty("fuel") or not inv:is_empty("src") then or not inv:is_empty("fuel") or not inv:is_empty("src") then
return false return false
end end
return true return true
end end
local function xput(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local to_stack = inv:get_stack(listname, index)
if listname == "output" then
return 0
else
return 99
end
end
xdecor.register("worktable", { xdecor.register("worktable", {
description = "Work Table", description = "Work Table",
groups = {snappy=3}, groups = {snappy=3},
@ -117,7 +128,8 @@ xdecor.register("worktable", {
}, },
on_construct = xconstruct, on_construct = xconstruct,
on_receive_fields = xfields, on_receive_fields = xfields,
can_dig = xdig can_dig = xdig,
allow_metadata_inventory_put = xput
}) })
local function light(mat) local function light(mat)