init.lua 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. local S = minetest.get_translator("defense_healing")
  2. local function heal(obj, amount)
  3. obj:set_hp(obj:get_hp() + amount)
  4. minetest.sound_play("defense_healing_drink",
  5. {
  6. object = obj,
  7. max_hear_distance = 4,
  8. })
  9. end
  10. local juice_helpstr = minetest.colorize(
  11. "#90FFFF",
  12. S("Tastes revolting. Best used to heal others"))
  13. minetest.register_craftitem("defense_healing:juice",
  14. {
  15. description = S("Chugging Juice Jug\n@1", juice_helpstr),
  16. inventory_image = "defense_healing_juice.png",
  17. stack_max = 1,
  18. on_use = function(itemstack, user)
  19. if user
  20. then
  21. heal(user, 1)
  22. end
  23. end,
  24. on_drop = function(itemstack)
  25. return itemstack --undroppable to prevent nasty accidents
  26. end,
  27. on_place = function(itemstack, user, pointed_thing)
  28. --heal other players
  29. --ensure that pointed_thing is a player
  30. if pointed_thing.type ~= "object" or
  31. not pointed_thing.ref:is_player()
  32. then
  33. return
  34. end
  35. heal(user, 4)
  36. end,
  37. })
  38. minetest.register_alias("healing_juice", "defense_healing:juice")
  39. minetest.register_craftitem("defense_healing:stonecake",
  40. {
  41. description = S("Stone Cake"),
  42. inventory_image = "defense_healing_cake.png",
  43. stack_max = 64,
  44. on_use = minetest.item_eat(5)
  45. })
  46. minetest.register_alias("healing_cake", "defense_healing:stonecake")
  47. minetest.register_craft(
  48. {
  49. type = "cooking",
  50. output = minetest.registered_aliases["healing_cake"],
  51. recipe = minetest.registered_aliases["cobble"],
  52. cooktime = 2,
  53. })
  54. give_initial_stuff.add("healing_juice", 3)
  55. give_initial_stuff.add("healing_cake 8", 1)