Page 1 of 1

Programatical way to play audio

Posted: Tue Sep 20, 2016 1:50 am
by aubergine18
Currently there's only 2 ways to play audio that I'm aware of:

1. Use an entity that makes sound (lots of processing overhead as the entity is doing a bunch of stuff I don't need)

2. GUI left-click sounds (only applicable to GUI).

I'd like a way to emit sound at a specific map location, without having to place an entity, ideally by first defining a `sound` prototype (so I can set volume via data.lua, preload, etc) and then using it via an API call (method on LuaSurface, possibly with ability to limit to specific player) passing in the name of the sound prototype.

If there are low-overhead ways to do this already, please let me know :)

Re: Programatical way to play audio

Posted: Tue Sep 20, 2016 4:20 am
by Mooncat
About audio, I wanted to make a musical mod that provides something like Minecraft's Jukebox.
I used assembling machine as the entity and changed its working sound. The idea was that when the machine received a musical material, it plays sound for roughly 0.5 seconds.
But the main issue was that the working sound didn't transmit far enough. It was loud when I was standing next to the machine. But if I walked away, the sound was lowered too quickly.

I have thought about calling API to play sound too. So I think I have to second this request.

(Or more specific to my case: I need a property that can change sound transmit distance. :P )