blueprint string viewer

Enhance your gameplay with these tools. This category is also the right place for tools useful for modders.
Mod databases, calculators, cheatsheets, multiplayer, scripts, libs and other useful stuff that is not strictly in-game mods.
Post Reply
Skandragon
Inserter
Inserter
Posts: 29
Joined: Fri Nov 18, 2016 9:26 am
Contact:

blueprint string viewer

Post by Skandragon »

A while back, someone posted about an online blueprint string viewer. AFAIK, that is no longer available. Am I wrong, and if so, what is the URL?

I have started writing one, but it's going to be tedious to get right; before I go too far down this rabbit hole, I want to make sure I'm not repeating efforts someone else has done.

Right now, a sample of my "red circuit pod" is here: http://www.flame.org/~explorer/factorio ... t-pod.html The intent is not to render just like it is in game, but to show it more like a building floor plan, and use simple boxes and such. Eventually, I'll annotate things like requester boxes with what they request, filter inserters with their list, things connected to networks or wires, etc with their parameters.

The blueprint string this is rendered from:

Code: Select all

H4sIAAAAAAAA/91VzW7bMAx+lSBnC3DcbpdOz2IoEpMQkyVNorMWht99dKP1z80ibwXaLpcgEcnvhyJl/Mp6reyqlQM4QkJIchic6kCuVUrQbS26veiUPqAD
cbWugk8c5p0cbqW4ru6kaMYqgsYwpZijchqM0Bh1j7Qeq1xspxIJdAkiQXxRpZmqXI2VQa5z/29Tae8oettu4aCO6KMcrN9jItQtH5mcvMOYqE24d8rKge4m
DkjQrassYc6HsxMpR7Kppw//7oKKihhi/e107phFS759QHRAP338Lin2MD5I+n0s9AFYXIQfPX/P1G2yunze7tBy0GQzOgO3cpO5gmXY6N1UMLNlMj0z/VIz
5im4ycHBqnvorYpPopZyexdqf7gJ84vw9TNchMuD8oZz0jyz51zDA3PCI4gQ/RHN63eyKerJCXXzbDoXKK85u34Urn0IEIVWWwuPolOnrBVWdWGe/JTmIpEL
NM6NbYrTNq/3o3B5Ft2JDgz2nThNIasPns2bN6ku7+eZdl4GKseZwSzxptiaS0LfbFoWDMt//ZJ9oNeiftnf679fFOeXzBkz6jIv8r5jlQT/+FB/IOdnk1W8
Lj/P4z5WOBVhjxcB54Zw/k0E6qNbtTfgzC+qlKFJaQsAAA==

aober93
Filter Inserter
Filter Inserter
Posts: 453
Joined: Tue Aug 30, 2016 9:07 pm
Contact:

Re: blueprint string viewer

Post by aober93 »

Might be useful if implemented with the blueprint share sites. The users often post blueprints, but no picture.

Skandragon
Inserter
Inserter
Posts: 29
Joined: Fri Nov 18, 2016 9:26 am
Contact:

Re: blueprint string viewer

Post by Skandragon »

aober93 wrote:Might be useful if implemented with the blueprint share sites. The users often post blueprints, but no picture.
That's the plan.

Well, sort of. I think my ultimate plan is to provide a blueprint management site, although I do see some hints that 0.15 will have loading and saving of them more integrated.

Things like, "give me a blueprint book that has oil processing and rail intersections set" or "take this blueprint and lower the logistic limits for the inserters from 200k to 10k"

sniderthanyou
Inserter
Inserter
Posts: 20
Joined: Tue Jul 05, 2016 11:43 am
Contact:

Re: blueprint string viewer

Post by sniderthanyou »

I love the idea! Do you intend to keep the source private, or would you consider hosting it on GitHub to allow others to contribute?

Skandragon
Inserter
Inserter
Posts: 29
Joined: Fri Nov 18, 2016 9:26 am
Contact:

Re: blueprint string viewer

Post by Skandragon »

