Blueprint Viewer

Calculate optimal ratios for feeding recipes, search through the research-tree, specialized tools to view game-information.
Post Reply
gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Blueprint Viewer

Post by gheift »

This nice service seems to be off-line -- ssilk

Hello everybody,

I have created a first version of an online viewer for blueprints created by the Foreman - Blueprint Manager [1] or Blueprint String [2] aslong as they are uncompressed. My initial attempt was to create a compression function for these two mods, but during the development of the viewer I discovered a few corner cases, which are not yet handled by my format.

The script on the site is rather slow, because it uses a Lua VM. The pictures are directly copied from the data directory of the game. I do not know, if I am allowed to host them on my website for this purpose.

Here is my viewer with 4 examples. If you click on a entity, some information of it will be displayed in the info box on the right site.

https://ght.io/factorio/blueprint/

Happy testing,
Gerhard

[1]: https://forums.factorio.com/forum/vie ... =14&t=6516
[2]: https://forums.factorio.com/forum/vie ... =14&t=6742

User avatar
Gandalf
Filter Inserter
Filter Inserter
Posts: 294
Joined: Fri Dec 19, 2014 10:15 pm
Contact:

Re: Blueprint Viewer

Post by Gandalf »

Very nice!
If something like this could be integrated in the forum at some point that'd be really neat.
OS: Linux Mint 19 x64 | desktop: Awesome 4.2  |  Intel Core i5 8600k  |  16GB DDR4  |  NVidia GTX 1050 Ti (driver version: 410.104)    (2019-03)

NotABiter
Fast Inserter
Fast Inserter
Posts: 124
Joined: Fri Nov 14, 2014 9:05 am
Contact:

Re: Blueprint Viewer

Post by NotABiter »

I hit a few issues:

1. It's currently broken if used with the Blueprint String mod. The top-level "name" value is presumably added by Foreman, but is not included by the Blueprint String mod (nor by my own blueprint generator), and your viewer seems to require it.

I.e., these work:

Code: Select all

do local _={entities={{entitynumber=1,name="solar-panel",position={x=0.5,y=2.5}}},icons={{name="solar-panel",index=1}},name="foo"};return _;end
do local _={entities={{entitynumber=1,name="basic-accumulator",position={x=0.5,y=2.5}}},icons={{name="basic-accumulator",index=1}},name="foo"};return _;end
But these don't work:

Code: Select all

do local _={entities={{entitynumber=1,name="solar-panel",position={x=0.5,y=2.5}}},icons={{name="solar-panel",index=1}}};return _;end
do local _={entities={{entitynumber=1,name="basic-accumulator",position={x=0.5,y=2.5}}},icons={{name="basic-accumulator",index=1}}};return _;end
2. It doesn't understand "default direction". I don't know if this is a "Factorio thing" or a "Blueprint String mod thing" (or a Lua thing?), but 0 is treated as the default direction, and "direction=0" is not included in blueprint strings. Your viewer doesn't seem to have the same understanding, and whereas this works:

Code: Select all

do local _={entities={{entitynumber=1,name="smart-inserter",position={x=0.5,y=2.5},direction=0}},icons={{name="smart-inserter",index=1}},name="foo"};return _;end
This just displays a red box (and the info text when you select it does not indicate any direction):

Code: Select all

do local _={entities={{entitynumber=1,name="smart-inserter",position={x=0.5,y=2.5}}},icons={{name="smart-inserter",index=1}},name="foo"};return _;end
3. Perhaps nothing you can do about this one but... the viewer doesn't seem to work very well for large blueprints. (I'm using the latest version of Firefox.) I tried putting in a blueprint like the one from this post (with a ,name="foo" added) and I guess that's a bit too big -- I repeatedly get the "unresponsive script" warning from Firefox (and I'm afraid to let the script continue to run without limit because it's causing Firefox to black out).

teenusa
Inserter
Inserter
Posts: 36
Joined: Sat Jan 24, 2015 1:36 pm
Contact:

Re: Blueprint Viewer

Post by teenusa »

Maybe you could make a list of blueprints?

Or rather you maybe can make a function for Users to import blueprints to your side in a list and all people can "download" the blueprints

teenusa

Ps.: Sorry for my Englisch it is not my native language D:
aka Chaftalie

gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: Blueprint Viewer

Post by gheift »

@NotABiter: The first two issues should be fixed, the third one is not easy to solve. I think DOM manipulation in Lua is not the best idea, so for now I limited the preview to 500 entities. When I have enough time, I will reimplement the function in pure Javascript with CSS classes.

