Community Forum

Loading an audio sample disables all audio in the game?

Forum Overview >> Scripting

Created17.04.2017 00:03

Tim Derks (timmiej93) 17.04.2017 00:10
I've been trying to play a 3D audio sample on demand in my new mod, but unfortunately, it is affecting the sound in the game in a strange way.

Here is the code loading the sample:
self.crossingSound = SoundUtil.loadSample(self.xmlFile, {}, "placeable.sounds.crossing", nil, self.baseDirectory, self.nodeId);

This is the XML entry:
<crossing file="sounds/trainCrossingBell.wav" indoorVolumeFactor="0.55" pitchOffset="1" volume3D="0.45" innerRadius="10" radius="50" />

There are no errors in the log beforehand. I commented all '" for debugging, the loading is the only sound reference in my mod.

The process is as follows:
I start an engine to ensure I have sound.
I place the mod (placeable)
I tab around through some vehicles
After a few vehicles, I get the following errors in my log:

Warning (Script): Unknown entity id 85021 in method 'getVisibility'.
LUA call stack:
dataS/scripts/utils/SoundUtil.lua (147) : getVisibility
dataS/scripts/vehicles/specializations/Steerable.lua (475) : onCameraSwitched
dataS/scripts/vehicles/VehicleLeaveEvent.lua (56) : leaveVehicle
dataS/scripts/network/Connection.lua (77) : run
dataS/scripts/BaseMission.lua (2345) : sendEvent
dataS/scripts/FSBaseMission.lua (3783) : onEnterVehicle
dataS/scripts/vehicles/VehicleEnterResponseEvent.lua (72) : onEnterVehicle
dataS/scripts/network/Connection.lua (77) : run
dataS/scripts/vehicles/VehicleEnterRequestEvent.lua (67) : sendEvent
dataS/scripts/network/Connection.lua (77) : run
dataS/scripts/BaseMission.lua (2338) : sendEvent
dataS/scripts/BaseMission.lua (1387) : requestToEnterVehicle
dataS/scripts/BaseMission.lua (1679) : toggleVehicle
dataS/scripts/FSBaseMission.lua (2171) : update
dataS/scripts/missions/mission00.lua (333) : update
dataS/scripts/main.lua (1876) : update

Does anyone know what on earth is going on here?
Also, bonus question, why is the SoundUtil not on the GDN? Is it too recent to publish?


i've switched over to adding the audio in the Giants Editor, and switching it on and off by settings its visibility. Works just fine. The issue now, however, is that when I call "g_gui:showGui('')", my game goes silent again. I'm absolutely flabbergasted, why would a GUI call affect audio? Am I doing something terribly wrong?

Emil Drefers (Unknown) 18.04.2017 07:05

hmmmm, the error message might indicate that a sample hasn't been deleted correctly.

In any case it might be worth to check if "self.crossingSound" is a valid table and if some values have been added to it.


Tim Derks (timmiej93) 18.04.2017 21:17
Aha! I just got a suspicion!
As I mentioned after my edit, I found out that calling g_gui:showGui('') was causing this, and I now know why, or at least I think so.
The GUI I'm closing by calling that, is the shop screen, or more specifically, the placement screen. These block audio, as most of us know, so I'm guessing this isn't properly canceled when calling g_gui:showGui('').
Is there a better way to close those GUIs?


PS. The reason for that first error was indeed the improper deleting of a sample, I loaded the sample in the load function of a placeable, and didn't do anything to it in the delete function, so that caused it.

Schon Batista (luizeduardo) 26.11.2017 02:29
hello wanted a help i want by indoorSounds.lua more this giving error. Error: Running LUA method 'update'.
dataS / scripts / utils / SoundUtil.lua (221): attempt to perform arithmetic on field 'volumeFactor' (a nil value)
Error: Render device Error: Unknown. What should I do?

Note: Log in to post. Create a new account here.