(long time reader, first time caller)
I am putting together a mod that uses an entity that is composed of a "base" entity and a number of "child" entities that are created and manipulated when the base entity changes. Took a bit but at this point, things work (blueprinting, shift-pasting, copy-paste etc.). Except the pipette. I can hover over one of the secondary entities and press "Q" and the pipette picks those up (and now I hold an item for this entity, something that should not be possible).
Is there a way for me to mark these entities as "can not be picked up by pipette". I still need them to be user selectable (they connect to wires). I was looking int placeable_by to just return the item of my primary entity but now a robot can construct those secondary entities out of the items for the primary which is not what I want.
I looked at some other mods that do similar things (compakt-circuits) and they have the same problem (I can pick up an IO connector with the pipette tool).
Ideally I can either add something to the entity/item that says "don't allow pickup by the pipette tool" or, when I receive the on_player_pipette event, I veto the actual execution of the pipette action.
Or is the answer just "you found a limitation of the engine, just don't do that "
Grateful for any tips/help.
Vetoing the pipette tool
Re: Vetoing the pipette tool
Why do your secondary entities have associated items at all? Surely you should just be creating the entity and not the item?
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Re: Vetoing the pipette tool
There are a bunch of ways to preempt or diasble pipetting, both via prototype flags and via scripts.
Look at some of my mods for ways to do it! They also handle blueprintable/not blueprintable items.
https://mods.factorio.com/mod/MultipleUnitTrainControl (change MU setting to "Basic", put two locos back to back and then pipette one of them)
https://mods.factorio.com/mod/cargo-ships -- pipette the invisible ship engine or the oil rig power pole.
Look at some of my mods for ways to do it! They also handle blueprintable/not blueprintable items.
https://mods.factorio.com/mod/MultipleUnitTrainControl (change MU setting to "Basic", put two locos back to back and then pipette one of them)
https://mods.factorio.com/mod/cargo-ships -- pipette the invisible ship engine or the oil rig power pole.
My mods: Multiple Unit Train Control, Smart Artillery Wagons
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk
Re: Vetoing the pipette tool
@robot256,
Thanks for the quick response. I looked a bit at the source code you pointed out and it seems to me that this is mostly accomplished by not associating an item with an entity. If there is no item, then the pipette has nothing to pick up.
That would work for me, however, I am using entities that are supposed to connect to the network (power or circuit). And without an item, the connections can not be blueprinted (if I remove the related items from my mod, then the blueprints lose all the wire connections because the blue prints seem to store the items with the connection information). Same applies to cut-and-paste. This is not a problem for any entity that is silently recreated by the primary entity placed (I have some of those and they work fine).
I am currently working through the process of publishing the mod, this may be easier to show than to tell.
Again, thanks for the suggestion.
-h
Thanks for the quick response. I looked a bit at the source code you pointed out and it seems to me that this is mostly accomplished by not associating an item with an entity. If there is no item, then the pipette has nothing to pick up.
That would work for me, however, I am using entities that are supposed to connect to the network (power or circuit). And without an item, the connections can not be blueprinted (if I remove the related items from my mod, then the blueprints lose all the wire connections because the blue prints seem to store the items with the connection information). Same applies to cut-and-paste. This is not a problem for any entity that is silently recreated by the primary entity placed (I have some of those and they work fine).
I am currently working through the process of publishing the mod, this may be easier to show than to tell.
Again, thanks for the suggestion.
-h
Re: Vetoing the pipette tool
@Xorimuth,
thank you for the reply. I am using entities that connect to the network(s) (both power and circuit) and it seems that blueprinting and cut-and-paste require items to maintain the wire connections.
-h
Re: Vetoing the pipette tool
SE seems to do something similar with their spaceship clamps which are a constant combinator and a electric pole.
The electric pole has an placeableby of an se-struct-generic-clamp-east item, but that item has nil for it's place result.
Blueprints handle making the ghosts, and then the mod calls revive on them through the lua in event handlers for:
defines.events.on_entity_cloned
defines.events.on_built_entity
defines.events.on_robot_built_entity
defines.events.script_raised_built
defines.events.script_raised_revive
The electric pole has an placeableby of an se-struct-generic-clamp-east item, but that item has nil for it's place result.
Blueprints handle making the ghosts, and then the mod calls revive on them through the lua in event handlers for:
defines.events.on_entity_cloned
defines.events.on_built_entity
defines.events.on_robot_built_entity
defines.events.script_raised_built
defines.events.script_raised_revive