Page 1 of 1
closing the modified gui of a combinator plays no sound
Posted: Fri Dec 06, 2024 3:27 am
by hgschmie
I have an entity that is derived from constant combinator. It shows up as having a "close gui sound" in the prototype gui:

- Screenshot 2024-12-05 at 19.17.59.png (129.02 KiB) Viewed 440 times
in my code, I am overwriting "entity.opened" with my own GUI.
When opening the GUI, the game plays the "open gui sound". However, when closing it (calling player.opened.destroy()), the gui closes but no sound is played.
Re: closing the modified gui of a combinator plays no sound
Posted: Sat Dec 07, 2024 7:48 am
by Honktown
Is it possible you're not noticing because the gui is closed during your explicit overwrite? I would expect writing player.opened = something else would play the close sound then, as that would be when the entity gui is closed. And that destroying a LuaGuiElement or a LuaEntity would not play a sound (the former because destroying a gui plays no sound, and that a destroying an entity wouldn't be "closing" the entity).
From how you wrote it, was it:
1) opened entity (opened sound played)
2) player.opened is written with created LuaGuiElement (I might expect a close sound to play here, overlapping entity open)
3) Player triggers close (no sound)
4) LuaGuiElement is .destroyed()? (no sound)
Re: closing the modified gui of a combinator plays no sound
Posted: Mon Dec 09, 2024 5:33 pm
by hgschmie
Hi,
Thanks for the quick response.
Basically, when the gui opens (fires on_gui_opened), I overwrite player.opened with my own GUI (in this case to replace a constant combinator gui with my own). It does play the "open sound", it does not play the "close sound here" (or maybe it does and it is not audible). The sound is not different from opening the "vanilla" GUI.
The player now interacts with the custom GUI and at some point, they press the "close" icon to close the GUI:
- assign 'nil' to player.opened
- call destroy on the custom GUI root element.
The GUI closes silently (no close sound).
Of course I can play the sound myself there but it seems wrong.