Page 1 of 1

Alternate verbose blueprint string format

Posted: Thu May 04, 2017 6:56 pm
by sparr
I recognize that blueprint strings are short so they will be easier to copy, paste, post online, etc.

I would love to have a way to "expand" a blueprint string to something like a JSON blob or lua object declaration, and then to paste that format back into the game.

The use case for this is to make the blueprint string itself directly editable, and more importantly to allow the strings to exist in source control. I want to expand a blueprint book to a github repository, and accept pull requests against it.

Re: Alternate verbose blueprint string format

Posted: Thu May 04, 2017 8:22 pm
by darkfrei
This library helps you convert blueprints to text strings, and text strings to blueprints
https://github.com/DaveMcW/blueprint-st ... string.lua

Re: Alternate verbose blueprint string format

Posted: Thu May 04, 2017 9:23 pm
by sparr
darkfrei wrote:
This library helps you convert blueprints to text strings, and text strings to blueprints
https://github.com/DaveMcW/blueprint-st ... string.lua
That's an internal library for turning an *actual* lua table into a blueprintstring. It doesn't help with the question of serializing a table or making the game accept serialized tables.

Re: Alternate verbose blueprint string format

Posted: Fri May 05, 2017 4:28 pm
by ssilk
This is not translatable, cause a blueprint is a kind of "program", which calls lua functions to place entities.

Re: Alternate verbose blueprint string format

Posted: Fri May 05, 2017 4:39 pm
by sparr
ssilk wrote:This is not translatable, cause a blueprint is a kind of "program", which calls lua functions to place entities.
No, it's not. A blueprint exchange string is just a gzip'd json blob describing the objects.

Here is the actual contents of a small blueprint, decoded:

Code: Select all

{
  "blueprint":{
    "icons":[
      {
        "signal":{
          "type":"item",
          "name":"express-splitter"
        },
        "index":1
      }
    ],
    "entities":[
      {
        "entity_number":1,
        "name":"express-underground-belt",
        "position":{
          "x":-2,
          "y":-2
        },
        "direction":4,
        "type":"input"
      },
      {
        "entity_number":2,
        "name":"express-transport-belt",
        "position":{
          "x":-1,
          "y":-2
        },
        "direction":4
      },
      {
        "entity_number":3,
        "name":"express-splitter",
        "position":{
          "x":-1.5,
          "y":-3
        },
        "direction":4
      },
      {
        "entity_number":4,
        "name":"express-underground-belt",
        "position":{
          "x":1,
          "y":-2
        },
        "direction":4,
        "type":"input"
      },
    "item":"blueprint",
    "version":64424902656
  }
}

Re: Alternate verbose blueprint string format

Posted: Sun May 07, 2017 2:06 pm
by ssilk
Oh, looks, like I'm not up to date. :oops: :) Thanks for this hint, I cannot know everything. :)

Well, if that format is that simple, I don't see any need to change it. That de/compression is kind of standard in any programming language.

Re: Alternate verbose blueprint string format

Posted: Sun May 07, 2017 3:59 pm
by sparr
ssilk wrote:Well, if that format is that simple, I don't see any need to change it. That de/compression is kind of standard in any programming language.
It doesn't matter how simple it is. If I give someone that blueprint string above, they need some third party tool to convert it. I want them to be able to just paste it into the game.