crafts.lua 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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)", image="mobs_meat.png", food=6},
  16. -- Mutton.
  17. {name="mobs:meat_raw_mutton", desc="Raw Mutton", image="mobs_mutton_raw.png", food=4, cooked="mobs:meat_mutton", is_raw=true},
  18. {name="mobs:meat_mutton", desc="Cooked Mutton", image="mobs_mutton.png", food=10},
  19. -- Pork.
  20. {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},
  21. {name="mobs:meat_pork", desc="Cooked Pork (Yuck)", image="mobs_pork.png", food=7, is_gross=true},
  22. -- White Wolf.
  23. {name="nssm:white_wolf_leg", desc="White Wolf Leg", image="werewolf_leg.png", food=3, cooked="nssm:roasted_white_wolf_leg", is_raw=true},
  24. {name="nssm:roasted_white_wolf_leg", desc="Roasted White Wolf Leg", image="roasted_werewolf_leg.png", food=6},
  25. }
  26. for k, v in ipairs(meat_types) do
  27. local eat_meat = minetest.item_eat(v.food)
  28. local do_eat_meat = eat_meat
  29. if v.is_raw or v.is_gross then
  30. do_eat_meat = function(itemstack, user, pointed_thing)
  31. -- Damage player only if meat was raw.
  32. if v.is_raw then
  33. -- Do not kill player.
  34. if user:get_hp() > 1 then
  35. user:set_hp(user:get_hp() - 1)
  36. end
  37. end
  38. -- Send message if meat was raw or gross.
  39. minetest.chat_send_player(user:get_player_name(), "# Server: You eat " .. v.desc .. "? Eww, gross!")
  40. return eat_meat(itemstack, user, pointed_thing)
  41. end
  42. end
  43. local groups = {food_meat = 1, flammable = 3}
  44. if v.is_raw then
  45. groups.food_meat_raw = 1
  46. end
  47. if v.is_gross then
  48. groups.food_meat_gross = 1
  49. end
  50. minetest.register_craftitem(":" .. v.name, {
  51. description = v.desc,
  52. inventory_image = v.image,
  53. groups = groups,
  54. on_use = do_eat_meat,
  55. })
  56. if v.cooked then
  57. minetest.register_craft({
  58. type = "cooking",
  59. output = v.cooked,
  60. recipe = v.name,
  61. cooktime = 5,
  62. })
  63. end
  64. end
  65. minetest.register_craftitem("mobs:leather", {
  66. description = "Leather",
  67. inventory_image = "mobs_leather.png",
  68. groups = {flammable = 2, leather = 1},
  69. })
  70. minetest.register_tool("mobs:net", {
  71. description = "Capturing Net",
  72. inventory_image = "mobs_net.png",
  73. groups = {not_repaired_by_anvil = 1, flammable = 2},
  74. })
  75. minetest.register_craft({
  76. output = "mobs:net",
  77. recipe = {
  78. {"group:stick", "", "group:stick" },
  79. {"group:stick", "", "group:stick" },
  80. {"farming:string", "group:stick", "farming:string" },
  81. }
  82. })
  83. -- items that can be used as fuel
  84. minetest.register_craft({
  85. type = "fuel",
  86. recipe = "mobs:net",
  87. burntime = 8,
  88. })
  89. minetest.register_craft({
  90. type = "fuel",
  91. recipe = "mobs:leather",
  92. burntime = 4,
  93. })
  94. minetest.register_craft({
  95. type = "fuel",
  96. recipe = "mobs:nametag",
  97. burntime = 3,
  98. })
  99. --------------------------------------------------------------------------------
  100. minetest.register_craftitem("mobs:leather_padding", {
  101. description = "Sewn Leather Padding",
  102. inventory_image = "mobs_leather_padding.png",
  103. groups = {flammable = 2, leather_padding = 1},
  104. })
  105. minetest.register_craft({
  106. output = "mobs:leather_padding",
  107. type = "shapeless",
  108. recipe = {"group:leather", "farming:string", "farming:cotton"},
  109. })
  110. minetest.register_craft({
  111. type = "fuel",
  112. recipe = "mobs:leather_padding",
  113. burntime = 6,
  114. })
  115. --------------------------------------------------------------------------------
  116. minetest.register_craftitem("mobs:flame_bolt", {
  117. description = "Flame Bolt",
  118. inventory_image = "mobs_flame_bolt.png",
  119. groups = {flammable = 3},
  120. light_source = 14,
  121. })
  122. minetest.register_craftitem("mobs:flame_staff", {
  123. description = "Flame Staff",
  124. inventory_image = "mobs_flame_staff.png",
  125. groups = {flammable = 1},
  126. stack_max = 1, -- Stores metadata.
  127. light_source = 14,
  128. on_use = function(...)
  129. return obsidian_gateway.on_flamestaff_use(...)
  130. end,
  131. })
  132. minetest.register_craft({
  133. output = "mobs:flame_staff",
  134. recipe = {
  135. {"", "mobs:flame_bolt", ""},
  136. {"", "mobs:flame_bolt", ""},
  137. {"farming:cloth", "mobs:flame_bolt", "farming:cloth"},
  138. },
  139. })