Page 1 of 1
Problem adding player sprite
Posted: Fri May 19, 2017 9:01 am
by jimmy_1283
So I have this mod:
viewtopic.php?f=93&t=47506
And I want my armor to use the power armor mk2 sprite, which I achieved by way of modifying demo-entities.lua, the problem is I essentially copied the whole file and applied my changes that way, which apparently breaks any mod that alters the base character stats, or at least inventory size.
Specifically I modified line 612 too look like this:
611 -- modular armors are not in the demo
612 armors = data.is_demo and {} or {"modular-armor", "power-armor", "power-armor-mk2", "power-armor-mk3"},
I'm a novice at best and am basically fumbling in the dark here, any help would be greatly appreciated.
Re: Problem adding player sprite
Posted: Fri May 19, 2017 9:42 am
by kikker450
Wait you're replacing complete base game files? I recommend a simple modding tutorial on the basics on how to add stuff in general:
https://wiki.factorio.com/Tutorial:Modd ... al/Gangsir.
Re: Problem adding player sprite
Posted: Sun May 21, 2017 12:37 pm
by jimmy_1283
I've been over every resource I can find and still no luck, that tutorial was no help either, as it doesn't even begin to cover what I need to do.
If anyone could point me in the right direction I'd appreciate it, at the moment I have to choose between having the player sprite show the armor or allow other mods to change the players inventory size.
Re: Problem adding player sprite
Posted: Sun May 21, 2017 2:59 pm
by kikker450
jimmy_1283 wrote:
I've been over every resource I can find and still no luck, that tutorial was no help either, as it doesn't even begin to cover what I need to do.
If anyone could point me in the right direction I'd appreciate it, at the moment I have to choose between having the player sprite show the armor or allow other mods to change the players inventory size.
Found it for you: there is a piece of code on how the devs do it in Factorio\data\base\prototypes\entity\entities.lua
Code: Select all
for _, animation in ipairs(data.raw["player"]["player"]["animations"]) do
if animation.armors then
for _, armor in ipairs(animation.armors) do
if armor == "light-armor" then
animation.armors[#animation.armors + 1] = "heavy-armor"
break
end
end
end
end
so to do it for your mod you just have to change the two strings referring to light-armor and heavy-armor
Code: Select all
for _, animation in ipairs(data.raw["player"]["player"]["animations"]) do
if animation.armors then
for _, armor in ipairs(animation.armors) do
if armor == "power-armor-mk2" then
animation.armors[#animation.armors + 1] = "power-armor-mk3"
break
end
end
end
end
already tested it, you can just copy paste this in your power-armor-mk3 file. So you don't have to replace the whole demo-entities file anymore. Normally the animation is included with the entity so I proposed to simply deep-copy power-armor-Mk2 and change it's requirements and stats, but since all of the animations of power-armors are the same you have to add it to the list to be animated.
Re: Problem adding player sprite
Posted: Sun May 21, 2017 5:31 pm
by jimmy_1283
Oh thank you so much for this, I knew there was a deep copy method, but couldn't for the life of me figure out how to apply it here, many mod authors will be happy to have this info I reckon, lol.