crafts.lua 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. -- name tag
  2. minetest.register_craftitem("mobs:nametag", {
  3. description = "Mob Name Tag",
  4. inventory_image = "mobs_nametag.png",
  5. groups = {flammable = 2},
  6. })
  7. minetest.register_craft({
  8. type = "shapeless",
  9. output = "mobs:nametag",
  10. recipe = {"default:paper", "dye:black", "farming:string"},
  11. })
  12. local meat_types = {
  13. -- Regular meat, creature type not defined.
  14. {name="mobs:meat_raw", desc="Raw Meat (Unidentified)", image="mobs_meat_raw.png", food=3, cooked="mobs:meat", is_raw=true},
  15. {name="mobs:meat", desc="Cooked Meat (Unidentified)\n\nEat to improve resistance to certain kinds of damage, for a time.", image="mobs_meat.png", food=6},
  16. -- Naraxen meat.
  17. {name="mobs:naraxen_meat_raw", desc="Raw Naraxen Meat (Unidentified)", image="mobs_meat_raw.png", food=3, cooked="mobs:naraxen_meat", is_raw=true},
  18. {name="mobs:naraxen_meat", desc="Naraxen Meat (Unidentified)", image="mobs_meat.png", food=6},
  19. -- Mutton.
  20. {name="mobs:meat_raw_mutton", desc="Raw Mutton", image="mobs_mutton_raw.png", food=4, cooked="mobs:meat_mutton", is_raw=true},
  21. {name="mobs:meat_mutton", desc="Cooked Mutton\n\nEat to improve resistance to certain kinds of damage, for a time.", image="mobs_mutton.png", food=10},
  22. -- Pork.
  23. {name="mobs:meat_raw_pork", desc="Raw Pork (Yuck)", image="mobs_pork_raw.png", food=4, cooked="mobs:meat_pork", is_raw=true, is_gross=true},
  24. {name="mobs:meat_pork", desc="Cooked Pork (Yuck)\n\nEat to improve resistance to certain kinds of damage, for a time.", image="mobs_pork.png", food=7, is_gross=true},
  25. -- White Wolf.
  26. {name="nssm:white_wolf_leg", desc="White Wolf Leg", image="werewolf_leg.png", food=3, cooked="nssm:roasted_white_wolf_leg", is_raw=true},
  27. {name="nssm:roasted_white_wolf_leg", desc="Roasted White Wolf Leg\n\nEat to improve resistance to certain kinds of damage, for a time.", image="roasted_werewolf_leg.png", food=6},
  28. }
  29. for k, v in ipairs(meat_types) do
  30. local eat_meat = minetest.item_eat(v.food)
  31. local do_eat_meat = function(itemstack, user, pointed_thing)
  32. -- Damage player only if meat was raw.
  33. if v.is_raw then
  34. -- Do not kill player.
  35. if user:get_hp() > 1*500 then
  36. -- Light poisoning that lasts awhile.
  37. hb4.delayed_harm({
  38. name = user:get_player_name(),
  39. step = 15,
  40. min = 50,
  41. max = 100,
  42. hp_min = 1,
  43. poison = true,
  44. })
  45. end
  46. end
  47. if v.name == "mobs:meat_mutton" then
  48. hunger.apply_damage_resistance(user:get_player_name(), "mutton", {resistance=0.8, time=30})
  49. elseif v.name == "nssm:roasted_white_wolf_leg" then
  50. hunger.apply_damage_resistance(user:get_player_name(), "wolf", {resistance=0.3, time=360})
  51. elseif v.name == "mobs:meat_pork" then
  52. hunger.apply_damage_resistance(user:get_player_name(), "pork", {resistance=0.7, time=10})
  53. elseif v.name == "mobs:meat" then
  54. hunger.apply_damage_resistance(user:get_player_name(), "pork", {resistance=0.5, time=7})
  55. end
  56. -- Send message if meat was raw or gross.
  57. if v.is_gross or v.is_raw then
  58. minetest.chat_send_player(user:get_player_name(),
  59. "# Server: You eat " .. utility.get_short_desc(v.desc) .. "? Eww, gross!")
  60. end
  61. return eat_meat(itemstack, user, pointed_thing)
  62. end
  63. local groups = {food_meat = 1, flammable = 3}
  64. if v.is_raw then
  65. groups.food_meat_raw = 1
  66. end
  67. if v.is_gross then
  68. groups.food_meat_gross = 1
  69. end
  70. minetest.register_craftitem(":" .. v.name, {
  71. description = v.desc,
  72. inventory_image = v.image,
  73. groups = groups,
  74. on_use = do_eat_meat,
  75. })
  76. if v.cooked then
  77. minetest.register_craft({
  78. type = "cooking",
  79. output = v.cooked,
  80. recipe = v.name,
  81. cooktime = 5,
  82. })
  83. end
  84. end
  85. minetest.register_craftitem("mobs:leather", {
  86. description = "Leather",
  87. inventory_image = "mobs_leather.png",
  88. groups = {flammable = 2, leather = 1},
  89. })
  90. minetest.register_tool("mobs:net", {
  91. description = "Capturing Net",
  92. inventory_image = "mobs_net.png",
  93. groups = {not_repaired_by_anvil = 1, flammable = 2},
  94. })
  95. minetest.register_craft({
  96. output = "mobs:net",
  97. recipe = {
  98. {"group:stick", "", "group:stick" },
  99. {"group:stick", "", "group:stick" },
  100. {"farming:string", "group:stick", "farming:string" },
  101. }
  102. })
  103. -- items that can be used as fuel
  104. minetest.register_craft({
  105. type = "fuel",
  106. recipe = "mobs:net",
  107. burntime = 8,
  108. })
  109. minetest.register_craft({
  110. type = "fuel",
  111. recipe = "mobs:leather",
  112. burntime = 4,
  113. })
  114. minetest.register_craft({
  115. type = "fuel",
  116. recipe = "mobs:nametag",
  117. burntime = 3,
  118. })
  119. --------------------------------------------------------------------------------
  120. minetest.register_craftitem("mobs:leather_padding", {
  121. description = "Sewn Leather Padding",
  122. inventory_image = "mobs_leather_padding.png",
  123. groups = {flammable = 2, leather_padding = 1},
  124. })
  125. minetest.register_craft({
  126. output = "mobs:leather_padding",
  127. type = "shapeless",
  128. recipe = {"group:leather", "farming:string", "farming:cotton"},
  129. })
  130. minetest.register_craft({
  131. type = "fuel",
  132. recipe = "mobs:leather_padding",
  133. burntime = 6,
  134. })
  135. --------------------------------------------------------------------------------
  136. -- Stores metadata, needs wear bar.
  137. -- Note: this also makes the staff repairable by combining it with another.
  138. minetest.register_tool("mobs:flame_staff", {
  139. description = "Flame Staff",
  140. inventory_image = "mobs_flame_staff.png",
  141. wield_image = "mobs_flame_staff.png^[transformR270",
  142. groups = {flammable = 1, not_repaired_by_anvil = 1},
  143. light_source = 14,
  144. wear_represents = "teleport_uses",
  145. on_use = function(...)
  146. return obsidian_gateway.on_flamestaff_use(...)
  147. end,
  148. })
  149. minetest.register_craft({
  150. output = "mobs:flame_staff",
  151. recipe = {
  152. {"", "mobs:flame_bolt", ""},
  153. {"", "mobs:flame_bolt", ""},
  154. {"farming:cloth", "mobs:flame_bolt", "farming:cloth"},
  155. },
  156. })