Page 1 of 1

Copy/paste train schedules as plain text

Posted: Mon Mar 22, 2021 7:04 pm
by Demosthenex
TL;DR
Pressing copy or paste while in the train schedule UI should export/import the train schedule using plain text and the clipboard.

What ?
Borrowing from Path of Exile, in that game highly complex items with statistics and enchantments allow you to hit control-c (copy) with the cursor on an item to get a plain text representation of the item into the clipboard. Other planning tools (ie: Path of Building) allow you to paste that human readable text to create the same item.

I often have quite complex train schedules in Factorio, and the ability to copy the existing schedule and paste it to Notepad, make a few changes, and paste it back would be fantastic. This also avoids adding excess new UI elements into the game. For instance, the following is a circuit controlled mixed item route.

Image
Image

If with my cursor over the schedule, I hit control-c (copy), I'd want the following copied into the clipboard as plain text:

Code: Select all

 - Station: Mixed-C-[Item: Stainless Steel]
   - OR
     - Item count: [Item: Copper Plate] = 0
     - Item count: [Item: Sulfur] = 0
     - Item count: [Item: Niobium Plate] = 0
     - Item count: [Item: Cobalt Extract] = 0
     - Item count: [Item: Ferrochrome] = 0
     - Item count: [Item: Phosphorous Rock] = 0
     - Item count: [Item: Nickel Plate] = 0

 - Station: Mixed-C-[Item: Stainless Steel]
   - AND
     - Inactivity: 5 seconds
     - Circuit signal: [Item: Copper Plate] > 0
     - Circuit signal: [Item: Sulfur] > 0
     - Circuit signal: [Item: Niobium Plate] > 0
     - Circuit signal: [Item: Cobalt Extract] > 0
     - Circuit signal: [Item: Ferrochrome] > 0
     - Circuit signal: [Item: Phosphorous Rock] > 0
     - Circuit signal: [Item: Nickel Plate] > 0

 - Station: [Item: Copper Plate]-P
   - OR
     - Item count: [Item: Copper Plate] >= 200
     - Time passed: 30 seconds

 - Station: [Item: Sulfur]-P
   - OR
     - Item count: [Item: Sulfur] >= 100
     - Time passed: 30 seconds

 - Station: [Item: Niobium Plate]-P
   - OR
     - Item count: [Item: Niobium Plate] >= 200
     - Time passed: 30 seconds

 - Station: [Item: Cobalt Extract]-P
   - OR
     - Item count: [Item: Cobalt Extract] >= 100
     - Time passed: 30 seconds

 - Station: [Item: Ferrochrome]-P
   - OR
     - Item count: [Item: Ferrochrome] >= 500
     - Time passed: 30 seconds

 - Station: [Item: Phosphorous Rock]-P
   - OR
     - Item count: [Item: Phosphorous Rock] >= 400
     - Time passed: 30 seconds

 - Station: [Item: Nickel Plate]-P
   - OR
     - Item count: [Item: Nickel Plate] >= 500
     - Time passed: 30 seconds
Ideally I can paste that into a text editor (Hi Emacs!), do some editing, and then paste it back.

To paste back, I'd expect to have the text in my clipboard and when the mouse hovers over the schedule if I hit paste it replaces the entire schedule.

Alternatively UI buttons could be added to export/import to the clipboard. Not in an encoded format, but a human readable one.

Errors should return line number failure info on the console, and not make changes.
Why ?
Factorio is about controlling rising complexity. Trains and schedules are some of the most complicated portions of the game. I've seen recommendations for schedules, routes, additional UI elements to allow changes. Many of those require many changes or in depth UI. Allowing a player to edit some text is very simple and can allow external tools to assist with composing schedules.

Re: Copy/paste train schedules as plain text

Posted: Tue Mar 23, 2021 2:40 pm
by vjbone
I think blueprints save train settings. So you can copy/paste when you want
And it looks like work for external tool to convert bp format to readable text(I saw something like this somewhere)

Re: Copy/paste train schedules as plain text

Posted: Tue Mar 23, 2021 2:51 pm
by Demosthenex
Duplicating schedules with a blueprint isn't the same as exporting a human readable and editable schedule, to then be imported.

Re: Copy/paste train schedules as plain text

Posted: Wed Mar 24, 2021 11:15 pm
by ssilk
Demosthenex wrote: Tue Mar 23, 2021 2:51 pm Duplicating schedules with a blueprint isn't the same as exporting a human readable and editable schedule, to then be imported.
I would never use that and I think most other players even would know about it or await this feature.

And it's kind of crude software-design to add something like that to any software. I've seen people working like so: They had a big database. But instead of writing software to operate/change their data, the wrote excel-sheets to get some data, edit it in excel and then store that back to the database. The errors they did, when they made their changes like so, was way bigger, then the effort to make things "right", by writing kind of CRUD-interface to their database.
This is the same.

Wouldn't it be much better to add the missing functionality to the current schedule-editor instead of adding such a misleading functionality?

Or make a mod to program you schedule kind of "human-readable". :)

Re: Copy/paste train schedules as plain text

Posted: Thu Mar 25, 2021 1:57 am
by Trific
Can we just get the ability to edit the station name on the schedule?

Re: Copy/paste train schedules as plain text

Posted: Thu Mar 25, 2021 2:05 am
by ptx0
ssilk wrote: Wed Mar 24, 2021 11:15 pm
Demosthenex wrote: Tue Mar 23, 2021 2:51 pm Duplicating schedules with a blueprint isn't the same as exporting a human readable and editable schedule, to then be imported.
I would never use that and I think most other players even would know about it or await this feature.
you could have said that about blueprint string sharing.

i have some complex work-of-art train schedules that would be cool to share.

Re: Copy/paste train schedules as plain text

Posted: Fri Mar 26, 2021 6:56 am
by ssilk
Sharing “blueprints“ of train-schedule is a much better idea from my point of view. It fits into the overall “I want to import/export all things I can do, to not repeat things over and over, every time I start a new game”, like personal logistics, hotbar, sorting inventory, equipment grid config. In my eyes it makes much sense to add also, that you should be able to save vehicles with their grid, schedules, orders etc.

Once it’s a blueprint, others can make an editor to read it, change it and create own blueprints. That’s the way to go.

Recently worked on that article:
viewtopic.php?f=6&t=88751 Save/Load (import/export) everything (Persistent Logistic requests, hotbar, inventory filters, equipment grid...)

Re: Copy/paste train schedules as plain text

Posted: Fri Mar 26, 2021 1:42 pm
by eradicator
Protip: Train schedules are tables representable as JSON. Should be easy to make a mod with a simplistic text window that let's you load/edit/save the JSON. There's no point in inventing a new data representation language just for train schedules unless you want a multi-language capable representation that can't be copy-/paste'ed across language barriers.

Re: Copy/paste train schedules as plain text

Posted: Sat Mar 27, 2021 2:35 am
by ptx0
eradicator wrote: Fri Mar 26, 2021 1:42 pm Protip: Train schedules are tables representable as JSON. Should be easy to make a mod with a simplistic text window that let's you load/edit/save the JSON. There's no point in inventing a new data representation language just for train schedules unless you want a multi-language capable representation that can't be copy-/paste'ed across language barriers.
JSON is for machines, not humans.