fishing.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. local S = ethereal.intllib
  2. -- Raw Fish (Thanks to Altairas for her Fish image on DeviantArt)
  3. minetest.register_craftitem("ethereal:fish_raw", {
  4. description = S("Raw Fish"),
  5. inventory_image = "fish_raw.png",
  6. wield_image = "fish_raw.png",
  7. groups = {food_fish_raw = 1, flammable = 3},
  8. on_use = minetest.item_eat(2),
  9. })
  10. -- Cooked Fish
  11. minetest.register_craftitem("ethereal:fish_cooked", {
  12. description = S("Cooked Fish"),
  13. inventory_image = "fish_cooked.png",
  14. wield_image = "fish_cooked.png",
  15. groups = {food_fish = 1, flammable = 3},
  16. on_use = minetest.item_eat(5),
  17. })
  18. minetest.register_craft({
  19. type = "cooking",
  20. output = "ethereal:fish_cooked",
  21. recipe = "ethereal:fish_raw",
  22. cooktime = 2,
  23. })
  24. -- Sashimi (Thanks to Natalia Grosner for letting me use the sashimi image)
  25. minetest.register_craftitem("ethereal:sashimi", {
  26. description = S("Sashimi"),
  27. inventory_image = "sashimi.png",
  28. wield_image = "sashimi.png",
  29. on_use = minetest.item_eat(4),
  30. })
  31. minetest.register_craft({
  32. output = "ethereal:sashimi 2",
  33. recipe = {
  34. {"group:food_seaweed", "group:food_fish_raw", "group:food_seaweed"},
  35. }
  36. })
  37. -- Worm
  38. minetest.register_craftitem("ethereal:worm", {
  39. description = S("Worm"),
  40. inventory_image = "worm.png",
  41. wield_image = "worm.png",
  42. })
  43. -- Used when right-clicking with fishing rod to check for worm and bait rod
  44. local rod_use = function(itemstack, placer, pointed_thing)
  45. local inv = placer:get_inventory()
  46. if inv:contains_item("main", "ethereal:worm") then
  47. inv:remove_item("main", "ethereal:worm")
  48. return ItemStack("ethereal:fishing_rod_baited")
  49. end
  50. end
  51. -- Fishing Rod
  52. minetest.register_craftitem("ethereal:fishing_rod", {
  53. description = S("Fishing Rod (Right-Click with rod to bait with worm from inventory)"),
  54. inventory_image = "fishing_rod.png",
  55. wield_image = "fishing_rod.png",
  56. stack_max = 1,
  57. on_place = rod_use,
  58. on_secondary_use = rod_use
  59. })
  60. minetest.register_craft({
  61. output = "ethereal:fishing_rod",
  62. recipe = {
  63. {"","","group:stick"},
  64. {"", "group:stick", "farming:string"},
  65. {"group:stick", "", "farming:string"},
  66. }
  67. })
  68. -- Sift through 2 Dirt Blocks to find Worm
  69. minetest.register_craft({
  70. output = "ethereal:worm",
  71. recipe = {
  72. {"default:dirt","default:dirt"},
  73. }
  74. })
  75. -- default ethereal fish
  76. ethereal.fish = {
  77. {"ethereal:fish_raw"},
  78. }
  79. -- xanadu server additional fish
  80. if minetest.get_modpath("xanadu") then
  81. ethereal.fish[2] = {"mobs:clownfish_raw"}
  82. ethereal.fish[3] = {"mobs:bluefish_raw"}
  83. end
  84. -- Fishing Rod (Baited)
  85. minetest.register_craftitem("ethereal:fishing_rod_baited", {
  86. description = S("Baited Fishing Rod"),
  87. inventory_image = "fishing_rod_baited.png",
  88. wield_image = "fishing_rod_wield.png",
  89. stack_max = 1,
  90. liquids_pointable = true,
  91. on_use = function (itemstack, user, pointed_thing)
  92. if pointed_thing.type ~= "node" then
  93. return
  94. end
  95. local pos = pointed_thing.under
  96. local node = minetest.get_node(pos).name
  97. if (node == "default:water_source"
  98. or node == "default:river_water_source")
  99. and math.random(1, 100) < 5 then
  100. local type = ethereal.fish[math.random(1, #ethereal.fish)][1]
  101. local inv = user:get_inventory()
  102. if inv:room_for_item("main", {name = type}) then
  103. inv:add_item("main", {name = type})
  104. minetest.sound_play("default_water_footstep", {pos = pos})
  105. pos.y = pos.y + 0.5
  106. minetest.add_particlespawner({
  107. amount = 5,
  108. time = .3,
  109. minpos = pos,
  110. maxpos = pos,
  111. minvel = {x = 2, y = .5, z = 2},
  112. maxvel = {x = 2, y = .5, z = 2},
  113. minacc = {x = 1, y = .1, z = 1},
  114. maxacc = {x = 1, y = .1, z = 1},
  115. minexptime = .3,
  116. maxexptime = .5,
  117. minsize = .5,
  118. maxsize = 1,
  119. collisiondetection = false,
  120. vertical = false,
  121. texture = "bubble.png",
  122. playername = "singleplayer"
  123. })
  124. return ItemStack("ethereal:fishing_rod")
  125. else
  126. minetest.chat_send_player(user:get_player_name(),
  127. S("Inventory full, Fish Got Away!"))
  128. end
  129. end
  130. end,
  131. })
  132. minetest.register_craft({
  133. type = "shapeless",
  134. output = "ethereal:fishing_rod_baited",
  135. recipe = {"ethereal:fishing_rod", "ethereal:worm"},
  136. })