Space Engineers

Space Engineers

Isy's Sound Randomizer
32 Comments
Deapri 24 Jan, 2024 @ 3:32pm 
Isy, would it be too much trouble to add an argument to skip a sound if ddesired?


void Main(string argument)
{
if(argument == "next")

{

firstRun = true;
}
Deapri 24 Jan, 2024 @ 4:21am 
Thanks for this Isy, was looking for a was to play a mix track while salvaging via a sound block.
MacMooey 31 May, 2022 @ 3:32pm 
Okay, I was unaware. Still new to the modding scene of SE, thank you so much!
Isy  [author] 31 May, 2022 @ 1:55am 
That's because you put it in the MOD list... Scripts are not mods! They have to be subscribed by every user and then loaded into programmable blocks.. Watch this video for more informations about how to do it:

https://youtu.be/NkhZ7BbYgvc
MacMooey 30 May, 2022 @ 7:23pm 
Hey Isy, every time I attempt to load your script in a world, I get a fatal error and the script fails to load.
Sindobaddo 14 Apr, 2022 @ 4:55am 
oh... damn, well thank you anyway
Isy  [author] 14 Apr, 2022 @ 1:19am 
No, it's more likely meant to play some ambient background noises now and then.. For your case, you'd need two sound blocks that are triggered by the sensors directly..
Sindobaddo 13 Apr, 2022 @ 9:36am 
can this script use a sensor to trigger a specified sound? and another sensor to trigger a different specified sound on the same sound block? or is it only meant for random?
Isy  [author] 24 Feb, 2022 @ 1:21am 
It's definitely possible but would require some work on this script, which I'm honestly not willing to do.. Neither I nor many other people found a good use for it, so you have to take it as-is unfortunately..
waverider6000 23 Feb, 2022 @ 8:00am 
Hi Isy.... thanks for your prompt reply

I think I miss understood your description and was trying to achieve a result that the script isn't designed to do which is a shame.

"Main features: Play sounds in order or random order"

I believe that it will play all sounds in list once before restarting the list, but placing sounds in script one after the other doesn't ensure it will play them in the exact order in script.

wish you could enter a number command before sound in the script so that it knows the order to play. I am not sure if thats possible, I am jealous of those who can code thanks for your time.
Isy  [author] 23 Feb, 2022 @ 3:13am 
Uh I didn't touch this script in years - don't know why it would behave that way... By looking at the code, there's not much that can go wrong - it's very straight forward, but it's also not very refined by the looks of things.. The script just starts over after the sequence finished which makes playing a defined set rather difficult.. It was more or less written for ambient noises (wind, birds, passing ships)..
waverider6000 22 Feb, 2022 @ 3:12pm 
Hi Isy your work is amazing

I am struggling to sort this issue out. I want to play a set of sounds in ascending order example:

string[] soundList = { "Malfunction DetectedId", "Running Virus ScanId", "Systems NormalId", "RebootingId" };

The sounds run in sequence until I added the last sound, it appears they now run in alphabetical order, which is not what I want. can you help because I am trying to create a hilarious situation on my elevator and have further sounds to add which wont sound right otherwise. The sounds copied from custom data to avoid any conflict
Chuck 14 Oct, 2020 @ 10:18pm 
@The High Velocity Pineapple Yeah that's a bug with small cockpits. I've tested it quite extensively. Not sure if it's reported or not - Keen makes it very difficult to report bugs, probably on purpose.

The only way to hear drone sounds in a small cockpit, would be if you could also hear them when just standing there (aka, the room around the small cockpit is airtight or you are on a planet, etc). I've tested this 15 ways to christmas. It applies to all 3 vanilla small cockpits. It doesnt matter if the small cockpit has an air supply of its own (that helps you hear all other sounds, but still not the drone sounds). Large cockpits in all the same circumstances will hear the drone sounds.
High Velocity Pineapple 24 Jul, 2020 @ 9:45am 
None of the Drone sounds appear to work, every thing else does thought?
Titan Nya 17 Mar, 2020 @ 4:40am 
Well not what i want to do exactly in my ship but it'll probably help me manage to edit another script for sound use as i have 1 sound block for flight alert that work nativelly with a script (just play the sound in the sound block then needed) and 1 sound block (mirrored cockpit) who is free and would be nice to use it for then a ship is detected or other things like that...

Hope i can understand how sound block work and all of that... I kinda want to finally use the sound mods i've had for a long time...
Isy  [author] 1 Apr, 2019 @ 3:32pm 
Current song on a LCD sounds like a good idea, because I love showing stuff on LCDs ;) Regarding the playtime.. I need to have a look at the options I have there, but I'm not sure, whether this is possible..
And regarding the broken sound: this bug exists for a very long time now.. I'm not sure that it will ever be fixed.. I think I need to start a new ticket at the bug tracker..
smartbadger 1 Apr, 2019 @ 3:27pm 
I hope that Keen fix sound blocks soon, 'cause this script is excellent, but my station's Rec room still spends too long in silence, and my transport doesn't play trucking music nearly as often as it should.
Have you considered echoing the title of the currently playing track to an LCD? Perhaps one of the wee corner LCDs would be a good readout size. Also, I don't think that the script gives you any way to expose how long a particular track is, does it? If it did, it'd be good to have the ability to play the next track when the current one finishes, as opposed to using a fixed time.
Isy  [author] 3 Nov, 2018 @ 8:42am 
Nothing.. Playing sounds with the sound block is always a hit and miss.. Because Keen.. Try playing the same sound in the sound block's terminal screen a few times after another.. It will bug out.. Because Keen!
RedRobin 3 Nov, 2018 @ 5:26am 
Hello, thanks for the script! I dont get it - I've read te post below but I dont know whats wrong. I have Station messages as you said. Like "Welcome to the station" but as it was written before - it plays only first sound and then other ones just first half second of it. What am I doing wrong?
Thanks RR
Isy  [author] 27 Sep, 2018 @ 5:06am 
Use the sound block itself with that action..
kulinator1 27 Sep, 2018 @ 4:07am 
Can you please add stop and start to the script so i can play i by button?:steamhappy:
Helratz 19 Aug, 2018 @ 6:52am 
Is there a way to make a sound block or group of sound blocks play a specific list of sounds that will play in sequence automatically that doesn't require a ton of programmable blocks or timer blocks?
Diego 22 May, 2018 @ 8:36am 
hmm makes sense thanks
Isy  [author] 22 May, 2018 @ 8:17am 
The script sets the loop time to 0 because if you want to randomize sounds, you don't want play one sound in a loop, do you ;) This script only really makes sense, if you have a sound pack with some ambient sounds installed, like bird chirps or station messages, like refinery xyz is broken, please send an engineer :P
Diego 22 May, 2018 @ 7:38am 
well strange, if i put the music from SE in it it plays one with the loop / the time to the next sound intervall but than it plays only a sek from the second one. With modded alarm sounds it plays only 1sek dosent matter what i do.
Diego 22 May, 2018 @ 7:09am 
hy Isy, you suprise me every time with your scripts :D but i have a problem with the loop time. That means it only play loopSounds 1sek long
ratheden 20 May, 2018 @ 8:19pm 
Ah, sorry, i just assumed that it was hard to do, not impossible. I have a lot of music and most does not have a common item i their IDs or titles. Some of it does like it is labeled cd1 cd2 etc, those will be easy to search for but the rest i will have to do one by one it seems.


