Difference between revisions of "minetest.sound play"

From Minetest Developer Wiki
Jump to navigation Jump to search
 
(23 intermediate revisions by 10 users not shown)
Line 1: Line 1:
 +
{{UnofficialLua}}
 
{{DISPLAYTITLE:minetest.sound_play}}
 
{{DISPLAYTITLE:minetest.sound_play}}
== Syntax ==
+
See [https://minetest.gitlab.io/minetest/minetest-namespace-reference/#sounds minetest.sound_play] in the Lua API documentation, and [https://minetest.gitlab.io/minetest/sounds/ Sounds] for general information about sound parameters.
<source>minetest.sound_play(SimpleSoundSpec, SoundParameters)</source>
 
  
== Description ==
+
[[Category:Methods|s]]
Plays a sound.
 
 
 
<code>SimpleSoundSpec</code> can be a string with the filename (without the file extention) or a table with the fields <code>name="name"</code> and <code>gain=float</code>.
 
 
 
<code>SoundParameters</code> is a table with the following fields:
 
* <code>gain = float</code>: the gain (default 1.0)
 
* <code>max_hear_distance = int</code>: the maximum hear distance
 
* <code>loop = bool</code>: Sound is looped
 
The location can be specified with one of the following fields (if none is used, its played locationless to all players):
 
* <code>to_player = "playername"</code>: Sound is played locationless to the player
 
* <code>pos = [[position]]</code>: Sound is played at this position
 
* <code>object = [[ObjectRef]]</code>: Sound is played connected to the object
 
 
 
The function returns a sound hanlder that can be passed to <source enclose=none>minetest.sound_stop(handle)</source> to stop the sound.
 
 
 
{{MissingExample}}
 
 
 
[[Category:Methods]]
 

Latest revision as of 13:50, 25 October 2022

Mbox warning.png This page contains unofficial, low-quality Lua API documentation and is likely to be outdated or wrong. Do not rely on it!
For the official and up-to-date documentation, see Lua API Documentation.
Mbox warning.png This page has been proposed for deletion for the following reason: "Contains unofficial and potentially outdated, redundant and inconsistent Lua API information"
If you don't think that this page should be deleted, please explain why on the talk page.

See minetest.sound_play in the Lua API documentation, and Sounds for general information about sound parameters.