Krastorio 2 Wind Turbine (ZarSasha's Fork)


A stand-alone, configurable version of the wind turbine from the overhaul mod "Krastorio 2" by raiguard. Forked from "Krastorio 2 Wind Turbine" by mad_engineer. The mod has been adapted for Space Age.

Content
3 months ago
2.0
4.78K
Power

i Mod exposure for turbine parameters? [DONE]

7 months ago

I'm thinking of creating a mod that has a windy planet without a lot of sun, and making the turbine effective there isn't really possible without forking the mod again because update_turbine_parameters is local to this mod's control.lua, and I'd need to alter it to change the calculation. I think just making the function global (so other mods can redefine what it does to the passed entity) would do the trick.

7 months ago

I can try and look into that. I am guessing that what I actually need to do, is create a remote interface for the script, so that your mod can call it. I haven't tried this before, so we will have to see what I come up with and then test it!

7 months ago

Turns out this is really complicated (mind you, I am not a real programmer).

Mods are exposed to global variables of the base game, but they can't see those of each other. Functions can't be shared through a storage table, and I am still unsure about the usefulness of the remote interface. Could you explain what kind of solution you have in mind? How would you go about "redefining" the function? Is there a normal way of doing this?

For now, I have created a functioning prototype that allows wind power on a planet to be overridden by adding a percentage value along with the planet ID to a comma-separated list in startup settings. One could for example write 75:gleba,30:fulgora,10:aquilo in the field. Does this seem useful to you?

7 months ago
(updated 7 months ago)

What I ended up doing for Dredgeworks to add similar overrides, in 0.7.4, was having a global table "do_not_submerge" where the key is the name of a resource, and the value is "true" to skip it; going for that approach with this, the key would be the name of a planet, the value would be the produced power, and the turbines would set up their power production factor based on that value if it exists, or solar power if it doesn't.

I could definitely program such a thing myself, if you're interested in contribution. I wasn't able to find you over on the Discord for Factorio, but we could potentially correspond there (Kusibu).

7 months ago

That's a really simple solution! So any mod would just have to declare this one as at least an optional dependency, and then refer to a global variable within the _global.lua file, which I am guessing has to be named exactly like that. The reference might then be something like k2wt_override_wind_power["nauvis"] = 115 in order to update that table. Have I understood it correctly?

As for Discord, I don't know why you couldn't find me there (I have the username ZarSasha). We could in principle continue discussion there, but I think I have already figured out how I want to change the mod! I will continue with my work.

7 months ago

Sounds like you get it, yep.

7 months ago

Super cool! I am happy to have learned something new.

7 months ago

Just uploaded v1.2.0! Let me know if it works the way you wanted it to.

7 months ago

It'll probably be a while! Hopefully even if I don't manage to figure out what I'm up to, other folks will find the change useful.

7 months ago

Of course! I will likely refine the code further, to ensure it function.

7 months ago

As of v1.2.2, the mod actually works with other mods as intended. It turned out to be quite a lot more complicated when the runtime stage is involved.

New response