init.lua 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. redshroom = redshroom or {}
  2. redshroom.modpath = minetest.get_modpath("redshroom")
  3. -- Localize for performance.
  4. local math_random = math.random
  5. local SHROOM_SCHEMATICS = {
  6. "redshroom_shroom1.mts",
  7. "redshroom_shroom2.mts",
  8. "redshroom_shroom3.mts",
  9. "redshroom_shroom4.mts",
  10. "redshroom_shroom5.mts",
  11. "redshroom_shroom6.mts",
  12. }
  13. minetest.register_node("redshroom:head", {
  14. description = "Red Shroom Head",
  15. tiles = {"redshroom_headtop.png", "redshroom_headtop.png", "redshroom_headside1.png^redshroom_headside2.png"},
  16. paramtype2 = "facedir",
  17. groups = utility.dig_groups("shroom", {flammable=2}),
  18. sounds = default.node_sound_wood_defaults(),
  19. on_place = minetest.rotate_node
  20. })
  21. minetest.register_node("redshroom:head2", {
  22. description = "Red Shroom Head",
  23. tiles = {"redshroom_headtop.png", "redshroom_headtop.png", "redshroom_headside1.png"},
  24. paramtype2 = "facedir",
  25. groups = utility.dig_groups("shroom", {flammable=2}),
  26. sounds = default.node_sound_wood_defaults(),
  27. on_place = minetest.rotate_node
  28. })
  29. minetest.register_node("redshroom:stem", {
  30. description = "Red Shroom Stem",
  31. tiles = {"redshroom_stemtop.png", "redshroom_stemtop.png", "redshroom_stemside.png"},
  32. paramtype2 = "facedir",
  33. groups = utility.dig_groups("shroom", {flammable=2}),
  34. sounds = default.node_sound_wood_defaults(),
  35. on_place = minetest.rotate_node
  36. })
  37. minetest.register_craft({
  38. type = "shapeless",
  39. output = "default:stick 16",
  40. recipe = {"redshroom:stem"},
  41. })
  42. minetest.register_node("redshroom:stemwhite", {
  43. description = "White Shroom Stem",
  44. tiles = {"redshroom_stemtop_white.png", "redshroom_stemtop_white.png", "redshroom_stemside_white.png"},
  45. paramtype2 = "facedir",
  46. groups = utility.dig_groups("shroom", {flammable=2}),
  47. sounds = default.node_sound_wood_defaults(),
  48. on_place = minetest.rotate_node
  49. })
  50. minetest.register_craft({
  51. type = "shapeless",
  52. output = "default:stick 16",
  53. recipe = {"redshroom:stemwhite"},
  54. })
  55. minetest.register_node("redshroom:gills", {
  56. description = "Shroom Gills",
  57. drawtype = "plantlike",
  58. tiles = {"redshroom_gills.png"},
  59. paramtype = "light",
  60. groups = utility.dig_groups("plant", {flammable=2, hanging_node=1}),
  61. drop = "", -- Gills are destroyed when dug.
  62. shears_drop = true, -- obtainable via shears
  63. walkable = false,
  64. buildable_to = true,
  65. sounds = default.node_sound_leaves_defaults(),
  66. selection_box = {
  67. type = "fixed",
  68. fixed = {-0.5, 5/16, -0.5, 0.5, 0.5, 0.5},
  69. },
  70. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  71. })
  72. redshroom.create_shroom_on_vmanip = function(vm, pos)
  73. local schempath = redshroom.modpath .. "/schematics/"
  74. local path = schempath .. SHROOM_SCHEMATICS[math_random(#SHROOM_SCHEMATICS)]
  75. minetest.place_schematic_on_vmanip(vm, vector.add(pos, {x=-2, y=0, z=-2}), path, "random", nil, false)
  76. end
  77. redshroom.create_shroom = function(pos)
  78. local schempath = redshroom.modpath .. "/schematics/"
  79. local path = schempath .. SHROOM_SCHEMATICS[math_random(#SHROOM_SCHEMATICS)]
  80. minetest.place_schematic(vector.add(pos, {x=-2, y=0, z=-2}), path, "random", nil, false)
  81. end