sniderthanyou wrote:I love the idea! Do you intend to keep the source private, or would you consider hosting it on GitHub to allow others to contribute?
Right now it's private mostly because it's in its infancy. However, if you are offering to help contribute... I'm interested in that, and plans can change. What I have now is more of a proof of concept -- it's got some pretty major hacking behind it.

First, a Ruby script to uncompress the BASE64 encoded data. Then a Lua script to output the data as JSON. Then a Ruby script to generate SVG. Lots of moving parts.

aober93
Filter Inserter
Filter Inserter
Posts: 453
Joined: Tue Aug 30, 2016 9:07 pm
Contact:

Re: blueprint string viewer

Post by aober93 »

How do you read the blueprint string anyway. It begins with H4sIAAAAAA what does that mean?

Yoyobuae
Filter Inserter
Filter Inserter
Posts: 499
Joined: Fri Nov 04, 2016 11:04 pm
Contact:

Re: blueprint string viewer

Post by Yoyobuae »

aober93 wrote:How do you read the blueprint string anyway. It begins with H4sIAAAAAA what does that mean?
It's BASE64 encoded and GZipped. Once those two are undone you get something like:

Code: Select all

do local _={entities={{name="constant-combinator",position={x=-3,y=-1},direction=2,control_behavior={filters={{signal={type="virtual",name="signal-black"},count=-3,index=1},{signal={type="item",name="copper-plate"},count=-4,index=2},{signal={type="item",name="iron-plate"},count=-4,index=3}}},connections={["1"]={red={{entity_id=2,circuit_id=1}}}}},{name="decider-combinator",position={x=-1.5,y=-1},direction=2,control_behavior={decider_conditions={first_signal={type="virtual",name="signal-each"},constant=0,comparator=">",output_signal={type="item",name="copper-plate"},copy_count_from_input=true}},connections={["1"]={red={{entity_id=1}},green={{entity_id=3,circuit_id=1}}},["2"]={green={{entity_id=3,circuit_id=2}}}}},{name="decider-combinator",position={x=-1.5,y=0},direction=2,control_behavior={decider_conditions={first_signal={type="virtual",name="signal-each"},constant=4,comparator="<",output_signal={type="virtual",name="signal-each"},copy_count_from_input=true}},connections={["1"]={green={{entity_id=3,circuit_id=2},{entity_id=2,circuit_id=1}}},["2"]={green={{entity_id=3,circuit_id=1},{entity_id=2,circuit_id=2},{entity_id=4,circuit_id=1}}}}},{name="decider-combinator",position={x=0.5,y=0},direction=2,control_behavior={decider_conditions={first_signal={type="virtual",name="signal-anything"},constant=3,comparator=">",output_signal={type="virtual",name="signal-black"},copy_count_from_input=false}},connections={["1"]={green={{entity_id=3,circuit_id=2}}},["2"]={green={{entity_id=5,circuit_id=1}}}}},{name="decider-combinator",position={x=2.5,y=0},direction=2,control_behavior={decider_conditions={first_signal={type="virtual",name="signal-black"},constant=2,comparator="<",output_signal={type="virtual",name="signal-black"},copy_count_from_input=true}},connections={["1"]={green={{entity_id=4,circuit_id=2},{entity_id=5,circuit_id=2}}},["2"]={green={{entity_id=5,circuit_id=1}}}}}},icons={{signal={type="item",name="decider-combinator"},index=1}}};return _;end

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

Re: blueprint string viewer

Post by ssilk »

Moved from Show Your Creations to Tools.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Skandragon
Inserter
Inserter
Posts: 29
Joined: Fri Nov 18, 2016 9:26 am
Contact:

Re: blueprint string viewer

Post by Skandragon »

It's BASE64 encoded and GZipped.
Technically, I think it's just Deflated, as it does not have a gzip header from what I can tell.

Yoyobuae
Filter Inserter
Filter Inserter
Posts: 499
Joined: Fri Nov 04, 2016 11:04 pm
Contact:

Re: blueprint string viewer

Post by Yoyobuae »

Skandragon wrote:
It's BASE64 encoded and GZipped.
Technically, I think it's just Deflated, as it does not have a gzip header from what I can tell.
Weill I just asked the file utility on Linux and it said it was gzip:

Code: Select all

