sounds.lua 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ---@meta
  2. ---Sounds
  3. ---------
  4. -- These sound files are played back by the engine if provided.
  5. ---@alias mt.SpecialSoundFile
  6. -- Played when the local player takes damage (gain = 0.5).
  7. ---|"player_damage"
  8. -- Played when the local player takes damage by falling (gain = 0.5).
  9. ---|"player_falling_damage"
  10. -- Played when the local player jumps.
  11. ---|"player_jump"
  12. -- Default node digging sound.
  13. ---|"default_dig_<groupname>"
  14. ---Specifies a sound name, gain (=volume) and pitch.
  15. ---This is either a string or a table.
  16. ---
  17. ---In string form, you just specify the sound name or
  18. ---the empty string for no sound.
  19. ---
  20. ---Table form has the following fields:
  21. ---
  22. ---* `name`: Sound name
  23. ---* `gain`: Volume (`1.0` = 100%)
  24. ---* `pitch`: Pitch (`1.0` = 100%)
  25. ---
  26. ---`gain` and `pitch` are optional and default to `1.0`.
  27. ---
  28. ---Examples:
  29. ---
  30. ---* `""`: No sound
  31. ---* `{}`: No sound
  32. ---* `"default_place_node"`: Play e.g. `default_place_node.ogg`
  33. ---* `{name = "default_place_node"}`: Same as above
  34. ---* `{name = "default_place_node", gain = 0.5}`: 50% volume
  35. ---* `{name = "default_place_node", gain = 0.9, pitch = 1.1}`: 90% volume, 110% pitch
  36. ---
  37. ---@class mt.SimpleSoundSpecTable
  38. ---@field name string|mt.SpecialSoundFile
  39. ---@field gain number
  40. ---@field pitch number
  41. local sound_spec = {}
  42. ---@alias mt.SimpleSoundSpec mt.SimpleSoundSpecTable|string|mt.SpecialSoundFile
  43. ---Looped sounds must either be connected to an object or played locationless to
  44. ---one player using `to_player = name`.
  45. ---
  46. ---A positional sound will only be heard by players that are within
  47. ---`max_hear_distance` of the sound position, at the start of the sound.
  48. ---
  49. ---`exclude_player = name` can be applied to locationless, positional and object-
  50. ---bound sounds to exclude a single player from hearing them.
  51. ---@class mt.SoundParameters
  52. ---@field gain number Default: `1.0`.
  53. ---@field pitch number Default: `1.0`.
  54. ---@field fade number Default: `0.0`. Change to a value > 0 to fade the sound in.
  55. ---@field to_player string Name.
  56. ---@field exclude_player string Name.
  57. ---@field loop boolean
  58. ---@field pos mt.Vector
  59. ---@field max_hear_distance number Default: `32`.
  60. ---@field object mt.ObjectRef
  61. local sound_parameters = {}