Limit Modded Module to specific entity

Place to get help with not working mods / modding interface.
Post Reply
Suf
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Fri Jul 10, 2020 5:07 am
Contact:

Limit Modded Module to specific entity

Post 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.

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: Limit Modded Module to specific entity

Post 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.
Image

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Limit Modded Module to specific entity

Post by darkfrei »

But you can check the event and extract the module, remove from entity and place on the ground.

Suf
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Fri Jul 10, 2020 5:07 am
Contact:

Re: Limit Modded Module to specific entity

Post 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.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Limit Modded Module to specific entity

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Suf
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Fri Jul 10, 2020 5:07 am
Contact:

Re: Limit Modded Module to specific entity

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

Post Reply

Return to “Modding help”