$ cat blueprint.txt | base64 -d | file -
/dev/stdin: gzip compressed data
And piping it to zcat instead produced the output above. :D

SyncViews
Filter Inserter
Filter Inserter
Posts: 295
Joined: Thu Apr 21, 2016 3:17 pm
Contact:

Re: blueprint string viewer

Post by SyncViews »

Did you get anywhere further with this?
Been playing with some concepts for a blueprint viewer/tool in Javascript/Rails.

shockr
Manual Inserter
Manual Inserter
Posts: 1
Joined: Mon May 01, 2017 9:34 pm
Contact:

Re: blueprint string viewer

Post by shockr »

SyncViews wrote:Did you get anywhere further with this?
Been playing with some concepts for a blueprint viewer/tool in Javascript/Rails.
So have I, with the new 0.15 patch the internal blueprint string format is "<version:1char><base64+zlib:rest>"


Decode it:

Code: Select all

cat blueprint.b64 | tail -c +2 | base64 -d | zlib-flate  -uncompress
Pretty print it:

Code: Select all

cat blueprint.b64 | tail -c +2 | base64 -d | zlib-flate  -uncompress | python -m json.tool

SyncViews
Filter Inserter
Filter Inserter
Posts: 295
Joined: Thu Apr 21, 2016 3:17 pm
Contact:

Re: blueprint string viewer

Post by SyncViews »

Yep the new JSON based format is a lot better, was able to fully implement in my webapp once I found a pure JavaScript deflate library. There are still some potential issues, but hopefully no one is expecting to put an entire factory in one in practice (I was able to fairly easily get something that used over a GB of memory for that decompressed JSON as well as poor CPU performance for inflate/deflate and JSON parsing).

Internal format is just a JSON representation of the Lua API's in a simple wrapper (for anyone porting existing logic, there is an extra '{"blueprint": {...}}' wrapper layer, and it uses "label" for the Blueprint name/label).
Only thing I am not 100% sure on is how "version" is encoded.

cid0rz
Long Handed Inserter
Long Handed Inserter
Posts: 88
Joined: Sun Jul 31, 2016 5:52 pm
Contact:

Re: blueprint string viewer

Post by cid0rz »

Hum I 'm having some problems decoding new strings in python. In the past I did:
being todecodestr a read from an openfile of a blueprint:

Code: Select all

decoded_data = base64.decodestring(todecodestr)
    tempfile = StringIO.StringIO(decoded_data)
    decompressed = gzip.GzipFile(fileobj=tempfile)
    mydata = decompressed.read()
and from:

Code: Select all

H4sIAAAAAAAA/52TUW7bMAyGrxLodfJQJ2hfCu0GPUEwGIpEJwRkyaDpLIGhu1dS6m5Jk66p32zyJ///s2TDwgWj3aJREx97UGLjRugJPQtpNWs1gWdkhEFNk9dd6tCE
vOuA0VQmdBv0mgMJ2Ych9QWvpoN6+Pkoj6qqo7RIYMrnpTTBMwXXbGCn9xhITX9HNaloiz4tapEGbgbceu1mX3skHrUT8mTiVKxAm52IefLA2rN6kKEH0mWh+CFkGLkf
7xkVyzB/8pysrEUtfquJwKb8BcWxQZvDIJkRubwk0ZYA/FlLfdES5Vos86z/tNYxP/INtgWDFugm6apOoBPueIXum/abaP/skOGcbTLRa8omlPh1F9yXMqg/Ji+j56al
0DXok1q12g1wg/pHUqt/OF7+k08ozhluYswUz07r0xWeLToGyhfhPn4psVpJ9BYOxdcXsy4/5okSTRFdOEibunn99esZ3/fLT7RXTtsszIfc6Q24THOuwkF3vUsp4zMB
j+QXzTN4+wr96fJnVgQAAA==
got:

Code: Select all

