Page 1 of 1

Limit Modded Module to specific entity

Posted: Mon Apr 12, 2021 1:35 pm
by Suf
Hi

There was a very similar topic about this question viewtopic.php?f=25&t=31074&hilit=modules but it didn't help me out that much.

i've made a module which has the "speed" effect i also added "module-category" for it and yeah it appears under the allowed modules for the desired entity,but at the same time it appears under the allowed modules for every entity that supports the "speed" effect and the limitation is for recipe which could be good solution for it,but the problem here it's still an allowed module for other entities.

So the question here how to actually hide/limit the module for the other entities?

Thanks in Advance.

Re: Limit Modded Module to specific entity

Posted: Mon Apr 12, 2021 4:28 pm
by Deadlock989
You can't. A module will go into any machine that allows the effects assigned to the module in the machine's module_specification. For assembling machines and furnaces you can use limitations and limitations_blacklist but those are based on recipes and so there is no way of preventing a specific module from being used in machines which don't work with recipes, e.g. labs and drills, except for completely banning all the effects that module has from the labs and drills.

Re: Limit Modded Module to specific entity

Posted: Mon Apr 12, 2021 5:07 pm
by darkfrei
But you can check the event and extract the module, remove from entity and place on the ground.

Re: Limit Modded Module to specific entity

Posted: Mon Apr 12, 2021 5:35 pm
by Suf
Deadlock989 wrote:
Mon Apr 12, 2021 4:28 pm
You can't. A module will go into any machine that allows the effects assigned to the module in the machine's module_specification. For assembling machines and furnaces you can use limitations and limitations_blacklist but those are based on recipes and so there is no way of preventing a specific module from being used in machines which don't work with recipes, e.g. labs and drills, except for completely banning all the effects that module has from the labs and drills.
Yeah banning all effects sound like a bad idea.
darkfrei wrote:
Mon Apr 12, 2021 5:07 pm
But you can check the event and extract the module, remove from entity and place on the ground.
Can you explain further? I don't really get what are you trying to illustrate.

Re: Limit Modded Module to specific entity

Posted: Mon Apr 12, 2021 8:02 pm
by eradicator
Suf wrote:
Mon Apr 12, 2021 5:35 pm
darkfrei wrote:
Mon Apr 12, 2021 5:07 pm
But you can check the event and extract the module, remove from entity and place on the ground.
Can you explain further? I don't really get what are you trying to illustrate.
There is no event for module changes and devs have stated multiple times that they don't intend to change that. You'd have to hack into every possible way a machine/module can be placed and do a bunch of checks and then try to *undo* the placement. That's pretty much the maximum complexity an ugly hack can get, and it'll never be a smooth experience for the user even if you get all the possible bits right.

The closesed you can get to a smooth experience would be to spam invisible beacons with one tile range onto the modded entity and then attach a custom relative gui to the machines gui and handle the module<->gui interactions yourself. And that still messes up the entity tooltip effect count and produces weird blueprints.

Re: Limit Modded Module to specific entity

Posted: Mon Apr 12, 2021 9:52 pm
by Suf
eradicator wrote:
Mon Apr 12, 2021 8:02 pm
Suf wrote:
Mon Apr 12, 2021 5:35 pm
darkfrei wrote:
Mon Apr 12, 2021 5:07 pm
But you can check the event and extract the module, remove from entity and place on the ground.
Can you explain further? I don't really get what are you trying to illustrate.
There is no event for module changes and devs have stated multiple times that they don't intend to change that. You'd have to hack into every possible way a machine/module can be placed and do a bunch of checks and then try to *undo* the placement. That's pretty much the maximum complexity an ugly hack can get, and it'll never be a smooth experience for the user even if you get all the possible bits right.

The closesed you can get to a smooth experience would be to spam invisible beacons with one tile range onto the modded entity and then attach a custom relative gui to the machines gui and handle the module<->gui interactions yourself. And that still messes up the entity tooltip effect count and produces weird blueprints.
The first section sounds impossible for me and the second one have potential to mess up player's blueprints;i guess i'll just limit the recipe for the modules then :lol: