How to change a prototype value in terms of mod settings

Place to get help with not working mods / modding interface.
User avatar
TelemakFactorio
Long Handed Inserter
Long Handed Inserter
Posts: 53
Joined: Fri Oct 14, 2016 4:30 pm
Contact:

How to change a prototype value in terms of mod settings

Post 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 :D
User avatar
TelemakFactorio
Long Handed Inserter
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

Post 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 :mrgreen:



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"
}
})
Pi-C
Smart Inserter
Smart Inserter
Posts: 1728
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: How to change a prototype value in terms of mod settings

Post 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. :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
User avatar
TelemakFactorio
Long Handed Inserter
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

Post by TelemakFactorio »

Oh, I get the solution wiht this mod code.

I missed I needded a settings.lua file and other minor defects.

Thanks
Pi-C
Smart Inserter
Smart Inserter
Posts: 1728
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: How to change a prototype value in terms of mod settings

Post by Pi-C »

Glad I could help … :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Hiladdar
Fast Inserter
Fast Inserter
Posts: 214
Joined: Mon May 14, 2018 6:47 pm
Contact:

Re: How to change a prototype value in terms of mod settings

Post 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
User avatar
TelemakFactorio
Long Handed Inserter
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

Post by TelemakFactorio »

Thanks everybody for your ideas.
Post Reply

Return to “Modding help”