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
How to change a prototype value in terms of mod settings
- TelemakFactorio
- Long Handed Inserter
- Posts: 53
- Joined: Fri Oct 14, 2016 4:30 pm
- Contact:
- TelemakFactorio
- Long Handed Inserter
- Posts: 53
- Joined: Fri Oct 14, 2016 4:30 pm
- Contact:
Re: How to change a prototype value in terms of mod settings
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"
}
})
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
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.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
- TelemakFactorio
- Long Handed Inserter
- Posts: 53
- Joined: Fri Oct 14, 2016 4:30 pm
- Contact:
Re: How to change a prototype value in terms of mod settings
Oh, I get the solution wiht this mod code.
I missed I needded a settings.lua file and other minor defects.
Thanks
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
Glad I could help …
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Re: How to change a prototype value in terms of mod settings
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
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
- TelemakFactorio
- Long Handed Inserter
- Posts: 53
- Joined: Fri Oct 14, 2016 4:30 pm
- Contact:
Re: How to change a prototype value in terms of mod settings
Thanks everybody for your ideas.