do local _={type="blueprint",data={entities={{name="arithmetic-combinator",position={x=0.5,y=-1},direction=2,control_behavior={arithmetic_conditions={first_signal={type="virtual",name="signal-each"},constant=0,operation="+",output_signal={type="virtual",name="signal-each"}}},connections={["1"]={red={{entity_id=2,circuit_id=2}},green={{entity_id=1,circuit_id=2}}},["2"]={green={{entity_id=1,circuit_id=1}}}}},{name="decider-combinator",position={x=-1,y=0.5},control_behavior={decider_conditions={first_signal={type="virtual",name="signal-white"},constant=0,comparator=">",output_signal={type="virtual",name="signal-M"},copy_count_from_input=false}},connections={["1"]={green={{entity_id=3}}},["2"]={red={{entity_id=1,circuit_id=1}}}}},{name="constant-combinator",position={x=1,y=1},direction=6,control_behavior={filters={{signal={type="virtual",name="signal-white"},count=3,index=1}}},connections={["1"]={green={{entity_id=2,circuit_id=1}}}}}},icons={{signal={type="item",name="arithmetic-combinator"},index=1},{signal={type="item",name="decider-combinator"},index=2}},label="combinatorexample"}};return _;end
now the new blueprints:

Code: Select all

0eNrtWNmumzAQ/Rc/wxV2IAtS+wv9gKpCBCbJSGCQMWlRxL93DO1tmsU15EbqQ16ieJv1zBybE9sWLdQKpWbxiWFWyYbFX0+swb1MCzOnuxpYzFBDyTwm09KMcsgwB+VnVblFmepKsd5jKHP4wWLee/8UYBTpVOrbEkT/zWMgNWqE0Z5h0CWyLbegSIXNEo/VVUNHK2nUkzg/eIs81tEfQTpyVJCNq8IzhmhVFckWDukR6TQd+SUzobV8kNOY2R2qRidXfh1R6ZZm3i0ad/hfjD8NGBnuh74fKEzmILlTp2pwJ2afaF/V6rqdoB6OoDp9QLkfxdUdudNKnexUVSYoSRiLtWqhH5alHGMyeMrNj4L8PPJIIwpihiprUQ9DbrK0VwDyciPlj6QKNzFmc28gc5FjYQXLdZLFnxTfSuoOCw3qDrod8tGaEuGTQL5LG+2jbECR5jMpPg+Cc6zfycDN0PKrHNwM3uLdiBJybEsfChKvMPPrqoDr6PExeAt3MHDhlsZwXqkGr0r9yEr1/lreuBbyclohW7XcA0g0s5fzF0IeQEhoRwh3RcjKihBuR0johpDlLCYInkkEizMimNS/Q7f+vZpHfvyZPotJ5KdSLD6I8yK3mK3nNZLXnfCRPuJMJTywdoqNvVNc3jbuYWAzDwMvLnkEA2s7l4TOEOFWiIR2iKzdyIQHs1rrU58V0Vw2WbtVBeezfH4qm4Rzfd44+iwmtYLxASTeov7Ztf87A3RDuajnz/9nPdtf84sh/lTSA/3HZx+UPEa2NUOIl2EowvVixQXv+59LY1qv
give me incorrect padding error. I tried padding in the end with = till length divisible by 4 but still does not decode, any hint where the problem can be? So you say the changed the description format inside the blueprint to json? then once decoded sure there is a library to replace my parser ^^

SyncViews
Filter Inserter
Filter Inserter
Posts: 295
Joined: Thu Apr 21, 2016 3:17 pm
Contact:

Re: blueprint string viewer

Post by SyncViews »

You need to strip that leading zero (likely a format version number).

Code: Select all

0eNrtWNmumzAQ/Rc/wxV2IAtS...
eNrtWNmumzAQ/Rc/wxV2IAtS...

cid0rz
Long Handed Inserter
Long Handed Inserter
Posts: 88
Joined: Sun Jul 31, 2016 5:52 pm
Contact:

Re: blueprint string viewer

Post by cid0rz »

Thank you! Now i got it with:

Code: Select all

    todecodestr = bprintfile.read()
    todecodestr = todecodestr[1:]
    bprintfile.close()

    decoded_data = base64.b64decode(todecodestr)
    mydata=zlib.decompress(decoded_data)
didn't notice the 0 :!:

Post Reply

Return to “Tools”