Hello everyone
I'm trying to modify a already existing mod. I want to add differntly pitched weapon sounds to each weapon. This should make the weapons sound less monoton and in the case uf fully automatic ones, less ear piercing. So what i already pitched the weapons sounds up and down a few tones and saved them as independent files and integrated them into the sound folder of the mod.
So i tried to extend the item.lua script with the new file names but this is where i run into errors. My question is: Is there a specific command that tells the game to pick multiple weapon sound for the same weapon randomly or at least sequentualy?
I already looked into the lua file for the standard smg of factorio which has 3 different sounds to play. I tried to copy its structure of the "sound=" and also placed the files (additionally) into the weapon sound (its name escapes me right now) folder of the "base" folder of factorio, sadly with no luck...
Managing multiple weaponsounds
Re: Managing multiple weaponsounds
If you are trying to overwrite an existing entity's sound, you should not use data:extend. Instead, edit the data table directly.
Or if you want to keep the existing sounds and add another one:
Code: Select all
data.raw["gun"]["submachine-gun"].attack_parameters.sound = {
{
filename = "__my-mod__/sound/submachine-gunshot-1.ogg",
volume = 0.6,
},
{
filename = "__my-mod__/sound/submachine-gunshot-2.ogg",
volume = 0.6,
},
{
filename = "__my-mod__/sound/submachine-gunshot-3.ogg",
volume = 0.6,
}
}
Code: Select all
local new_sound = {
filename = "__my-mod__/sound/submachine-gunshot-4.ogg",
volume = 0.6,
}
table.insert(data.raw["gun"]["submachine-gun"].attack_parameters.sound, new_sound)
Re: Managing multiple weaponsounds
Hey thank so much!!! It works nowDaveMcW wrote: Fri Mar 26, 2021 12:13 pm If you are trying to overwrite an existing entity's sound, you should not use data:extend. Instead, edit the data table directly.
Or if you want to keep the existing sounds and add another one:Code: Select all
data.raw["gun"]["submachine-gun"].attack_parameters.sound = { { filename = "__my-mod__/sound/submachine-gunshot-1.ogg", volume = 0.6, }, { filename = "__my-mod__/sound/submachine-gunshot-2.ogg", volume = 0.6, }, { filename = "__my-mod__/sound/submachine-gunshot-3.ogg", volume = 0.6, } }
Code: Select all
local new_sound = { filename = "__my-mod__/sound/submachine-gunshot-4.ogg", volume = 0.6, } table.insert(data.raw["gun"]["submachine-gun"].attack_parameters.sound, new_sound)

So for everyone who tries the same i'll quickly summarize what i did.
Here is the original code found in the data.lua file of the mod:
Code: Select all
require("prototypes.ammo")
require("prototypes.weapon")
require("prototypes.recipe")
require("prototypes.technology")
require("prototypes.ammo-category")
require("prototypes.projectiles")
require("prototypes.entity")
Code: Select all
require("prototypes.ammo")
require("prototypes.weapon")
require("prototypes.recipe")
require("prototypes.technology")
require("prototypes.ammo-category")
require("prototypes.projectiles")
require("prototypes.entity")
data.raw["gun"]["boltgun"].attack_parameters.sound = {
{
filename = "__Wh40k_Armoury_fork__/sound/bolt1.wav",
volume = 0.6,
},
{
filename = "__Wh40k_Armoury_fork__/sound/bolt2.wav",
volume = 0.6,
},
{
filename = "__Wh40k_Armoury_fork__/sound/bolt3.wav",
volume = 0.6,
},
{
filename = "__Wh40k_Armoury_fork__/sound/bolt4.wav",
volume = 0.6,
},
{
filename = "__Wh40k_Armoury_fork__/sound/bolt5.wav",
volume = 0.6,
}
}
data.raw["gun"]["stormbolter"].attack_parameters.sound = {
{
filename = "__Wh40k_Armoury_fork__/sound/bolt1.wav",
volume = 0.6,
},
{
filename = "__Wh40k_Armoury_fork__/sound/bolt2.wav",
volume = 0.6,
},
{
filename = "__Wh40k_Armoury_fork__/sound/bolt3.wav",
volume = 0.6,
},
{
filename = "__Wh40k_Armoury_fork__/sound/bolt4.wav",
volume = 0.6,
},
{
filename = "__Wh40k_Armoury_fork__/sound/bolt5.wav",
volume = 0.6,
}
}
data.raw["gun"]["bolt_rifle"].attack_parameters.sound = {
{
filename = "__Wh40k_Armoury_fork__/sound/bolt1.wav",
volume = 0.6,
},
{
filename = "__Wh40k_Armoury_fork__/sound/bolt2.wav",
volume = 0.6,
},
{
filename = "__Wh40k_Armoury_fork__/sound/bolt3.wav",
volume = 0.6,
},
{
filename = "__Wh40k_Armoury_fork__/sound/bolt4.wav",
volume = 0.6,
},
{
filename = "__Wh40k_Armoury_fork__/sound/bolt5.wav",
volume = 0.6,
}
}
data.raw["gun"]["heavy_bolter"].attack_parameters.sound = {
{
filename = "__Wh40k_Armoury_fork__/sound/HBolt1.wav",
volume = 0.6,
}
}
data.raw["gun"]["assault_bolter"].attack_parameters.sound = {
{
filename = "__Wh40k_Armoury_fork__/sound/bolt1.wav",
volume = 0.6,
},
{
filename = "__Wh40k_Armoury_fork__/sound/bolt2.wav",
volume = 0.6,
},
{
filename = "__Wh40k_Armoury_fork__/sound/bolt3.wav",
volume = 0.6,
},
{
filename = "__Wh40k_Armoury_fork__/sound/bolt4.wav",
volume = 0.6,
},
{
filename = "__Wh40k_Armoury_fork__/sound/bolt5.wav",
volume = 0.6,
}
}

Would it be ok for you if i try to contact the original mod dev and provide him with the newly modified files? I would give credit to you for helping me of course
