Module Inserter


Mass insert modules into machines with construction bots

Utilities
2 months ago
0.13 - 1.1
140K

g Call your mod from my mod?

4 years ago

Hi, I'm making my first mod, which auto-layouts a field of oil-wells. I'm considering auto-adding modules to the placed pumpjacks as well. Considering you already have a bunch of logic to determine which modules should be inserted for which kind of building, it might be great if I could rely on your mod for that instead.

The homework I've done so far led me to LuaRemote calls: https://lua-api.factorio.com/latest/LuaRemote.html
So the factorio API seems to play ball on this aproach I have in mind.

And I noticed in your source you already exposed a bit of interfacing: https://github.com/Choumiko/ModuleInserter/blob/ae33156462e3e372b42dd29de73226a96d9dd889/control.lua#L730
But it seems you don't have any exposed functions that are meaningful for my mod. If they exist, could you point me to them? If they don't, would you be interested to add them? Or would you accept a pull request if I added it myself?

From my point of view, my mod's scope ends with placing the ghosts. Ideally I would pass the placed ghost as argument to your mod somehow, and your mod takes over the module insertion from there. Alternatively, I would be interested in querying your mod which modules to add and I could insert them myself, but at least it would abide by the settings the users have made in your mod.

4 years ago
(updated 4 years ago)

I've added an interface to get a table with the current module configuration from my mod:
remote.call("mi", "get_module_config", player_index) https://github.com/Choumiko/ModuleInserter/blob/master/control.lua#L752
It should return a table like:

{
    ["oil-well"] = {
        ["speed-module-1"] = 1,
        ["speed-module-2"] = 1},
    ["beacon"] = {}
}

or an empty table if the player hasn't set anything yet or false if there was no config. Empty tables after an entity name mean that my mod would remove all modules from it, shouldn't be interesting for your mod.

My mod completely ignores ghosts (which maybe it shouldn't) so that's currently the easiest solution for me.
Feel free to submit a pull request should you need anything else to make it work.

4 years ago

Great! Thanks for this. :-)

4 years ago

I'm surprised how painless that went. Works like a charm :-) Thanks again!

New response