Pain


Modable sounds when player is in pain. Works best in multiplayer.

Utilities
2 years ago
1.1
515
Combat

FAQ

Found a bug, issue or a missing feature?


Please report bugs or issues to our mod discussion page in accordance with factorio bug report rules or talk with us about the desired features.

How to create a sound pack?


We implemented a moddable interface. Everybody can make own sound packs!

To create a soundpack

  • Add dependency to info.json
{ "dependencies": ["pain"] }
  • Add your sound pack option in settings.lua
-- add your sound pack as option for the player
table.insert(data.raw["string-setting"]["pain-sound-pack"].allowed_values, "my-pain")
-- optionaly set it as default
data.raw["string-setting"]["pain-sound-pack"].default_value = "my-pain"
  • Name your sound pack option in locale/en/locale.cfg: (for example)
[string-mod-setting]
pain-sound-pack-my-pain=Hurt know More
  • Specify your pain sound in data.lua
-- define sound
data:extend{
    -- example
    {
        type = "sound",
        name = "my-pain-any",
        category = "alert",
        filename = "__pain__/sounds/any.ogg",
        volume = 0.9,
        aggregation = {
            max_count = 1,
            remove = false,
            count_already_playing = true,
        },
    },
    {
        type = "sound",
        name = "my-pain-fire",
        category = "alert",
        variations = {
            {
                filename = "__pain__/sounds/fire1.ogg",
                volume = 0.42,
            },
            {
                filename = "__pain__/sounds/fire2.ogg",
                volume = 0.23,
            },
        },
        aggregation = {
            max_count = 1,
            remove = false,
            count_already_playing = true,
        },
    },

}
  • Register your sound pack in control.lua
-- define sound pack
local function make_sound_pack()
    remote.call("pain", "register", "my-own-sound-pack", {
        -- example
        {
            damage = "*", -- any
            health = 0,
            comparison = ">",
            sound  = "my-pain-any",
            volume = 0.6,
            delay  = 60 * 1, -- 1s
            priority = 0, -- default
        },
        {
            damage = "fire",
            health = 222, -- character max is 250 by default
            comparison = "<", -- default
            sound  = "my-pain-fire",
            volume = 1, -- default
            delay  = 60 * 2, -- 2s
            priority = 1, -- higher then any
        },
    })
end
-- hook it up to the [pain mod](https://mods.factorio.com/mod/pain)
script.on_init(make_sound_pack)
script.on_load(make_sound_pack)
  • every pain can be customized to specific damage types

How to use the mod API?


Remote interface to install and modify sound packs:

remote.call("pain", "soundpacks") → array of string

Returns a list of all installed sound pack names.

remote.call("pain", "killers", name) → array of Filter

Gets name of sound pack.
Returns list of Filter.

remote.call("pain", "register", name, filters)

Gets name of sound pack and a list of Filter.
The filters will be added to given sound pack.

remote.call("pain", "unregister", name, filters)

Gets name of sound pack and a list of Filter.
The filters will be removed from given sound pack.
Optional parameters are ignored here.

remote.call("pain", "update")

Resets damage event filters.
Only for internal working required.

What is the format of the filter expression?


Filter{
    -- if
    damage = "type",    -- required, DamageType name or "*" for any
    health = 23,        -- required, number
    comparison = "<=",  -- optional, ComparisonString
    probabiliy = 0.5,   -- optional, [0,1]
    priority = 0,       -- optional, hightest gets played
    -- then
    sound  = "path"     -- required, SoundPath
    volume = 1,         -- optional, [0,1]
    delay  = 0,         -- optional, ticks or false to play immediately
}

Further information