Referencing sounds.lua library in base mod
Posted: Fri Oct 25, 2024 4:09 pm
Hi there,
I've searched this forum but my problem apparently isn't that common.
I have the following code for implementing a new nuke explosion as part of a mod that changes some things in the mod in the module at :
The file references the from the base game. I've examined other mods using a similar strategy when adding new projectiles; those all load fine.
My mod however, does not. This is what I get:
The problem seems to be the relative path definition as the game expects a base directory within my mod. How do I actually reference the base game and not a base directory within my own mod?
Thanks!
I've searched this forum but my problem apparently isn't that common.
I have the following code for implementing a new nuke explosion as part of a mod that changes some things in the
Code: Select all
PlutoniumEnergy
Code: Select all
PlutoniumEnergyAddons\prototypes\entity\projectile.lua
Code: Select all
local sounds = require("__base__.prototypes.entity.sounds")
local uranium_atomic_bomb_action =
{
type = "direct",
action_delivery =
{
type = "instant",
target_effects =
{
{
type = "set-tile",
tile_name = "nuclear-ground",
radius = 20, -- This
apply_projection = true,
tile_collision_mask = { layers = { water_tile = true } }
},
{
type = "destroy-cliffs",
radius = 40, -- This
explosion = "explosion"
},
{
type = "create-entity",
entity_name = "nuke-explosion"
},
{
type = "camera-effect",
effect = "screen-burn",
duration = 80,
ease_in_duration = 5,
ease_out_duration = 70,
delay = 0,
strength = 8,
full_strength_max_distance = 200,
max_distance = 2000
},
{
type = "play-sound",
sound = sounds.nuclear_explosion(0.9),
play_on_target_position = false,
-- min_distance = 200,
max_distance = 2500,
-- volume_modifier = 1,
audible_distance_modifier = 3
},
{
type = "play-sound",
sound = sounds.nuclear_explosion_aftershock(0.4),
play_on_target_position = false,
-- min_distance = 200,
max_distance = 2500,
-- volume_modifier = 1,
audible_distance_modifier = 3
},
{
type = "damage",
damage = { amount = 1000, type = "explosion" } -- This
},
{
type = "damage",
damage = { amount = 1000, type = "physical" } -- This
},
{
type = "damage",
damage = { amount = 1000, type = "fire" } -- This
},
{
type = "create-entity",
entity_name = "huge-scorchmark",
offsets = { { 0, -0.5 } },
check_buildability = true
},
{
type = "invoke-tile-trigger",
repeat_count = 1
},
{
type = "destroy-decoratives",
from_render_layer = "decorative",
to_render_layer = "object",
include_soft_decoratives = true, -- soft decoratives are decoratives with grows_through_rail_path = true
include_decals = true,
invoke_decorative_trigger = true,
decoratives_with_trigger_only = false, -- if true, destroys only decoratives that have trigger_effect set
radius = 60 -- large radius for demostrative purposes -- This
},
{
type = "create-decorative",
decorative = "nuclear-ground-patch",
spawn_min_radius = 21.5, -- This
spawn_max_radius = 22.5, -- This
spawn_min = 55, -- This
spawn_max = 80, -- This
apply_projection = true,
spread_evenly = true
},
{
type = "nested-result",
action = {
type = "area",
target_entities = false,
trigger_from_target = true,
repeat_count = 2000,
radius = 40,
action_delivery = {
type = "instant",
target_effects = {
type = "create-fire",
entity_name = "atomic-bomb-fire-flame",
tile_collision_mask = { layers = { water_tile = true } }
}
}
}
},
{
type = "nested-result",
action =
{
type = "area",
target_entities = false,
trigger_from_target = true,
repeat_count = 3000, -- This
radius = 35, -- This
action_delivery =
{
type = "projectile",
projectile = "atomic-bomb-ground-zero-projectile",
starting_speed = 0.6 * 0.8 * 2.5, -- This
starting_speed_deviation = nuke_shockwave_starting_speed_deviation
}
}
},
{
type = "nested-result",
action =
{
type = "area",
target_entities = false,
trigger_from_target = true,
repeat_count = 4000, -- This
radius = 125, -- This
action_delivery =
{
type = "projectile",
projectile = "atomic-bomb-wave",
starting_speed = 0.5 * 0.7 * 2.5, -- This
starting_speed_deviation = nuke_shockwave_starting_speed_deviation
}
}
},
{
type = "nested-result",
action =
{
type = "area",
show_in_tooltip = false,
target_entities = false,
trigger_from_target = true,
repeat_count = 2500, -- This
radius = 70, -- This
action_delivery =
{
type = "projectile",
projectile = "atomic-bomb-wave-spawns-cluster-nuke-explosion",
starting_speed = 0.5 * 0.7 * 2.1, -- This
starting_speed_deviation = nuke_shockwave_starting_speed_deviation
}
}
},
{
type = "nested-result",
action =
{
type = "area",
show_in_tooltip = false,
target_entities = false,
trigger_from_target = true,
repeat_count = 2000, -- This
radius = 12, -- This
action_delivery =
{
type = "projectile",
projectile = "atomic-bomb-wave-spawns-fire-smoke-explosion",
starting_speed = 0.5 * 0.65 * 2.5, -- This
starting_speed_deviation = nuke_shockwave_starting_speed_deviation
}
}
},
{
type = "nested-result",
action =
{
type = "area",
show_in_tooltip = false,
target_entities = false,
trigger_from_target = true,
repeat_count = 3500, -- This
radius = 40, -- This
action_delivery =
{
type = "projectile",
projectile = "atomic-bomb-wave-spawns-nuke-shockwave-explosion",
starting_speed = 0.5 * 0.65 * 3.5, -- This
starting_speed_deviation = nuke_shockwave_starting_speed_deviation
}
}
},
{
type = "nested-result",
action =
{
type = "area",
show_in_tooltip = false,
target_entities = false,
trigger_from_target = true,
repeat_count = 1500, -- This
radius = 60, -- This
action_delivery =
{
type = "projectile",
projectile = "atomic-bomb-wave-spawns-nuclear-smoke",
starting_speed = 0.5 * 0.65 * 2.5, -- This
starting_speed_deviation = nuke_shockwave_starting_speed_deviation
}
}
},
{
type = "nested-result",
action =
{
type = "area",
show_in_tooltip = false,
target_entities = false,
trigger_from_target = true,
repeat_count = 25, -- This
radius = 20, -- This
action_delivery =
{
type = "instant",
target_effects =
{
{
type = "create-entity",
entity_name = "nuclear-smouldering-smoke-source",
tile_collision_mask = { layers = { water_tile = true } }
}
}
}
}
}
}
}
}
Code: Select all
sounds.lua
My mod however, does not. This is what I get:
The problem seems to be the relative path definition as the game expects a base directory within my mod. How do I actually reference the base game and not a base directory within my own mod?
Thanks!