@teenusa: I have this in my mind, but currently everything runs on the client site. Actually you can share the blueprints with the generated link. (You might have missed it, because it was temporarily hidden.)

Otherwise I found a few buildings which will not be displayed:
  • all smelters
  • beacon
  • pumpjack
  • small lamp
  • lab
Thanks for your feedback.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Blueprint Viewer

Post by ssilk »

Crazy stuff...

Edit: some questions:
- why do you need the Lua VM? Executing the blueprint code?
- do you take the entities also from the lua game config? (Data.lua)
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

quinor
Filter Inserter
Filter Inserter
Posts: 404
Joined: Thu Mar 07, 2013 3:07 pm
Contact:

Re: Blueprint Viewer

Post by quinor »

This is must-be tool for this forum. I hope it gets at least sticked along with string generation tools.

gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: Blueprint Viewer

Post by gheift »

@ssilk: My initial motivation was to write a better representation for the blueprints, to compress them down. Currently my format has the size of 5% – 15% of the orignial blueprint string and even 20% – 50% of compressed blueprint strings (gzip | base64). To be able to include them in the game later, I wrote this in Lua, which is kind of obvious. After the first version was ready I thought, I just could write this preview page, which shows the blueprints and compress them to my new format, which also the URL of this site :D . Therefor I included the VM. The data for the pictures are extracted form the data.lua files, but it cost me about three full days to get nearly everything I needed. The format is, in my opinion, a mess and has way to much excepional cases.

Kane
Filter Inserter
Filter Inserter
Posts: 666
Joined: Fri Sep 05, 2014 7:34 pm
Contact:

Re: Blueprint Viewer

Post by Kane »

Looks amazing. I'm using Blueprint-string. Not sure how one goes by generating uncompressed strings.

Example output now:

Code: Select all

H4sIAAAAAAAA/42YYWujQBCG/0rp51jc3dndhJJfUo5ikr2rYDSohSvF/36aKpfxXdn50tKAT98Zn5nVXJqnqjkX1dP78TvUfdmXoTt+v6lf859f9ef1FNqj
2tXFNRyfT0VXnrPuVpV9H9rn3a3pxmua+vj995jp3df448UOu0vZhvP9cxp2b3pN0wKa3YCZNcxIotFEy5FGaxoxWt8WdXdr2j47hapfl/tiN6h2TbWSjGai
KaS5Nc3JM6rNjH5N9ZKMaiPjfk3bC2j5RrTDGnaYYd21qKqsKq43Dnqocrxc5WBvLkhDG6UpHAbJNJiN4hRMg9Li+2k3b6eCuVBGjKVtLAyIIkHxbquXMBlK
Mhp+Kx2Mhlpm43fR9VlZd6GNLIN7uWq2BQZBeQFDMwbor/YChmEMsF4dBIz8kaHBfJ0LGIoxQHet0gweAxe+TiNYNzTorE0awW6KBnU1pRGWIUBXbdMIppcG
RbVAUc8QYKgWGOoYAgTVi6DjXijrrOub29qKaYOZx5FzEwk01antnO3vUcxPFAOOmsXRa7iUn9csVOP/a8dlcGuqsEL93B49o0BVs6ja9SFU2fkjdOsTkRgB
TDUCU2fGUhA+kZhkCs1SgKmGkgTDCCCqEYg6p1jqAFONZJkaxgBVjU9WkrNKwFSzTxIUI4ChRr5I5zoIJCX5Il0YYCcpseisIgJLSad6wppKoCgJtinvCD4p
Jx1lihIoSjYFYFNC4CcJ/GR6EuhJgk3KpoTAT0r6yZYWgZ50SAHYzrLgphW4aR+LsKCmFZzxbOtZcNImnfSsDHDSCpz0LAM4aZNOOpYBX9QEa9OxDGCldeIp
37MwIKf1iZNVsYVjQU37X83xlP/z0Wfjryp2zrNHaz3BQFN7kMBUDOZAWZcLYIcoC9x1SsDyURZI7LSAZaMs8NkZASvafAdiO5I0P8oCx51Ns+Io/CbCpVHx
CkF259OoeONBeyfQPu4DSO8E0kc19aC8FygfHx8PynuB8vG59qC8FyivIp0fduW5qadvC6dS8WWirC9hvHIYhtc29J9t/fT+GurLPwQaUu9yFAAA

gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: Blueprint Viewer

Post by gheift »

On linux, use

Code: Select all

