Advertisement
Guest User

Untitled

a guest
Feb 9th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. function minetest.item_place(itemstack, placer, pointed_thing)
  2. -- Call on_rightclick if the pointed node defines it
  3. if pointed_thing.type == "node" and placer and
  4. not placer:get_player_control().sneak then
  5. local n = minetest.env:get_node(pointed_thing.under)
  6. local nn = n.name
  7. if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then
  8. return minetest.registered_nodes[nn].on_rightclick(itemstack,placer, pointed_thing.under, n)
  9. end
  10. end
  11.  
  12. if itemstack:get_definition().type == "node" then
  13. return minetest.item_place_node(itemstack, placer, pointed_thing)
  14. elseif itemstack:get_definition().type ~= "none" then
  15. return minetest.item_place_object(itemstack, placer, pointed_thing)
  16. end
  17. end
  18.  
  19. And example usage:
  20.  
  21. on_rightclick = function(itemstack,clicker, pos, node)
  22. if itemstack:get_name() == "default:sign_wall" then
  23. fdir = minetest.dir_to_facedir(clicker:get_look_dir())
  24. minetest.env:add_node(pos, {name = "homedecor:fence_brass_with_sign", param2 = fdir})
  25. itemstack:take_item()
  26. return itemstack
  27. end
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement