schematic.lua 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ---@meta
  2. ---Schematics
  3. -------------
  4. -- A schematic specifier identifies a schematic by either a filename to a
  5. -- Minetest Schematic file (`.mts`) or through raw data supplied through Lua,
  6. -- in the form of a table.
  7. ---@class mt.SchematicSpecTable
  8. -- 3D vector containing the dimensions of the provided schematic. (required field)
  9. ---@field size mt.Vector
  10. -- A flat table of MapNode tables making up the schematic,
  11. -- in the order of `[z [y [x]]]`. (required field)
  12. ---@field data mt.MapNode[]
  13. -- A table of {ypos, prob} slice tables. A slice table
  14. -- sets the probability of a particular horizontal slice of the schematic being
  15. -- placed. (optional field)
  16. ---@field yslice_prob {ypos:number, prob:number}[]?
  17. ---@alias mt.SchematicSpec mt.SchematicSpecTable|string
  18. ---@alias mt.SchematicAttr
  19. ---|"place_center_x" Placement of this decoration is centered along the X axis.
  20. ---|"place_center_y" Placement of this decoration is centered along the Y axis.
  21. ---|"place_center_z" Placement of this decoration is centered along the Z axis.
  22. ---|"force_placement" Schematic nodes other than "ignore" will replace existing nodes.
  23. -- Used in `minetest.create_schematic`.
  24. --
  25. -- - If there are two or more entries with the same `pos` value, the last entry
  26. -- is used.
  27. -- - If `pos` is not inside the box formed by `p1` and `p2`, it is ignored.
  28. -- - If `probability_list` equals `nil`, no probabilities are applied.
  29. ---@class mt.SchematicProbability
  30. ---@field pos mt.Vector Absolute coordinates of the node being modified.
  31. -- From `0` to `255` that encodes probability and per-node force-place.
  32. -- Probability has levels 0-127, then 128 may be added
  33. -- to encode per-node force-place. For probability stated as 0-255,
  34. -- divide by 2 and round down to get values 0-127, then add 128 to apply
  35. -- per-node force-place.
  36. ---@field prob integer
  37. -- Used in `minetest.create_schematic`.
  38. --
  39. -- - If slice probability list equals `nil`, no slice probabilities are applied.
  40. ---@class mt.SchematicSliceProbability
  41. -- Indicates the y position of the slice with a probability applied,
  42. -- the lowest slice being `ypos = 0`.
  43. ---@field ypos number
  44. -- From `0` to `255` that encodes probability and per-node force-place.
  45. -- Probability has levels 0-127, then 128 may be added
  46. -- to encode per-node force-place. For probability stated as 0-255,
  47. -- divide by 2 and round down to get values 0-127, then add 128 to apply
  48. -- per-node force-place.
  49. ---@field prob integer
  50. ---@alias mt.SchematicFormat
  51. ---|"mts" A string containing the binary MTS data used in the MTS file format.
  52. ---|"lua" A string containing Lua code representing the schematic in table format.
  53. -- Used in `minetest.serialize_schematic`.
  54. ---@class mt.SchematicSerializeOptions
  55. -- If `lua_use_comments` is true and `format` is "lua", the Lua code
  56. -- generated will have (X, Z) position comments for every X row generated in
  57. -- the schematic data for easier reading.
  58. ---@field lua_use_comments boolean
  59. -- If `lua_num_indent_spaces` is a nonzero number and `format` is "lua", the
  60. -- Lua code generated will use that number of spaces as indentation instead
  61. -- of a tab character.
  62. ---@field lua_num_indent_spaces number
  63. -- Used in `minetest.read_schematic`.
  64. ---@class mt.SchematicReadOptions
  65. -- - `none`: no `write_yslice_prob` table is inserted,
  66. -- - `low`: only probabilities that are not 254 or 255 are written in the
  67. -- `write_ylisce_prob` table,
  68. -- - `all`: write all probabilities to the `write_yslice_prob` table.
  69. -- - The default for this option is `all`.
  70. -- - Any invalid value will be interpreted as `all`.
  71. ---@field write_yslice_prob "none"|"low"|"all"