init.lua 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. decals = {}
  2. decals.on_punch = function(pos, node, puncher, pointed_thing)
  3. local player = puncher:get_player_name()
  4. if minetest.check_player_privs(player, { creative = true }) then
  5. minetest.swap_node(pos, {name = node.name, param2 = node.param2-32})
  6. end
  7. end
  8. decals.on_rightclick = function(pos, node, clicker)
  9. local player = clicker:get_player_name()
  10. if minetest.check_player_privs(player, { creative = true }) then
  11. minetest.swap_node(pos, {name = node.name, param2 = node.param2+32})
  12. end
  13. end
  14. function decals.register_decal(name, desc)
  15. minetest.register_node('decals:'..name, {
  16. description = desc,
  17. drawtype = 'mesh',
  18. mesh = 'decals_mesh.obj',
  19. tiles = {'decals_'..name..'.png'},
  20. inventory_image = 'decals_'..name..'.png',
  21. wield_image = 'decals_'..name..'.png',
  22. paramtype = 'light',
  23. paramtype2 = 'colorfacedir',
  24. palette = 'decals_color_palette.png',
  25. sunlight_propagates = true,
  26. selection_box = {
  27. type = 'fixed',
  28. fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
  29. },
  30. collision_box = {
  31. type = 'fixed',
  32. fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
  33. },
  34. groups = {breakable=1},
  35. on_place = minetest.rotate_and_place,
  36. on_rightclick = decals.on_rightclick,
  37. on_punch = decals.on_punch,
  38. })
  39. end
  40. dofile(minetest.get_modpath('decals')..'/alphanumeric.lua')
  41. dofile(minetest.get_modpath('decals')..'/shapes.lua')