EntityWithHealthPrototype resistances field is a singular rather than array?

Post Reply
User avatar
Muppet9010
Filter Inserter
Filter Inserter
Posts: 278
Joined: Sat Dec 09, 2017 6:01 pm
Contact:

EntityWithHealthPrototype resistances field is a singular rather than array?

Post by Muppet9010 »

The definition of the resistances field in EntityWithHealthPrototype is the type of Resistances. But looking at this Resistances class its a single object/table, rather than supporting an array of Resistances.
I'm not entirely sure on what the valid options are the, but the example array of tables in the Docs are both flagged as invalid by Sumneko using the TyepDefs.

https://lua-api.factorio.com/latest/pro ... esistances

Note that the Wiki looks to have had the same issue.
Last edited by Muppet9010 on Thu Oct 26, 2023 9:02 am, edited 1 time in total.

computeraddict
Fast Inserter
Fast Inserter
Posts: 111
Joined: Sat Oct 07, 2023 6:44 am
Contact:

Re: EntityWithHealthPrototype resistances field is a singular rather than array?

Post by computeraddict »

From the completely working Space Exploration mod, resistances of the thruster suit are defined like this:

Code: Select all

    resistances = {
      {
        percent = 30,
        type = "physical"
      },
      {
        decrease = 0,
        percent = 30,
        type = "acid"
      },
      {
        decrease = 0,
        percent = 30,
        type = "explosion"
      },
      {
        decrease = 0,
        percent = 60,
        type = "fire"
      }
    }
I don't see any issue with the docs?

User avatar
Muppet9010
Filter Inserter
Filter Inserter
Posts: 278
Joined: Sat Dec 09, 2017 6:01 pm
Contact:

Re: EntityWithHealthPrototype resistances field is a singular rather than array?

Post by Muppet9010 »

The docs list a single object/table of fields. But accepts an array of objects as per your included example.

curiosity
Filter Inserter
Filter Inserter
Posts: 326
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: EntityWithHealthPrototype resistances field is a singular rather than array?

Post by curiosity »

Funny that even the examples from the docs themselves declare an array.

Bilka
Factorio Staff
Factorio Staff
Posts: 3139
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: EntityWithHealthPrototype resistances field is a singular rather than array?

Post by Bilka »

It is indeed an array of the struct. Some array types are documented in a bit of a roundabout way, which can lead to actual array part being overlooked. ArmorPrototype::resistances was also affected. Both are fixed for the next version, thanks for the report.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Post Reply

Return to “Resolved Requests”