also can a volume setting per song be added? When doing it timer/per/sound block (my old way) i could set the volume on each sound block, as many of the songs play at a different volume.

Anyway, Thanks for a great Mod!
Isy  [author] 19 May, 2018 @ 11:17am 
Did you even read my comment? "So, first of all: you can't rename sounds."
ratheden 19 May, 2018 @ 10:57am 
Can i rename the sounds? if so how? I would like to add a prefix to all songs to make finding them easy, as the names vary a lot.
Isy  [author] 19 May, 2018 @ 2:01am 
I don't really understand your problem.. So, first of all: you can't rename sounds. All sounds have an internal ID that is stored in the game files, for example "Lights On" has the ID "SoundBlockLightsOn". That's the way, Keen labeled it internally. My script reads all these IDs and puts them in the custom data of the programmable block so that you can have a look at what IDs are available.
If you build your own soundpack, you can however define the names, IDs and so on.

As described in my script, it can find and play songs by searching for them with partial IDs, so if you have a mod, where all sounds are named like "MyModSound1", "MyModSound2", "MyModSound3", ... you could just use it like this:

string[] soundList = { "MyMod" };

The script will find all sounds, that contain "MyMod" and play them..
ratheden 18 May, 2018 @ 6:53pm 
My current way is to build sound blocks on the electronics attachment mod, this lets me have 25 soundblocks in 1 large grid space, then i add a 2nd electronics attachment add 25 timers, and tell the first to play, then start the next timer.... LOTS of setup, no randomizing, and you have to set the delay on each timer for the song length....

So your script seems like the answer.. i have managed to get it to play 5 songs, learning the syntax of scripting as i go, but slowly.

ON to my question:
is there a easy way to change the ID or Song name? so i might make this easier by adding a prefix to Songs and not sounds?
ratheden 18 May, 2018 @ 6:26pm 
This seems to be EXACTLY what i have been wanting so badly of late...
But when i copy a list of sounds from the custom data and place it in this area at the end of this, // List of sounds by ID. IDs are saved in the custom data of the programmable block for easier access.
// The search for sounds can be done with partial strings, like "Sound" will find all sounds containing this string
// Example: string[] soundList = { "SoundBlockLightsOn", "SoundBlockLightsOff", "SoundBlockObjectiveComplete" };
string[] soundList = {}; text
, placed here: soundList = {}; in the brackets. I get a lot of errors, tried adding commas after each sound(song) and that cleared a few errors but does not get them all.

So, How can i using the custom data, insert songs into end of that list of sounds by ID? Do i need a sound block for each song? i am only using 1 at them moment.

Your Scripts are the best, just gotta learn to use them right :)