Page 1 of 1

[0.12.33] scale can be set to a table

Posted: Sat May 14, 2016 12:06 am
by keyboardhack
When setting the scale of an animation like this

Code: Select all

{
      filename = "__base__/graphics/entity/steam-engine/steam-engine-horizontal.png",
      width = 246,
      height = 137,
      frame_count = 32,
      line_length = 8,
      shift = {1.34, -0.06},
      scale = {r=0.545, g=0.271, b=0.075, a=1.0},
      tint = {r=0.545, g=0.271, b=0.075, a=1.0}
}
an error would be expected because the scale is a number and not a table but the game doesn't throw an error as expected. This is a problem when other mods try to use the scale value as it's now a table istead of a number.

made a little mod that sets the scale to a table.
scaleBug_1.0.0.zip
(1.12 KiB) Downloaded 81 times

Re: [0.12.33] scale can be set to a table

Posted: Sat May 14, 2016 1:25 am
by Rseding91
That's just how Lua works. We don't do validation of any of the data in the data.raw table until all mods are finished processing. Yell at whoever puts bad data in it :)

Re: [0.12.33] scale can be set to a table

Posted: Sat May 14, 2016 4:57 am
by keyboardhack
Rseding91 wrote:That's just how Lua works. We don't do validation of any of the data in the data.raw table until all mods are finished processing. Yell at whoever puts bad data in it :)
That makes sense when loading other mods afterwards, but shouldn't factorio throw an error if scaleBug was used as a standalone mod? As it's right now the mod is loaded without a problem but as i understand it factorio should complain about the incorrect type.

If i try to set the name of an entity equal an table then i get this error when loading the game:

Code: Select all

PANIC: unprotected error in call to LUA API (bad argument #-1 (string expected, got table))
Shouldn't i expect something similar when the scale is set to a table?

Re: [0.12.33] scale can be set to a table

Posted: Sat May 14, 2016 5:10 am
by Rseding91
"scale" is not a valid property that animations use so it never gets read on the game engine side.

Re: [0.12.33] scale can be set to a table

Posted: Sat May 14, 2016 5:20 am
by keyboardhack
I am pretty sure it's a valid property. Just so we are on the same page i am talking about this property https://wiki.factorio.com/index.php?tit ... tion#scale.
I have used it myself in mods so i know it changes the scale of an object.

Re: [0.12.33] scale can be set to a table

Posted: Sat May 14, 2016 5:27 am
by Rseding91
keyboardhack wrote:I am pretty sure it's a valid property. Just so we are on the same page i am talking about this property https://wiki.factorio.com/index.php?tit ... tion#scale.
I have used it myself in mods so i know it changes the scale of an object.
Ah, I was looking at a different type of animation.

The scale in that instance ends up as a table meaning it doesn't show up when the sprite parameters look for "scale" as a property. As a result it uses the default value of 1.