Thank you, using the log and serpent I was able to update my script more defensively... Taking into account that fields can be nested in difficulty blocks.
My issue has been resolved.
I'm patching an existing mod around furnaces such that craft speed across several tiers of furnaces take into ...
Search found 6 matches
- Fri May 20, 2022 8:53 pm
- Forum: Modding help
- Topic: How to reference base Prototype fields for building other prototypes
- Replies: 10
- Views: 2673
- Fri May 20, 2022 7:02 pm
- Forum: Modding help
- Topic: How to reference base Prototype fields for building other prototypes
- Replies: 10
- Views: 2673
Re: How to reference base Prototype fields for building other prototypes
data.raw.recipe["iron-plate"].energy_required
presents the nil
presents the nil
- Fri May 20, 2022 5:56 am
- Forum: Modding help
- Topic: How to reference base Prototype fields for building other prototypes
- Replies: 10
- Views: 2673
Re: How to reference base Prototype fields for building other prototypes
I've also attempted to establish my "foo" reference in my mod's data-final-fixes.lua to no avail.
- Fri May 20, 2022 5:54 am
- Forum: Modding help
- Topic: How to reference base Prototype fields for building other prototypes
- Replies: 10
- Views: 2673
Re: How to reference base Prototype fields for building other prototypes
energy_required is an optional field which is allowed to be nil during the data stage. If it is still nil at the end, it gets set to the default value of 0.5.
This means you need to check for nil before doing math on it.
local energy = data.raw.recipe["iron-plate"].energy_required or 0.5
data ...
- Fri May 20, 2022 5:53 am
- Forum: Modding help
- Topic: How to reference base Prototype fields for building other prototypes
- Replies: 10
- Views: 2673
Re: How to reference base Prototype fields for building other prototypes
according to data\base\prototypes\recipe.lua:
{
type = "recipe",
name = "iron-plate",
category = "smelting",
energy_required = 3.2,
ingredients = {{"iron-ore", 1}},
result = "iron-plate"
},
I'm attempting to refer to this prototype and specifically the field noted, energy_required.
{
type = "recipe",
name = "iron-plate",
category = "smelting",
energy_required = 3.2,
ingredients = {{"iron-ore", 1}},
result = "iron-plate"
},
I'm attempting to refer to this prototype and specifically the field noted, energy_required.
- Fri May 20, 2022 3:27 am
- Forum: Modding help
- Topic: How to reference base Prototype fields for building other prototypes
- Replies: 10
- Views: 2673
How to reference base Prototype fields for building other prototypes
How does one go about referencing the fields of prototypes found in the base game during the Data stage?
Sample:
local foo = 5 * data.raw.recipe["iron-plate"].energy_required
data.raw.recipe["my-bar"].energy_required = foo + 16
The game errors on bootup stating that i cannot use arithmetic on a ...
Sample:
local foo = 5 * data.raw.recipe["iron-plate"].energy_required
data.raw.recipe["my-bar"].energy_required = foo + 16
The game errors on bootup stating that i cannot use arithmetic on a ...