OpenNoteBlockStudio icon indicating copy to clipboard operation
OpenNoteBlockStudio copied to clipboard

Show /execute syntax to play data packs from a command block

Open Oscilloscopy opened this issue 3 years ago • 2 comments

This could be an issue for mapmakers and other similar people, if the function were to be run on a command block, using /function or doing the same with /execute on a player doesnt play because the datapack uses @s in the play/pause/stop commands. Maybe add a feature to change this to @p/@a/etc.

Oscilloscopy avatar Jun 16 '22 12:06 Oscilloscopy

From the FAQ:

🇶 I can't hear my data pack when I play it in a command block./How can I play data packs to everyone in the world? When you run /function <song>:play in the chat, you're the one executing the command, so the datapack will only play for you. Similarly, if you paste this command into a command block, the song will only play for the command block itself, that is, no one will hear it. To play the song for everyone, use /execute as @a at @s run function <song>:play. You can also replace @a with another selector to pick whoever you want to hear the song.

encode42 avatar Jun 16 '22 17:06 encode42

Yeah, the purpose of using @s is so the command executor has the freedom to pick who they want to hear the song, which is possible with /execute (wouldn't be the case if @p/@a were "baked" into the commands).

Playing from a command block is such a common use case, though. So I do think we should make it more clear that this is the intended way to use the data pack (perhaps by showing the /execute syntax on the popup after you export the data pack). I'll leave this issue open so we can address it in the future!

Bentroen avatar Jun 20 '22 04:06 Bentroen