speaker.playSound
The sound name corresponds to a resource name in sound.json file. For instance minecraft:entity.player.levelup is the sound one hears when leveling up.
speaker.playSound Function | |
---|---|
Syntax speaker.playSound(
| |
Returns | boolean success |
API | speaker |
Source | CC:Tweaked (source) |
Play a sound with the given volume and pitch.
Like .playNote, the volume may be any value between 0 and 3 defaulting to 1.
The pitch argument is slightly different. Instead this may be any value between 0 and 2, with a larger value representing a higher pitch. One may convert from .playNote to .playSound pitches with the following equation: 2 ^ ((pitch - 12) / 12).
This will return true if the sound could be played or false if too many sounds were played in a single tick.
|
|||
Play a sound. | |||
Code | <nowiki>
local speaker = peripheral.find("speaker")
speaker.playSound("minecraft:entity.player.levelup")
</nowiki>
|
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.