Page 1 of 1

Manually construct ghosts or blueprints

Posted: Sun Aug 16, 2015 2:26 am
by erisco
Blueprints change the mode of play from focus on individual machines to focus on systems of machines. The power of a single click is increased.

Fond of that kind of play I want to use it earlier in the game. "Start Out Planning" is a simple mod that helps with this (see https://forums.factorio.com/forum/vie ... int#p59770). Having a single blueprint is not quite useful enough, but it is trivial to give yourself more with console commands.

What is missing is a way to construct ghost objects conveniently. This is of course done late game by construction robots. Even if you use "Start Out Planning", in the early game after placing a blueprint you must select each item individually from your inventory, orient it correctly, and place it on the map. This amounts to a lot of busywork relative to the spirit of what blueprints should offer.

A mod could remedy this shortcoming. On a mouse click or key press, the mod attempts to place ghost objects within the player's normal placement radius, using items from the player's inventory. If the player does not have the item in their inventory the mod logs a failure message indicating the object type -- for example "No 'Assembling Machine 2' in your inventory".

I am interested to hear from experienced Factorio modders of how difficult this mod may be to implement -- and some pointers to which parts of the API I need to study. If it is a relatively easy task then I may make this mod myself.

Re: Manually construct ghosts or blueprints

Posted: Sun Aug 16, 2015 3:21 am
by Adil
So, what you want is basically building blueprints in flesh right away and without robot?
Well, apart from separate key, that's doable. (The best that can be done about a key is slapping another monstrous button onto player's gui.)

There are events on_built_entity and on_put_item which may be used to detect the blueprint placement.
Some understanding of the game object (surfaces, players, forces) would be needed to make it multiplayer-friendly.
surface.create_entity, surface.find_entities_filtered and player.remove_item methods are needed to make it work.
(sorry for a brief answer, gtg.)

Re: Manually construct ghosts or blueprints

Posted: Sun Aug 16, 2015 9:42 am
by erisco
I had a poke around the API documentation and was pleasantly surprised to find it in order. While the API could use some more functionality here and there, I was able to put together this mod in only a few hours. Props to the Factorio team!

Here is the link: https://forums.factorio.com/forum/vie ... 91#p101191