Setting dependent character animations
Posted: Tue Mar 11, 2025 9:52 pm
So I'm hoping to include a setting in my Power Armor MK3 mod which changes the PAMK4 armor into a mech armor, complete with all the bells an whistles, including the animations (it looks quite silly without them). I've managed to get everything to work except for the appearance/animations.
I'm currently using the following to use Vanilla sprites for my armors. This is done in the Prototype stage.
What I want to do is check if both Space Age is enabled and the setting is enabled, then switch over to the Mech Armor sprites, below is my current attempt to do so. I've tried this in both data and Data-updates stage.
It obviously doesn't work, the animations at least, and with my mediocre coding talents I'm stuck. If anyone could provide some help, or even a solution, I'd be grateful.
Thanks in advance to any help given.
I'm currently using the following to use Vanilla sprites for my armors. This is done in the Prototype stage.
Code: Select all
for _, animation in ipairs(data.raw["character"]["character"]["animations"]) do
if animation.armors then
for _, armor in ipairs(animation.armors) do
if armor == "power-armor-mk2" then
animation.armors[#animation.armors + 1] = "pamk3-pamk3"
animation.armors[#animation.armors + 1] = "pamk3-pamk4"
break
end
if armor == "light-armor" then
animation.armors[#animation.armors + 1] = "pamk3-lvest"
break
end
if armor == "heavy-armor" then
animation.armors[#animation.armors + 1] = "pamk3-hvest"
break
end
end
end
end
Code: Select all
if settings.startup["pam3-ma2"].value and mods["space-age"] then
local simulations = require("__space-age__.prototypes.factoriopedia-simulations")
data.raw["armor"]["pamk3-pamk4"].factoriopedia_simulation = simulations.factoriopedia_mech_armor
data.raw["armor"]["pamk3-pamk4"].provides_flight = true
data.raw["armor"]["pamk3-pamk4"].takeoff_sound = {filename = "__space-age__/sound/entity/mech-armor/mech-armor-takeoff.ogg", volume = 0.2, aggregation = {max_count = 2, remove = true}}
data.raw["armor"]["pamk3-pamk4"].landing_sound = {filename = "__space-age__/sound/entity/mech-armor/mech-armor-land.ogg", volume = 0.3, aggregation = {max_count = 2, remove = true, count_already_playing = true}}
data.raw["armor"]["pamk3-pamk4"].flight_sound = {sound={filename = "__space-age__/sound/entity/mech-armor/mech-armor-flight.ogg", volume = 0.2}}
for _, animation in ipairs(data.raw["character"]["character"]["animations"]) do
if animation.armors then
for _, armor in ipairs(animation.armors) do
if armor == "mech-armor" then
animation.armors[#animation.armors + 1] = "pamk3-pamk4"
break
end
end
end
end
end
Thanks in advance to any help given.