Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function minetest.item_place(itemstack, placer, pointed_thing)
- -- Call on_rightclick if the pointed node defines it
- if pointed_thing.type == "node" and placer and
- not placer:get_player_control().sneak then
- local n = minetest.env:get_node(pointed_thing.under)
- local nn = n.name
- if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then
- return minetest.registered_nodes[nn].on_rightclick(itemstack,placer, pointed_thing.under, n)
- end
- end
- if itemstack:get_definition().type == "node" then
- return minetest.item_place_node(itemstack, placer, pointed_thing)
- elseif itemstack:get_definition().type ~= "none" then
- return minetest.item_place_object(itemstack, placer, pointed_thing)
- end
- end
- And example usage:
- on_rightclick = function(itemstack,clicker, pos, node)
- if itemstack:get_name() == "default:sign_wall" then
- fdir = minetest.dir_to_facedir(clicker:get_look_dir())
- minetest.env:add_node(pos, {name = "homedecor:fence_brass_with_sign", param2 = fdir})
- itemstack:take_item()
- return itemstack
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement