decor.lua 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. ---@meta
  2. ---Decoration definition
  3. ------------------------
  4. ---@alias mt.DecorType
  5. -- Creates a 1 times `H` times 1 column of a specified node (or a random node from
  6. -- a list, if a decoration list is specified). Can specify a certain node it must
  7. -- spawn next to, such as water or lava, for example. Can also generate a
  8. -- decoration of random height between a specified lower and upper bound.
  9. -- This type of decoration is intended for placement of grass, flowers, cacti,
  10. -- papyri, waterlilies and so on.
  11. ---|"simple"
  12. -- Copies a box of `MapNodes` from a specified schematic file (or raw description).
  13. -- Can specify a probability of a node randomly appearing when placed.
  14. -- This decoration type is intended to be used for multi-node sized discrete
  15. -- structures, such as trees, cave spikes, rocks, and so on.
  16. ---|"schematic"
  17. -- Used by `minetest.register_decoration`.
  18. ---@alias mt.DecorDef mt.DecorDefSimple|mt.DecorDefSchematic
  19. ---@class mt.DecorDefCommon
  20. ---@field deco_type mt.DecorType
  21. -- Node (or list of nodes) that the decoration can be placed on.
  22. ---@field place_on string|string[]
  23. -- Size of the square divisions of the mapchunk being generated.
  24. -- Determines the resolution of noise variation if used.
  25. -- If the chunk size is not evenly divisible by sidelen, sidelen is made
  26. -- equal to the chunk size.
  27. ---@field sidelen number
  28. -- The value determines `decorations per surface node`.
  29. -- Used only if noise_params is not specified.
  30. -- If >= 10.0 complete coverage is enabled and decoration placement uses
  31. -- a different and much faster method.
  32. ---@field fill_ratio number
  33. -- NoiseParams structure describing the perlin noise used for decoration
  34. -- distribution.
  35. -- A noise value is calculated for each square division and determines
  36. -- `decorations per surface node` within each division.
  37. -- If the noise value >= 10.0 complete coverage is enabled and
  38. -- decoration placement uses a different and much faster method.
  39. ---@field noise_params mt.NoiseParams
  40. -- List of biomes in which this decoration occurs. Occurs in all biomes
  41. -- if this is omitted, and ignored if the Mapgen being used does not
  42. -- support biomes.
  43. -- Can be a list of (or a single) biome names, IDs, or definitions.
  44. ---@field biomes string[]
  45. -- Lower limits for decoration.
  46. -- These parameters refer to the Y co-ordinate of the `place_on` node.
  47. ---@field y_min number
  48. -- Upper limits for decoration.
  49. -- These parameters refer to the Y co-ordinate of the `place_on` node.
  50. ---@field y_max number
  51. -- Node (or list of nodes) that the decoration only spawns next to.
  52. -- Checks the 8 neighbor nodes on the same Y, and also the ones
  53. -- at Y+1, excluding both center nodes.
  54. ---@field spawn_by string|string[]
  55. -- Number of spawn_by nodes that must be surrounding the decoration
  56. -- position to occur.
  57. -- If absent or -1, decorations occur next to any nodes.
  58. ---@field num_spawn_by number
  59. -- * Comma separated values.
  60. -- * Flags for all decoration types.
  61. -- * "liquid_surface": Instead of placement on the highest solid surface
  62. -- in a mapchunk column, placement is on the highest liquid surface.
  63. -- Placement is disabled if solid nodes are found above the liquid
  64. -- surface.
  65. -- * "force_placement": Nodes other than "air" and "ignore" are replaced
  66. -- by the decoration.
  67. -- * "all_floors", "all_ceilings": Instead of placement on the highest
  68. -- surface in a mapchunk the decoration is placed on all floor and/or
  69. -- ceiling surfaces, for example in caves and dungeons.
  70. -- Ceiling decorations act as an inversion of floor decorations so the
  71. -- effect of `place_offset_y` is inverted.
  72. -- Y-slice probabilities do not function correctly for ceiling
  73. -- schematic decorations as the behavior is unchanged.
  74. -- If a single decoration registration has both flags the floor and
  75. -- ceiling decorations will be aligned vertically.
  76. ---@field flags string
  77. ---@class mt.DecorDefSimple:mt.DecorDefCommon
  78. -- The node name used as the decoration.
  79. -- If instead a list of strings, a randomly selected node from the list
  80. -- is placed as the decoration.
  81. ---@field decoration string|string[]
  82. -- Decoration height in nodes.
  83. -- If height_max is not 0, this is the lower limit of a randomly
  84. -- selected height.
  85. ---@field height number
  86. -- Upper limit of the randomly selected height.
  87. -- If absent, the parameter `height` is used as a constant.
  88. ---@field height_max number
  89. -- Param2 value of decoration nodes.
  90. -- If param2_max is not 0, this is the lower limit of a randomly
  91. -- selected param2.
  92. ---@field param2 number
  93. -- Upper limit of the randomly selected param2.
  94. -- If absent, the parameter `param2` is used as a constant.
  95. ---@field param2_max number
  96. -- Y offset of the decoration base node relative to the standard base
  97. -- node position.
  98. -- Can be positive or negative. Default is 0.
  99. -- Effect is inverted for "all_ceilings" decorations.
  100. -- Ignored by `y_min`, `y_max` and `spawn_by` checks, which always refer
  101. -- to the `place_on` node.
  102. ---@field place_offset_y number
  103. ---@class mt.DecorDefSchematic:mt.DecorDefCommon
  104. -- If schematic is a string, it is the filepath relative to the current
  105. -- working directory of the specified Minetest schematic file.
  106. -- Could also be the ID of a previously registered schematic.
  107. ---@field schematic string|mt.SchematicSpec
  108. ---@field replacements table
  109. -- Flags for schematic decorations.
  110. ---@field flags string
  111. ---@field rotation "0"|"90"|"180"|"270"|"random"
  112. -- If the flag `place_center_y` is set this parameter is ignored.
  113. -- Y offset of the schematic base node layer relative to the `place_on` node.
  114. -- Can be positive or negative. Default is 0.
  115. -- Effect is inverted for "all_ceilings" decorations.
  116. -- Ignored by `y_min`, `y_max` and `spawn_by` checks, which always refer
  117. -- to the `place_on` node.
  118. ---@field place_offset_y number