Do Robots Build Automatic Trains?

by Qon

Makes blueprinted trains start in automatic mode, automatically. So now you don't have to switch them from manual mode manually. With 'Recursive Blueprints' mod you can now completely automate scaling your train force!

Tweaks
3 years ago
0.17 - 1.1
9.79K
Trains

i Add blueprint option to automate trains

5 years ago

It would be nice if blueprints had an extra checkmark at the top to automate the trains and that copying trains would copy their automatic status too.

5 years ago

I'm pretty sure it's not possible to modify the actual blueprint GUI. A button could appear outside the blueprint window while a blueprint window is open though, I've seen mods that do that.

But I'm not sure if there's ever any reason to have the trains start in manual mode. I'm not going to add that feature if no one will ever touch it. Can you tell me a scenario where you would want to disable the automatic behaviour?

4 years ago

I might want to place a train but change the schedule. With it always being on automatic the train will drive away.

4 years ago
(updated 4 years ago)

I would probably cut out a rail piece in front of the train to workaround this. But yes I guess that is a legitimate use case where the workaround would ideally not have to be used (or might have other negatives). I'm not really sure how to actually save this setting in the blueprint though. The toggle button itself could appear while editing or placing the blueprint dynamically, other mods do that so I could read their code to get a running start on how Factorio's GUI api works. And they are doing pretty much the same thing. BP alignment mod might actually save some data in the blueprint somehow so I could use that mod to inform me on that too.

Kinda wish the existing GUI and blueprints themselves were more moddable so we don't have to do all these weird workarounds to implement features that would otherwise be a line of code and now is probably hours of work...

Edit: And I need some way to store information in the ghosts as well, and some way to recognise which blueprint was used to place the ghosts, even when placed by script like from Recursive Blueprints. Does Lua have WeakMaps, and if so can they be stored in the global table? Those wouldn't work for blueprints when the blueprints are stringified or transfered between games though. But for other things that could be a solution. Mods usually seem to use special invisible items and entities which always seem to break at the slightest mod interaction/instant blueprint etc. And for blueprinting entities a WeakMap wouldn't work, but I don't need to store anything that needs to be copied from the surface to blueprints anyways.

4 years ago

They added a better way to store information with ghosts. I made an example mod for this a while back before they added the new feature. Have to update to the new method at some point.

4 years ago

They == Wube?
Where should I read about it?

4 years ago

The toggle button itself could appear while editing or placing the blueprint dynamically, other mods do that so I could read their code to get a running start on how Factorio's GUI api works. And they are doing pretty much the same thing. BP alignment mod might actually save some data in the blueprint somehow so I could use that mod to inform me on that too.

In my experience adding a button to the blueprint GUI is rather fragile. The initial setup and editing a blueprint are treated differently I think, and if you want to save anything in the blueprint you also save all the changes the user has made. With the new Blueprint Library there also were some problems (in some cases - probably when opening a blueprint from the library or maybe from nested books - the alignment GUI didn't open) but I didn't really look into that because the alignment mod is mostly obsolete now anyway.

See e.g. https://github.com/steffen-kiess/factorio-BlueprintAlignment/blob/41149648214978d9d4ec36ee58b35aa6a1dcb2be/gui.lua#L196, there is some fun stuff like reopening the blueprint UI (and when this was called during the initial setup then it will switch to the edit mode here).

Also if there are multiple mods doing this kind of stuff they can break each other.

Kinda wish the existing GUI and blueprints themselves were more moddable so we don't have to do all these weird workarounds to implement features that would otherwise be a line of code and now is probably hours of work...

Yes, proper support from the game would make this much easier. You also can always use a hack like a string in the blueprint title, then you don't need any UI at all. (But I don't know whether that will work with Recursive Blueprints).

Edit: And I need some way to store information in the ghosts as well, and some way to recognise which blueprint was used to place the ghosts, even when placed by script like from Recursive Blueprints. Does Lua have WeakMaps, and if so can they be stored in the global table? Those wouldn't work for blueprints when the blueprints are stringified or transfered between games though. But for other things that could be a solution. Mods usually seem to use special invisible items and entities which always seem to break at the slightest mod interaction/instant blueprint etc. And for blueprinting entities a WeakMap wouldn't work, but I don't need to store anything that needs to be copied from the surface to blueprints anyways.

I think the new way to store it are the entity tags https://lua-api.factorio.com/latest/LuaItemStack.html#LuaItemStack.get_blueprint_entity_tags which will then show up as ghost tags: https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.tags

4 years ago

Thanks steffenk! Didn't know about the tags or the tricks used to manipulate GUI.

New response