mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 04:21:07 +01:00
Add screwdriver support for itemframes
This commit is contained in:
parent
644187e204
commit
d502ac3bec
1 changed files with 31 additions and 9 deletions
|
@ -56,14 +56,17 @@ local remove_item_entity = function(pos, node)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local update_item_entity = function(pos, node)
|
local update_item_entity = function(pos, node, param2)
|
||||||
remove_item_entity(pos, node)
|
remove_item_entity(pos, node)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local item = inv:get_stack("main", 1)
|
local item = inv:get_stack("main", 1)
|
||||||
if not item:is_empty() then
|
if not item:is_empty() then
|
||||||
|
if not param2 then
|
||||||
|
param2 = node.param2
|
||||||
|
end
|
||||||
if node.name == "mcl_itemframes:item_frame" then
|
if node.name == "mcl_itemframes:item_frame" then
|
||||||
local posad = facedir[node.param2]
|
local posad = facedir[param2]
|
||||||
pos.x = pos.x + posad.x*6.5/16
|
pos.x = pos.x + posad.x*6.5/16
|
||||||
pos.y = pos.y + posad.y*6.5/16
|
pos.y = pos.y + posad.y*6.5/16
|
||||||
pos.z = pos.z + posad.z*6.5/16
|
pos.z = pos.z + posad.z*6.5/16
|
||||||
|
@ -78,7 +81,7 @@ local update_item_entity = function(pos, node)
|
||||||
end
|
end
|
||||||
lua:_update_texture()
|
lua:_update_texture()
|
||||||
if node.name == "mcl_itemframes:item_frame" then
|
if node.name == "mcl_itemframes:item_frame" then
|
||||||
local yaw = math.pi*2 - node.param2 * math.pi/2
|
local yaw = math.pi*2 - param2 * math.pi/2
|
||||||
e:set_yaw(yaw)
|
e:set_yaw(yaw)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -96,11 +99,6 @@ local drop_item = function(pos, node, meta)
|
||||||
remove_item_entity(pos, node)
|
remove_item_entity(pos, node)
|
||||||
end
|
end
|
||||||
|
|
||||||
local on_rotate
|
|
||||||
if minetest.get_modpath("screwdriver") then
|
|
||||||
on_rotate = screwdriver.disallow
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node("mcl_itemframes:item_frame",{
|
minetest.register_node("mcl_itemframes:item_frame",{
|
||||||
description = S("Item Frame"),
|
description = S("Item Frame"),
|
||||||
_doc_items_longdesc = S("Item frames are decorative blocks in which items can be placed."),
|
_doc_items_longdesc = S("Item frames are decorative blocks in which items can be placed."),
|
||||||
|
@ -189,7 +187,31 @@ minetest.register_node("mcl_itemframes:item_frame",{
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
drop_item(pos, node, meta)
|
drop_item(pos, node, meta)
|
||||||
end,
|
end,
|
||||||
on_rotate = on_rotate,
|
on_rotate = function(pos, node, user, mode, param2)
|
||||||
|
if mode == screwdriver.ROTATE_FACE then
|
||||||
|
-- Rotate face
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
|
||||||
|
local objs = nil
|
||||||
|
if node.name == "mcl_itemframes:item_frame" then
|
||||||
|
objs = minetest.get_objects_inside_radius(pos, .5)
|
||||||
|
end
|
||||||
|
if objs then
|
||||||
|
for _, obj in ipairs(objs) do
|
||||||
|
if obj and obj:get_luaentity() and obj:get_luaentity().name == "mcl_itemframes:item" then
|
||||||
|
update_item_entity(pos, node, (node.param2+1) % 4)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return
|
||||||
|
elseif mode == screwdriver.ROTATE_AXIS then
|
||||||
|
-- Place screwdriver into itemframe
|
||||||
|
minetest.registered_nodes["mcl_itemframes:item_frame"].on_rightclick(pos, node, user, ItemStack("screwdriver:screwdriver"))
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
|
Loading…
Reference in a new issue