Page 1 of 1
How to change a prototype value in terms of mod settings
Posted: Sun Nov 03, 2019 12:43 pm
by TelemakFactorio
Hi,
I am trying to change a generator efficiency based on a setting for my mod (let's say the setting is named 'new_generator_efficiency).
Is it only possible ?
I know exactly how to make a setting, but I don't know how to apply it to my generator prototype.
I imagine the solution will be to get the settign value from a var then to put it in my data:extend ?
Cheers,
Tele
Re: How to change a prototype value in terms of mod settings
Posted: Sun Nov 03, 2019 12:45 pm
by darkfrei
Re: How to change a prototype value in terms of mod settings
Posted: Sun Nov 03, 2019 1:32 pm
by TelemakFactorio
Thanks, but I asked because in data.lua
local output = settings.startup["reasonable-wind-turbine-mk1-output"].value
throw this
"attempt to index index field reasonable-wind-turbine-mk1-output, a nil value
I have required the settings.lua file in data.lua which contains my setting definition :
data:extend({
{
type = "int-setting",
name = "reasonable-wind-turbine-mk1-output",
setting_type = "startup",
default_value = 20,
minimum_value = 1,
maximum_value = 1000,
order = "rwtmo1a"
},
{
type = "string-setting",
name = "reasonable-wind-turbine-mk1-output-unit",
setting_type = "startup",
default_value = "KW",
allowed_values = {"KW", "MW"},
order = "rwtmo1b"
}
})
Re: How to change a prototype value in terms of mod settings
Posted: Sun Nov 03, 2019 2:01 pm
by Pi-C
Have a look at the code of
this mod! Basically, it's just a collection of settings to change values in prototypes from another mod. Should be pretty much what you need.
Re: How to change a prototype value in terms of mod settings
Posted: Sun Nov 03, 2019 6:01 pm
by TelemakFactorio
Oh, I get the solution wiht this mod code.
I missed I needded a settings.lua file and other minor defects.
Thanks
Re: How to change a prototype value in terms of mod settings
Posted: Sun Nov 03, 2019 6:35 pm
by Pi-C
Glad I could help …
Re: How to change a prototype value in terms of mod settings
Posted: Mon Nov 04, 2019 6:27 am
by darkfrei
Re: How to change a prototype value in terms of mod settings
Posted: Mon Nov 04, 2019 5:53 pm
by Hiladdar
I have several mods with practical examples, where settings file is read, and based on the settings the entity, recipe, or technology costs are dynamically defined in data.lua. The ones which best demonstrate it would be my manufacturing, electrical, and mining mods.
https://mods.factorio.com/mod/Hiladdar_Mining (note, when I published this mod, mining power was still part of the game)
https://mods.factorio.com/mod/Hiladdar_Manufacturing
https://mods.factorio.com/mod/Hiladdar_Electrical
Hiladdar
Re: How to change a prototype value in terms of mod settings
Posted: Thu Nov 28, 2019 6:50 pm
by TelemakFactorio
Thanks everybody for your ideas.