Problem adding player sprite

Place to get help with not working mods / modding interface.
Post Reply
jimmy_1283
Long Handed Inserter
Long Handed Inserter
Posts: 70
Joined: Mon Oct 17, 2016 12:55 pm
Contact:

Problem adding player sprite

Post 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.

kikker450
Inserter
Inserter
Posts: 30
Joined: Fri May 05, 2017 9:07 am
Contact:

Re: Problem adding player sprite

Post 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.

jimmy_1283
Long Handed Inserter
Long Handed Inserter
Posts: 70
Joined: Mon Oct 17, 2016 12:55 pm
Contact:

Re: Problem adding player sprite

Post by jimmy_1283 »

kikker450 wrote: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.
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.

kikker450
Inserter
Inserter
Posts: 30
Joined: Fri May 05, 2017 9:07 am
Contact:

Re: Problem adding player sprite

Post 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.

jimmy_1283
Long Handed Inserter
Long Handed Inserter
Posts: 70
Joined: Mon Oct 17, 2016 12:55 pm
Contact:

Re: Problem adding player sprite

Post 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.

Post Reply

Return to “Modding help”