base64 -d | gzip -d
This gives you the following code:

Code: Select all

do local _={entities={[1]={entitynumber=1,name="basic-splitter",position={x=-2,y=-2.5},direction=4},[2]={entitynumber=2,name="basic-splitter",position={x=5,y=-2.5},direction=4},[3]={entitynumber=3,name="basic-splitter",position={x=-4,y=-0.5},direction=4},[4]={entitynumber=4,name="basic-transport-belt",position={x=-2.5,y=-0.5},direction=4},[5]={entitynumber=5,name="basic-splitter",position={x=-3,y=-1.5},direction=4},[6]={entitynumber=6,name="basic-transport-belt",position={x=-1.5,y=-0.5},direction=4},[7]={entitynumber=7,name="basic-splitter",position={x=-1,y=-1.5},direction=4},[8]={entitynumber=8,name="basic-splitter",position={x=0,y=-0.5},direction=4},[9]={entitynumber=9,name="small-lamp",position={x=1.5,y=-0.5}},[10]={entitynumber=10,name="basic-splitter",position={x=4,y=-1.5},direction=4},[11]={entitynumber=11,name="basic-splitter",position={x=3,y=-0.5},direction=4},[12]={entitynumber=12,name="basic-transport-belt",position={x=5.5,y=-0.5},direction=4},[13]={entitynumber=13,name="basic-transport-belt",position={x=4.5,y=-0.5},direction=4},[14]={entitynumber=14,name="basic-splitter",position={x=6,y=-1.5},direction=4},[15]={entitynumber=15,name="basic-splitter",position={x=7,y=-0.5},direction=4},[16]={entitynumber=16,name="fast-inserter",position={x=-4.5,y=1.5}},[17]={entitynumber=17,name="fast-inserter",position={x=-2.5,y=1.5}},[18]={entitynumber=18,name="fast-inserter",position={x=-3.5,y=1.5}},[19]={entitynumber=19,name="fast-inserter",position={x=-0.5,y=1.5}},[20]={entitynumber=20,name="fast-inserter",position={x=-1.5,y=1.5}},[21]={entitynumber=21,name="fast-inserter",position={x=0.5,y=1.5}},[22]={entitynumber=22,name="fast-inserter",position={x=3.5,y=1.5}},[23]={entitynumber=23,name="fast-inserter",position={x=2.5,y=1.5}},[24]={entitynumber=24,name="fast-inserter",position={x=5.5,y=1.5}},[25]={entitynumber=25,name="fast-inserter",position={x=4.5,y=1.5}},[26]={entitynumber=26,name="fast-inserter",position={x=7.5,y=1.5}},[27]={entitynumber=27,name="fast-inserter",position={x=6.5,y=1.5}},[28]={entitynumber=28,name="train-stop",position={x=-13,y=3},direction=6},[29]={entitynumber=29,name="small-lamp",position={x=-8.5,y=3.5}},[30]={entitynumber=30,name="medium-electric-pole",position={x=-5.5,y=2.5}},[31]={entitynumber=31,name="steel-chest",position={x=-4.5,y=2.5}},[32]={entitynumber=32,name="fast-inserter",position={x=-4.5,y=3.5}},[33]={entitynumber=33,name="steel-chest",position={x=-2.5,y=2.5}},[34]={entitynumber=34,name="steel-chest",position={x=-3.5,y=2.5}},[35]={entitynumber=35,name="fast-inserter",position={x=-2.5,y=3.5}},[36]={entitynumber=36,name="fast-inserter",position={x=-3.5,y=3.5}},[37]={entitynumber=37,name="steel-chest",position={x=-0.5,y=2.5}},[38]={entitynumber=38,name="steel-chest",position={x=-1.5,y=2.5}},[39]={entitynumber=39,name="fast-inserter",position={x=-0.5,y=3.5}},[40]={entitynumber=40,name="fast-inserter",position={x=-1.5,y=3.5}},[41]={entitynumber=41,name="medium-electric-pole",position={x=1.5,y=2.5}},[42]={entitynumber=42,name="steel-chest",position={x=0.5,y=2.5}},[43]={entitynumber=43,name="fast-inserter",position={x=0.5,y=3.5}},[44]={entitynumber=44,name="steel-chest",position={x=3.5,y=2.5}},[45]={entitynumber=45,name="steel-chest",position={x=2.5,y=2.5}},[46]={entitynumber=46,name="fast-inserter",position={x=3.5,y=3.5}},[47]={entitynumber=47,name="fast-inserter",position={x=2.5,y=3.5}},[48]={entitynumber=48,name="steel-chest",position={x=5.5,y=2.5}},[49]={entitynumber=49,name="steel-chest",position={x=4.5,y=2.5}},[50]={entitynumber=50,name="fast-inserter",position={x=5.5,y=3.5}},[51]={entitynumber=51,name="fast-inserter",position={x=4.5,y=3.5}},[52]={entitynumber=52,name="steel-chest",position={x=7.5,y=2.5}},[53]={entitynumber=53,name="fast-inserter",position={x=7.5,y=3.5}},[54]={entitynumber=54,name="steel-chest",position={x=6.5,y=2.5}},[55]={entitynumber=55,name="fast-inserter",position={x=6.5,y=3.5}},[56]={entitynumber=56,name="medium-electric-pole",position={x=8.5,y=2.5}},[57]={entitynumber=57,name="small-lamp",position={x=11.5,y=3.5}},[58]={entitynumber=58,name="straight-rail",position={x=-13,y=5},direction=2},[59]={entitynumber=59,name="straight-rail",position={x=-11,y=5},direction=2},[60]={entitynumber=60,name="straight-rail",position={x=-9,y=5},direction=2},[61]={entitynumber=61,name="straight-rail",position={x=-7,y=5},direction=2},[62]={entitynumber=62,name="straight-rail",position={x=-5,y=5},direction=2},[63]={entitynumber=63,name="straight-rail",position={x=-3,y=5},direction=2},[64]={entitynumber=64,name="straight-rail",position={x=-1,y=5},direction=2},[65]={entitynumber=65,name="straight-rail",position={x=1,y=5},direction=2},[66]={entitynumber=66,name="straight-rail",position={x=3,y=5},direction=2},[67]={entitynumber=67,name="straight-rail",position={x=5,y=5},direction=2},[68]={entitynumber=68,name="straight-rail",position={x=7,y=5},direction=2},[69]={entitynumber=69,name="straight-rail",position={x=9,y=5},direction=2},[70]={entitynumber=70,name="straight-rail",position={x=11,y=5},direction=2},[71]={entitynumber=71,name="straight-rail",position={x=13,y=5},direction=2},[72]={entitynumber=72,name="straight-rail",position={x=15,y=5},direction=2}},icons={[0]={name="train-stop",index=1}}};return _;end
You can view it here: https://ght.io/factorio/blueprint/#Blue ... qNVuXW2nAA

