If you look at http://lua-api.factorio.com/latest/Conc ... Ingredient you see amount :: uint: Amount of the item.
But when you execute this,
/c game.player.print(game.player.force.recipes['processing-unit'].ingredients[3].amount)
The output is 0.5 for the sulfuric-acid to make a processing unit.
How can an uint have the value 0.5?
Another thing, related to this, in http://lua-api.factorio.com/latest/Conc ... ml#Product
amount :: float (optional): Amount of the item or fluid to give. If not specified, amount_min, amount_max and probability must all be specified.
amount_min :: uint (optional): Minimal amount of the item or fluid to give. Has no effect when amount is specified.
amount_max :: uint (optional): Maximum amount of the item or fluid to give. Has no effect when amount is specified.
probability :: double (optional): A value in range [0, 1]. Item or fluid is only given with this probability; otherwise no product is produced. Has no effect when amount is specified.
Are the types really float, uint and double?
So I'm not sure what to believe at the moment.
My guess is I can interpret all numbers as double, because all 32 bits integers fit in a double without loss and for my goal that's probably enough.
My question to the devs, isn't the lua-api.factorio.com generated from the source code?
Errors on lua-api.factorio.com?
Re: Errors on lua-api.factorio.com?
Internally "item" and "fluid" are very different, see the messy definitions in data\base\prototypes\recipe. This means they have different tables.
type :: string: "item"
name :: string: Prototype name of the required item
amount :: uint: Amount of the item.
type :: string: "fluid"
name :: string: Prototype name of the required fluid
amount :: float: Amount of the fluid.
type :: string: "item"
name :: string: Prototype name of the required item
amount :: uint: Amount of the item.
type :: string: "fluid"
name :: string: Prototype name of the required fluid
amount :: float: Amount of the fluid.
Re: Errors on lua-api.factorio.com?
Thanks, I can see the differences in structures.
As far as I can see the structure in game.player.force.recipes looks all the same, or at least the same enough for me.
I've dumped the data for all recipes, technologies, entities, items and fluids to try to make my own calculator tool.
All the tools I've found so far, helmod, factoratio, etc, aren't doing exactly what I want and I've run into the end of my excel skills. Now it's time for C# skills![Smile :)](./images/smilies/icon_e_smile.gif)
I've changed my dump script to temporarily make invalid json and dump the data type lua reports for non string/table/array data and I only see boolean and number so I'll just use double for all numbers.
As far as I can see the structure in game.player.force.recipes looks all the same, or at least the same enough for me.
I've dumped the data for all recipes, technologies, entities, items and fluids to try to make my own calculator tool.
All the tools I've found so far, helmod, factoratio, etc, aren't doing exactly what I want and I've run into the end of my excel skills. Now it's time for C# skills
![Smile :)](./images/smilies/icon_e_smile.gif)
I've changed my dump script to temporarily make invalid json and dump the data type lua reports for non string/table/array data and I only see boolean and number so I'll just use double for all numbers.