Custom ambient music

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Reygan
Fast Inserter
Fast Inserter
Posts: 177
Joined: Tue Jan 28, 2014 8:42 pm
Contact:

Custom ambient music

Post by Reygan »

How can i add my ambient music using lua?
Not replace existing, but add my files indeed. I searched, where existing files\pathes are writen (configs, luas, etc) but find nothing. Are they hardcoded in exe now? If they are, then it will be suggestion. Will be awesome, if mods can add custom music.

To mods: please, move this topic to right forum. I am not sure, to where it most related.
Daniel V. Lenskiy

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Custom ambient music

Post by FreeER »

the ambient sounds used by Factorio, normally, are in data\core\sound\ambient. I'm not sure that any files there are used simply because they are there, or if the exe looks for specific ones, I'm going to assume the latter. Some other ways to play sounds are listed below:

Some entity prototypes allow you to specify a sound (typically for when they are 'working') by providing the sound path, you'd need to look at the wiki prototype definitions (or I've tried to get some of the missing definitions recorded here, zip in second post).

'Triggers' can be used to play sound, so you could use any entity's trigger property to play-sound (of course, you have to find which entity has a trigger property that you can manipulate, the simplest would probably be the generic entity's created_effect or the entity_with_health's attack_reaction). See information on triggers here

I want to say that the MoLogic Core had a piece of sound code, but it was fairly limited from what I recall (you could ask it to play a sound that was part of MoLogic Core, but not your own).

I wrote a 'semi-useful' (at least theoretically) bit of code in an unreleased Extra Utilities mod/library that you can see here (based initially off of the 'warning flare' from the old CC mod). See the files that have 'sound' in their name and the unit-tests.lua file, however this implementation will almost certainly be reworked to use the entity_with_health's attack_reaction trigger instead (I wrote this before I'd gotten the information about triggers gathered and on the wiki).

If none of those methods work for you, then there isn't a way (that I know of) to play custom sounds (and thus ambient music). In all cases, it would be difficult if not impossible to stop the sound once it was started (and for long sounds and some uses the sound might theoretically be played a second time before it was even finished).

xboxxxxd
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat Apr 09, 2016 12:04 pm
Contact:

Re: Custom ambient music

Post by xboxxxxd »

I know it's 2 years later, but i just wanted to give it anyways, got annoyed every time i saw this question somewhere lol,

Here's a Pre-Made package by me, that keeps existing music to the game, but also adds custom ones (this script includes 37 different fancy and weird factorio styled songs, and some not..)

NOTE: This Mod is for v0.14.x <- versions of v0.14.0 and later editions.

(Songs are Free Licensed.)

Enjoy.

Ive Split up the files, because they where to big to get uploaded at once on here..
Custom-Music-Expansion_0.0.1(Part1).zip
Part 1 of this Mod.
(35.97 MiB) Downloaded 167 times
Custom-Music-Expansion_0.0.1(Part2).zip
Part 2 of this Mod.
(59.92 MiB) Downloaded 148 times
Custom-Music-Expansion_0.0.1(Part3).zip
Part 3 of this Mod.
(98.67 MiB) Downloaded 140 times
If you don't want all the Free Licensed Music with this mod, then only use this .zip instead of using all 4 parts, and add your own songs..
Custom-Music-Expansion_0.0.1(Part4).zip
Part 4 of this Mod.
(970 Bytes) Downloaded 136 times

User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 339
Joined: Tue Jul 08, 2014 10:06 am
Contact:

Re: Custom ambient music

Post by LuziferSenpai »

Hey,

i have written a MOD out of that and make it very easy to add new.

To add new:
Make 37 to the last Number that you have in your Names.
Have Fun.

Here is the MOD:

Click

Greetz,

Senpai
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai

Pascali
Fast Inserter
Fast Inserter
Posts: 170
Joined: Wed Aug 23, 2017 8:24 pm
Contact:

Re: Custom ambient music

Post by Pascali »

link is broken :(

Are that the musics played in factorio? The files in this directory?
sound\ambient

I wan´t to play the original music and additionally my custom musics. How can i do this?
xboxxxxd wrote: If you don't want all the Free Licensed Music with this mod, then only use this .zip instead of using all 4 parts, and add your own songs..
Custom-Music-Expansion_0.0.1(Part4).zip
I downlaoded the zip witch cointains:
data.lua
info.json

Where do i have to copy this files?

Post Reply

Return to “Modding help”