Page 1 of 1

modifying another mod's control.lua values to a variable

Posted: Wed Oct 11, 2023 8:01 pm
by inick
I'm not going to be vague trying to hide what I am after. I'm also not going to hide this is my first actual mod file (NOT yet posted). I have been using the memory-storage mods (one for items, one for fluids) and have made my own personal edits in fluid-memory-storage that work just fine. I make three edits in the mod to suit my playstyle, and think since I'm going to invite others to multiplay with me, maybe I should make an addon to fluid-memory-storage.

fluid-memory-storage_1.4.6/control.lua:149 defines

Code: Select all

comfortable = 0.5 * entity.fluidbox.get_capacity(1)
I want to change only

Code: Select all

0.5
to

Code: Select all

0.85
in my addon, but since it's in control.lua (runtime), how can I get my data-updates.lua to modify this value?
I've got the other two (of three) to successfully modify with my addon, but I can't google my way to update the control.lua value of someone else's mod.

Can someone give me a clue?

Re: modifying another mod's control.lua values to a variable

Posted: Wed Oct 11, 2023 10:56 pm
by Silari
You can't. Every mod has it's own LUA sandbox, and they can't interact with each other that way. Really the only way a mod can interact with another one is by requiring files from a mod to copy some of its stuff, or by using an interface that a mod defined which is then called.

Re: modifying another mod's control.lua values to a variable

Posted: Wed Oct 11, 2023 11:15 pm
by inick
Ohh - the familiar "getters" and "setters" functions in a source file are familiar.

the concept of the sandbox per mod was vague because you can alter data.raw during the data phase on game init. Thought I could alter anything, just a matter of a dot in the right place or brackets and quotes!

I'll consider my options, and keep an eye on this thread too.


Thanks for the reply

Re: modifying another mod's control.lua values to a variable

Posted: Thu Oct 12, 2023 3:47 am
by FuryoftheStars
Yeah, control.lua is pretty isolated. The best way would be to see if they can move that constant to a setting. Then you could modify it without the need of a mod. :)

For reference, too, this is not (so much of) an issue with data and setting files. :twisted:

Re: modifying another mod's control.lua values to a variable

Posted: Thu Oct 12, 2023 4:11 am
by inick
Well, I had a big brain moment tonight. I feel accomplished.

I just used Factorio's own fluid dynamics + the default value in their control.lua to influence my own wishes on it. I got it working. Now, I only need two edits to make the mod fit my playstyle. Actually was a better turnout than what I was using previously.

I don't need to edit their control.lua anymore, I don't need to pack around the files, now I just need to download my own mod to everywhere.


(for visitors.. fluid_box["base_level"] = 0.35 plus the original value 0.5 = my desired 0.85 (85%) pipe fill when using the mods)