Skip to content

Commit f4f7c7a

Browse files
Wuzzy2paramat
authored andcommittedJan 8, 2020
Improve Lua API documentation on sounds (#9265)
1 parent 7c0e0c3 commit f4f7c7a

File tree

2 files changed

+60
-11
lines changed

2 files changed

+60
-11
lines changed
 

‎doc/lua_api.txt

+52-11
Original file line numberDiff line numberDiff line change
@@ -849,24 +849,39 @@ A positional sound will only be heard by players that are within
849849
`SimpleSoundSpec`
850850
-----------------
851851

852-
* e.g. `""`
853-
* e.g. `"default_place_node"`
854-
* e.g. `{}`
855-
* e.g. `{name = "default_place_node"}`
856-
* e.g. `{name = "default_place_node", gain = 1.0}`
857-
* e.g. `{name = "default_place_node", gain = 1.0, pitch = 1.0}`
852+
Specifies a sound name, gain (=volume) and pitch.
853+
This is either a string or a table.
858854

855+
In string form, you just specify the sound name or
856+
the empty string for no sound.
857+
858+
Table form has the following fields:
859+
860+
* `name`: Sound name
861+
* `gain`: Volume (`1.0` = 100%)
862+
* `pitch`: Pitch (`1.0` = 100%)
863+
864+
`gain` and `pitch` are optional and default to `1.0`.
865+
866+
Examples:
867+
868+
* `""`: No sound
869+
* `{}`: No sound
870+
* `"default_place_node"`: Play e.g. `default_place_node.ogg`
871+
* `{name = "default_place_node"}`: Same as above
872+
* `{name = "default_place_node", gain = 0.5}`: 50% volume
873+
* `{name = "default_place_node", gain = 0.9, pitch = 1.1}`: 90% volume, 110% pitch
859874

860875
Special sound files
861876
-------------------
862877

863878
These sound files are played back by the engine if provided.
864879

865-
* `main_menu`: Looped sound in the main menu (gain = 1.0)
866880
* `player_damage`: Played when the local player takes damage (gain = 0.5)
867881
* `player_falling_damage`: Played when the local player takes
868882
damage by falling (gain = 0.5)
869-
883+
* `default_dig_<groupname>`: Default node digging sound
884+
(see node sound definition for details)
870885

871886
Registered definitions
872887
======================
@@ -6468,9 +6483,14 @@ Used by `minetest.register_node`, `minetest.register_craftitem`, and
64686483
-- upon digging. Server will always update actual result shortly.
64696484

64706485
sound = {
6471-
breaks = "default_tool_break", -- tools only
6472-
place = <SimpleSoundSpec>,
6486+
-- Definition of items sounds to be played at various events.
6487+
-- All fields in this table are optional.
6488+
6489+
breaks = <SimpleSoundSpec>,
6490+
-- When tool breaks due to wear. Ignored for non-tools
6491+
64736492
eat = <SimpleSoundSpec>,
6493+
-- When item is eaten with `minetest.do_item_eat`
64746494
},
64756495

64766496
on_place = function(itemstack, placer, pointed_thing),
@@ -6679,12 +6699,33 @@ Used by `minetest.register_node`.
66796699
-- liquid, flowingliquid drawtypes can only wave like liquids.
66806700

66816701
sounds = {
6702+
-- Definition of node sounds to be played at various events.
6703+
-- All fields in this table are optional.
6704+
66826705
footstep = <SimpleSoundSpec>,
6683-
dig = <SimpleSoundSpec>, -- "__group" = group-based sound (default)
6706+
-- If walkable, played when object walks on it. If node is
6707+
-- climbable or a liquid, played when object moves through it
6708+
6709+
dig = <SimpleSoundSpec> or "__group",
6710+
-- While digging node.
6711+
-- If `"__group"`, then the sound will be
6712+
-- `default_dig_<groupname>`, where `<groupname>` is the
6713+
-- name of the tool's digging group with the fastest digging time.
6714+
-- In case of a tie, one of the sounds will be played (but we
6715+
-- cannot predict which one)
6716+
-- Default value: `"__group"`
6717+
66846718
dug = <SimpleSoundSpec>,
6719+
-- Node was dug
6720+
66856721
place = <SimpleSoundSpec>,
6722+
-- Node was placed. Also played after falling
6723+
66866724
place_failed = <SimpleSoundSpec>,
6725+
-- When node placement failed
6726+
66876727
fall = <SimpleSoundSpec>,
6728+
-- When node starts to fall
66886729
},
66896730

66906731
drop = "",

‎doc/menu_lua_api.txt

+8
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,11 @@ Limitations of Async operations
244244
-Limited set of available functions
245245
e.g. No access to functions modifying menu like core.start,core.close,
246246
core.show_path_select_dialog
247+
248+
Background music
249+
----------------
250+
The main menu supports background music.
251+
It looks for a `main_menu` sound in `$USER_PATH/sounds`. The same naming
252+
conventions as for normal sounds apply.
253+
This means the player can add a custom sound.
254+
It will be played in the main menu (gain = 1.0), looped.

0 commit comments

Comments
 (0)
Please sign in to comment.