As written above: the small lamps will not yet be displayed.

Kane
Filter Inserter
Filter Inserter
Posts: 666
Joined: Fri Sep 05, 2014 7:34 pm
Contact:

Re: Blueprint Viewer

Post by Kane »

Thanks :)

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3699
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Blueprint Viewer

Post by DaveMcW »

You can read a compressed string using this function. Download rawinflate.js here.

Code: Select all

<script src="rawinflate.js"></script>
<script>
function uncompress(s) {
	if (s.substr(0,8) == 'do local') return s;  // already uncompressed!
	return RawDeflate.inflate(atob(s).slice(10, -8));
}
</script>

gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: Blueprint Viewer

Post by gheift »

Thanks for the lib, just included the code in the page. Now you can use even the compressed Blueprints.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Blueprint Viewer

Post by ssilk »

gheift wrote:@ssilk: My initial motivation was to write a better representation for the blueprints, to compress them down. Currently my format has the size of 5% – 15% of the orignial blueprint string and even 20% – 50% of compressed blueprint strings (gzip | base64). To be able to include them in the game later, I wrote this in Lua, which is kind of obvious. After the first version was ready I thought, I just could write this preview page, which shows the blueprints and compress them to my new format, which also the URL of this site :D . Therefor I included the VM. The data for the pictures are extracted form the data.lua files, but it cost me about three full days to get nearly everything I needed.
So as I understand you right, the VM is for the web-server-part? :)
The format is, in my opinion, a mess and has way to much excepional cases.
Ok. So I think I step back for a moment and look to this architecture.
You say "format". I would call the current as "using lua data-structure to create a internal struct, which can be used for blueprints". ;)
I think we will have this "format" for a while, cause it is clear for me, that you cannot really create a format, when you don't know the needs and what might be added.

