[0.15.21] "layers" Syntax not erroring when improperly used.

Bugs that are actually features.
Unbr34k4bl3
Burner Inserter
Burner Inserter
Posts: 11
Joined: Thu May 18, 2017 2:09 pm
Contact:

[0.15.21] "layers" Syntax not erroring when improperly used.

Post by Unbr34k4bl3 »

What did you do?
Was working on my mod. Tried making my own entity.

Code: Select all

data:extend({

  {
    type = "assembling-machine",
    name = "helium-condenser",
    icon = "__loopx__/graphics/icons/items/lx-superconductor.png",
    flags = {"placeable-neutral", "player-creation"},
    minable = {hardness = 0.2, mining_time = 0.5, result = "lx-superconductor"},
    max_health = 100,
    corpse = "small-remnants",
    collision_box = {{-1.4, -1.4}, {1.4, 1.4}},
    selection_box = {{-1.5, -1.5}, {1.5, 1.5}},
    vehicle_impact_sound =  { filename = "__base__/sound/car-wood-impact.ogg", volume = 1.0 },
    layers =
	{
        filename = "__loopx__/graphics/entity/helium-condenser/helium-condenser.png",
        width = 127,
        height = 127,
        shift = {0.84, -0.09},
    },
    crafting_categories = {"crafting"},
    crafting_speed = 2.1,
    energy_source =
    {
      type = "electric",
      usage_priority = "secondary-input",
      emissions = 0.03 / 3.5
    },
    energy_usage = "200kW",
    ingredient_count = 4,
    module_specification =
    {
      module_slots = 5,
      module_info_icon_shift = {0, 0.5},
      module_info_multi_row_initial_height_modifier = -0.3
    },
    allowed_effects = {"consumption", "speed", "productivity", "pollution"}
  }

})

What happened?
The game returned me an invisible entity graphic. Without giving me an error that it won't load the graphic. Or that I used the wrong syntax or type/instead of "layers" that I should use "animation".

What did you expect to happen instead?
Expected the entity to show the graphics (Looked at some internal entities within demo-entities.lua) and worked my way from there. As layers was used by other mods aswell as in the base game. Expected to get an error of some sort if I did it wrongly which I didn't get.

Write down the steps to reproduce the bug if you know them.
1. Make a mod and the necessities. (I can provide my mod in it's current stage if necessary for testing, Sidenote -> Has a lot of dependencies on other mods)
2. Make an entity with the code above with proper pictures and proper sizes (etc.)
3. The game won't load the graphic and return an invisible entity. And will not return an error.

Does it happen always, once, or sometimes?
Always.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15638
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.15.21] "layers" Syntax not erroring when improperly used.

Post by Rseding91 »

The way the prototypes operate they expect values to exist in some given key for a prototype and when they don't it treats them as "not defined". Properties the prototype isn't looking for are simply ignored.

In this case when you give "layers" the assembling machine isn't looking for that key so it ignores it. Also since you didn't define "animation" it treats it as "not defined" and gives the machine no animation (it's an optional value).

The end result is: if you give the prototype values it isn't using and the ones you meant to give it are optional then the game has no way to know if you actually meant to not define the thing or if it was a mistake.

So, it operates as it does now: it doesn't give an error and assumes that you meant to do what you did.
If you want to get ahold of me I'm almost always on Discord.
Unbr34k4bl3
Burner Inserter
Burner Inserter
Posts: 11
Joined: Thu May 18, 2017 2:09 pm
Contact:

Re: [0.15.21] "layers" Syntax not erroring when improperly used.

Post by Unbr34k4bl3 »

Rseding91 wrote:The way the prototypes operate they expect values to exist in some given key for a prototype and when they don't it treats them as "not defined". Properties the prototype isn't looking for are simply ignored.

In this case when you give "layers" the assembling machine isn't looking for that key so it ignores it. Also since you didn't define "animation" it treats it as "not defined" and gives the machine no animation (it's an optional value).

The end result is: if you give the prototype values it isn't using and the ones you meant to give it are optional then the game has no way to know if you actually meant to not define the thing or if it was a mistake.

So, it operates as it does now: it doesn't give an error and assumes that you meant to do what you did.
Alright then. Sorry for taking away your time. Rather post it to make sure. Thanks for the explanation!
Rseding91
Factorio Staff
Factorio Staff
Posts: 15638
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.15.21] "layers" Syntax not erroring when improperly used.

Post by Rseding91 »

Unbr34k4bl3 wrote:
Rseding91 wrote:The way the prototypes operate they expect values to exist in some given key for a prototype and when they don't it treats them as "not defined". Properties the prototype isn't looking for are simply ignored.

In this case when you give "layers" the assembling machine isn't looking for that key so it ignores it. Also since you didn't define "animation" it treats it as "not defined" and gives the machine no animation (it's an optional value).

The end result is: if you give the prototype values it isn't using and the ones you meant to give it are optional then the game has no way to know if you actually meant to not define the thing or if it was a mistake.

So, it operates as it does now: it doesn't give an error and assumes that you meant to do what you did.
Alright then. Sorry for taking away your time. Rather post it to make sure. Thanks for the explanation!
No problem. We don't have any documentation on the prototypes and how they work at this point so it can be confusing for someone just starting with it. It's something we want to improve on but with the rate the prototypes change any non-automated documentation would get outdated almost immediately.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Not a bug”