There's an existing mod, TrainHorn, that plays a train horn sound when a player is run over (AKA the train horn of shame).
I've added this mod to a small multiplayer game I'm running with friends and we found that the train horn sound is only local to the person getting squished, and I'm wondering if it can be modified so that the sound is global to all players?
I've been looking through the control.lua and data.lua of this mod, trying to figure this out. My best guess is that the following event position variable in control.lua "event.cause.surface.create_entity({name = "train-horn-sound", position = event.cause.position}) is what needs to be changed, but I could be 100% wrong and I do not know what to change it to, to be able to hear the train horn globally.
Here's the control.lua and data.lua of the mod:
control.lua
Code: Select all
script.on_event(defines.events.on_player_died, function(event)
if event.cause ~= nil then
if event.cause.type == 'locomotive' then
event.cause.surface.create_entity(
{name = "train-horn-sound", position = event.cause.position})
end
end
end)
Code: Select all
data:extend({
{
type = "explosion",
name = "train-horn-sound",
flags = {"not-on-map"},
animations = {
{
filename = "__core__/graphics/empty.png",
priority = "low",
width = 1,
height = 1,
frame_count = 1,
line_length = 1,
animation_speed = 1
}
},
light = {intensity = 0, size = 0},
sound = {
{
filename = "__TrainHorn__/sound/horn.ogg",
volume = 1.0
}
}
}
})