And indeed, this is a good question: What is a blueprint, when you don't have really a goodformat for it? Or what is a blueprint at all? Which parts of a factory design belongs to blueprint, which not? Does the modules setting belong to a blueprint? Wouldn't it be much better to define it like in a gif? You define "colors", for example "red" (#FF0000 = 01). So gif format can be really good compressed. For blueprint this means, you have some kind of "header", where you define all entities. For example "a basic-splitter with orientation 4" = A1 and then use a gif for storing this? I think, this is, what you want to do. :)

But it is for me obvious, that we need some formats, not only one or two. For example, an ascii based format. Differently compressed formats. Repetitions.
So it is also obvious for me, that we need some kind of "lib", that is able to convert from one format to another. Of course written in lua. But will output other formats, json for example or xml. And vice versa.
This cannot be written by only one person. :)

Oh, btw. do you plan to release the code anywhere? I think others can learn a lot from it, including the devs.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: Blueprint Viewer

Post by gheift »

Sorry, I think I did not differntiate about which format I was writing. The data structure of the blueprints is good.

The structure of how the drawing information for the entities is stored in the data.lua files is somehow inconsistent. Maybe I have not seen the whole picture, how it is organized, but on my first view I found too many possibilities. There are picture and pictures, animation and animations. Some of them are divided by direction horizontal and vertical, some by north, east, south, west. There are also sheets, which collect these as one, but they do not have the same order everytime. Some entites have unnamed layers, some have named ones. For some entites there are additional drawing information located somewhere else.

It was quite a lot of work to collect nearly all of them and I am not yet finished. I think the game has quite a lot of code to deal with all these cases. In my opinion it would benefit the futere development in the long term if all these cases would be unified.

The blueprint format, which is exposed by the game to the mods is good as it is. It stores for each entity all the relevant information and is extensible for example with module settings of assembling machines (like you wrote). How this blueprint is used by us (stringification, exchange with other users and therefor compression etc.) should not be the concern of the interface in the first place.

As exchange format we have currently the blueprint dump and a deflate/base64 encoded version of it, which is used by the two used mods. There is no need to convert it in any way, because it is rougly the native format of the game. Then there is my format, which is not yet finished. Indeed I used the idea you mention: first define some entities with attributes, like inserter with direction north, assembler with recipe gears, and then I refer to these instead of repeating it all over again. And I stores them in a "picture" based on the coordinates. The drawback with this projection is: only one entity per position and the order of them is lost. I found at least one example where two entites can exist on the same postion: horizontal and vertical rails. Also the order of the entities is important, which I read in the forum after I started my first design (https://forums.factorio.com/forum/vie ... f=8&t=4814). So I have to change the way, I store this information in format. When it is ready I will ask the authors of the currently existing mods if they are willing to include/use my format, but not yet.

The code of my current compressen is already only, it is used on my page to create the link: https://ght.io/factorio/blueprint/ght/blueprint.lua, but as I already wrote: I have to rewrite some parts of it. The code which collects all the drawing information is not online, but if somebody is interested I can upload it, too.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Blueprint Viewer

Post by ssilk »

gheift wrote:Sorry, I think I did not differntiate about which format I was writing. The data structure of the blueprints is good.

The structure of how the drawing information for the entities is stored in the data.lua files is somehow inconsistent. Maybe I have not seen the whole picture, how it is organized, but on my first view I found too many possibilities. There are picture and pictures, animation and animations. Some of them are divided by direction horizontal and vertical, some by north, east, south, west. There are also sheets, which collect these as one, but they do not have the same order everytime. Some entites have unnamed layers, some have named ones. For some entites there are additional drawing information located somewhere else.
Ah, yes, this.

That was the reason for my factorio loader (https://github.com/alexaulbach/FactorioLoaderLib) . The generated data-structures (for example json: https://github.com/alexaulbach/Factorio ... .11.6.json ) show exactly that. But they show also, that the possibilities are limited. If I join for example everything about the steam-engine it shows interesting results.
It was quite a lot of work to collect nearly all of them and I am not yet finished. I think the game has quite a lot of code to deal with all these cases. In my opinion it would benefit the futere development in the long term if all these cases would be unified.
I don't think so. They just use the config. If the option is there, they handle it... or not. That depends from the entity.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Talguy
Fast Inserter
Fast Inserter
Posts: 105
Joined: Tue Apr 29, 2014 8:54 pm
Contact:

Re: Blueprint Viewer

Post by Talguy »

BUMP! The viewer is offline :(

tehfreek
Filter Inserter
Filter Inserter
Posts: 391
Joined: Thu Mar 17, 2016 7:34 am
Contact:

Re: Blueprint Viewer

Post by tehfreek »

And now the SSL cert for the site has expired :?

Post Reply

Return to “Cheatsheets / Calculators / Viewers”