Entity only placeable by hand ?

Place to get help with not working mods / modding interface.
User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1525
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

Entity only placeable by hand ?

Post by binbinhfr »

Hi,

is there a way to force an entity to be position on map only by hand/player action, and disable automatic positionnement by construction bots ?

I want to ensure that this entity will only exist once on the map.

I could use on_robot_built_entity and destory any unwanted entity, but I don't know how to put the item them back to where it was taken from...
And I'm afraid about loops : robots will try to position it forever.
(in the case of on_built_entity, it's easier, because you can put it back into player's inventory or quickbar).
My mods on the Factorio Mod Portal :geek:
Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

Re: Entity only placeable by hand ?

Post by Supercheese »

Yes, you can monitor and disallow placement of the ghost entity (inspecting the contents of the ghost), which should stop any bot-placement. I did this once for Logistics Railway: https://github.com/Suprcheese/Logistics ... ol.lua#L35
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Entity only placeable by hand ?

Post by Nexela »

Something along the lines of this

on_entity_built event -

if entity.name="entity-ghost" and entity.ghost_name="my-entity" then entity.destroy()

will not allow blueprints or shift placing and you don't have to worry about the item since it is just a ghost.

if it is IN a blueprint it will just destroy that ghost when placed
User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1525
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

Re: Entity only placeable by hand ?

Post by binbinhfr »

thx guys ! I'll try this right now.
My mods on the Factorio Mod Portal :geek:
Post Reply

Return to “Modding help”