Caramelldansen Labs


Turns your Research Labs into a Rave with a touch of Caramelldansen

Tweaks
9 months ago
1.1 - 2.0
6.49K

b Fix for sound duplication with multiple labs (v2.0.60)

8 days ago

I've found a relatively good solution to this issue. Now, only one track plays at a time, as intended. However, when you move near other labs, the music may switch. Each lab plays the same track but may be at a different point in the song.

Code: prototypes/caramelldansenlabs.lua:

local settingVolume = settings.startup["caramelldansenlabs_volume"].value
local settingLimit = settings.startup["caramelldansenlabs_limit"].value

local lab_sound_def = {
    filename = "__CaramelldansenLabs__/sounds/CaramelldansenLabs.ogg",
    volume = (settingVolume / 100) * 0.8,
    preload = true
}

local working_sound_def = {
    sound = lab_sound_def,
    idle_sound = { filename = "__base__/sound/idle1.ogg", volume = 0.6 },
    apparent_volume = 2.5,
    audible_distance_modifier = 0.2,
    fade_in_ticks = 5,
    fade_out_ticks = 5,
}

if settingLimit then
    working_sound_def.max_sounds_per_prototype = 1
end

data.raw["lab"]["lab"].working_sound = working_sound_def

if mods["Krastorio2"] then
    data.raw["lab"]["biusart-lab"].working_sound = table.deepcopy(working_sound_def)
end

if mods["space-exploration"] then
    data.raw["lab"]["se-space-science-lab"].working_sound = table.deepcopy(working_sound_def)
end

New response