The radio currently does not create any sound in the newest version of beam, please wait, I'm working on it
Sadly the radio does not create any sound any more in 0.22 for reasons that CarKiller can’t explain either, neither can I or other modders I have asked. The functions I have used work, the code does not error, there are no entries into the system console so I have absolutely no clue WHAT even is not working about the code. It of course still works in any other Version without issues, I hope to find a solution eventually, but currently it‘s an unfixable problem for me. If anyone has any clue that could contribute towards what’s wrong, I would appreciate it. I will release updates of the LeGran and Focus with the radio as it is (tho implement the new code from the focus into the LeGran for all users of pre 0.22 versions) I don’t want the LeGran fix to be pushed any further back as it has been completed for a week now but I was trying to fix the radio before uploading. Sorry for the inconveniences, I just have no clue why or what is wrong
Does the console even see the sounds? Maybe it doesn't, and maybe something is preventing them from playing? This update caused many weird issues with sounds so no idea.
I looked through your code and tested stuff and the reason seems to be because there isn't enough of a delay between creating the SFX source and playing it, so it ends up playing nothing because I guess the SFX source is not ready. So I recommend you call the "obj:createSFXSource()" functions in the onInit() function to generate the SFX sources and store them in a table beforehand and then play them using: Code: obj:setVolumePitch(sfx_source, volume, pitch) obj:playSFX(sfx_source) And before playing a new song, call this function first to stop the current music: Code: obj:stopSFX(sfx_source)
Oh thank you! I didn’t know that stopSFX was something that existed That is gonna make stuff so much easier Also the reason why I don’t create them from the get go is that some of the sources (especially larger sound files like lonle) take a short bit to load, so adding more music would lengthen your loading time even if you don’t use the radio I‘ll experiment with that when working on the fix update --- Post updated --- Are you playing on 0.22?
That might be why it doesn't work, it could be trying to play them before they finish loading or something
Yeah that could explain part of it, however I’m still baffled as to why it worked before hand. Also if it‘s an issue of it not loading in time, it should work once you go back to the song after skipping over it, which it doesn’t... but I’ll mess around with the code some more and work with the stopSFX function
This is me when I look at the files of any mod that got broken in an update lol, how do people come up with the weirdest ways to exploit game bugs instead of making the mod properly, and also think it's the correct way of doing that?? When the console has so many errors that it almost crashes due to stack overflow (yes I've seen this happen in 2 mods, it's ridiculous), but they just ignore that because the mod somehow works anyway, what the heck??
Lmao okay that’s kinda funny About the console... the thing that made me a bit helpless was the absence of any kind of error in the console And the Radio lua is the result of my first „large“ lua project that also had a lot of experimenting go into it. It certainly is not the most efficient or cleanest way to create a radio and I already have multiple ideas as to how to improve it (thanks to you lot :3) but it... did work lol
Even your radio LUA is definitely way cleaner and more efficient than my multi-shooting cannon LUA, I need to rewrite it completely, currently it's about as bad as the Yandere Sim code lol. It was literally my first LUA code ever, and I copied a lot of it from the in-game cannon because it's almost the same thing, the difference is that mine is a controller so I couldn't use most of the original due to incompatibility.
The reason is because you are creating a new SFX object every time you try to play the audio and you aren't using the past created SFX object to play the audio. When you call "obj:createSFXSource()" it creates a new SFX object from the audio source and gives you a reference ID, which you use to play the audio. So if you don't want to initialize all SFX objects beforehand, just cache the ID of the SFX object the first time you play the audio and use that for playing the audio in the future and it should work.
Yes[/QUOTE] Then the radio does not work as noted by the huge wall of text above. what exactly do you mean with Caching the ID? Also yeah it‘s probably better to not create a new source each time you switch the playing music
Then the radio does not work as noted by the huge wall of text above. what exactly do you mean with Caching the ID? Also yeah it‘s probably better to not create a new source each time you switch the playing music[/QUOTE] So when you create the SFX source the first time, store the song directory and the ID from the "obj:createSFXSource()" as a key/value pair in a table. This way, you can get the ID of the SFX source using the song directory, since thats consistent unlike the ID you get from "obj:createSFXSource()" which varies depending on how many SFX sources have been created. So the code goes something like this: Code: local sfx_table = {} --Set this to song directory when you want to play a song local play_song_dir = "ui/modules/credits/lonle.ogg" local current_sfx_playing = nil local function loadSong(song_dir) --If SFX source is not cached (has never been played), then create SFX source if not sfx_table[song_dir] then sfx_table[song_dir] = obj:createSFXSource(song_dir, "AudioDefaultLoop3D", "", 1) return true end return false end local function playSong(song_dir) --Stop current music if current_sfx_playing then obj:stopSFX(current_sfx_playing) end --Play new song local sfx_to_play = sfx_table[song_dir] obj:setVolumePitch(sfx_to_play, 1, 1) obj:playSFX(sfx_to_play) current_sfx_playing = sfx_to_play end local function nextSong() --set play_song_dir to next song directory --play_song_dir = "some song directory" end local need_to_create_sfx = false local timer = 0 local function updateGFX(dt) if play_song_dir then --Check if we need to create SFX source if timer == 0 then need_to_create_sfx = loadSong(play_song_dir) end --If needed to create SFX source --then start timer to delay playing song if need_to_create_sfx then timer = timer + dt else timer = 1 end --If arbitrary amount of time passed then play song --hopefully SFX source loaded by now :) if timer >= 1 then playSong(play_song_dir) timer = 0 play_song_dir = nil end end end M.nextSong = nextSong M.updateGFX = updateGFX
Thank you, Angelo! I have taken some deep looks at your code and finally learned what a table is I have already implemented all of it into my lua code with some changes and it works flawlessly After fixing all the sources of lua errors lol. The code is also a lot simpler to modify now and the tutorial can be shortened a lot that way as well! I credited your parts of code inside the lua Again, thank you very much, I couldn't have done that without you ^^