init.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. minetest.register_craftitem("orb_of_healing:orb_of_healing", {
  2. description = "Orb of Healing\nMana: 10",
  3. inventory_image = "orb_of_healing_orb.png",
  4. on_use = function(itemstack, player, pointed_thing)
  5. local name = player:get_player_name()
  6. local players_mana = hbmana.get(name)
  7. if players_mana >= 10 then
  8. hbmana.set(name, players_mana - 10)
  9. local pos = {}
  10. if pointed_thing.type == "object" and pointed_thing.ref:get_luaentity().name ~= "__builtin:item" then
  11. local pointed_entity = pointed_thing.ref:get_luaentity()
  12. pos = pointed_thing.ref:get_pos()
  13. if pointed_thing.ref:is_player() then
  14. pointed_thing.ref:set_hp(pointed_thing.ref:get_hp() + 5)
  15. elseif pointed_entity.name ~= "__builtin:item" then
  16. pointed_thing.ref:punch(player, 1.0, {
  17. full_punch_interval = 1.0,
  18. damage_groups = {fleshy = -3},
  19. }, nil)
  20. end
  21. else
  22. pos = player:get_pos()
  23. player:set_hp(player:get_hp() + 5)
  24. end
  25. minetest.add_particlespawner({
  26. amount = 150,
  27. time = 0.5,
  28. minpos = {
  29. x = pos.x - 1,
  30. y = pos.y,
  31. z = pos.z - 1
  32. },
  33. maxpos = {
  34. x = pos.x + 1,
  35. y = pos.y + 2,
  36. z = pos.z + 1
  37. },
  38. minexptime = 0.1,
  39. maxexptime = 0.2,
  40. minsize = 1,
  41. maxsize = 2,
  42. collisiondetection = false,
  43. vertical = false,
  44. texture = "orb_of_healing_particle.png",
  45. })
  46. end
  47. end
  48. })
  49. minetest.register_craft({
  50. output = "orb_of_healing:orb_of_healing",
  51. recipe = {
  52. {"", "default:glass", ""},
  53. {"default:glass", "gems_amber:amber", "default:glass"},
  54. {"", "default:glass", ""},
  55. }
  56. })