uncompressed blueprint string

Post Reply
ichVII
Long Handed Inserter
Long Handed Inserter
Posts: 98
Joined: Mon Feb 27, 2017 10:16 pm
Contact:

uncompressed blueprint string

Post by ichVII »

In addition to the import_stack and export_stack features, I would like to have an option to use similiar features with the uncompressed blueprint string. While set/get_blueprint_entities/tiles/entity_tags are great, it would be nice to have one combined access to all information.

I tried to inflate a string in lua, but I only found ways, that require specific libraries, which I propably cant or shouldnt include in a mod.

Alternatively adding game.inflate and game.deflate to inflate/deflate strings would solve my problem as well.

I am trying to change the colour of a coloured blueprint and if i could get access to the uncompressed blueprint string, it would be as easy as replacing the name of the blueprint in the uncompressed string. (at the end in item: …).

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: uncompressed blueprint string

Post by eradicator »

+1 for zip/deflate support

Would be handy to generate custom "exchange strings" too (for modded stuff other than blueprints).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

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

Re: uncompressed blueprint string

Post by DaveMcW »

As a workaround, you can include the zip library yourself. https://github.com/DaveMcW/blueprint-st ... rintstring

User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 450
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: uncompressed blueprint string

Post by raiguard »

+1. Having inflate / deflate and base64 encode/decode available to be used anywhere, not just for blueprints, would be amazing.
Don't forget, you're here forever.

User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 232
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: uncompressed blueprint string

Post by Therenas »

Raiguard wrote:
Wed Feb 05, 2020 3:33 pm
+1. Having inflate / deflate and base64 encode/decode available to be used anywhere, not just for blueprints, would be amazing.
Isn't base64 en- and decode already available in the core lualib util file?

User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 450
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: uncompressed blueprint string

Post by raiguard »

Well yes, but not zlib inflate and deflate.
Don't forget, you're here forever.

User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 450
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: uncompressed blueprint string

Post by raiguard »

This was added, so this topic can be moved now.
Don't forget, you're here forever.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: uncompressed blueprint string

Post by eradicator »

Raiguard wrote:
Tue Feb 18, 2020 3:35 pm
This was added, so this topic can be moved now.
Had to search a bit until i found what you mean so i'll post it here for future readers:

Code: Select all

LuaGameScript.encode_string(string) → string	Deflates and base64 encodes the given string.
LuaGameScript.decode_string(string) → string	Base64 decodes and inflates the given string.
As far as i know "blueprint exchange string" has some factorio specific decorations (version byte?). So i'm wondering if that needs to be manually handled?
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 450
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: uncompressed blueprint string

Post by raiguard »

Yes, the Factorio blueprint strings have a single digit at the beginning denoting a version. Remove the first character of a compressed blueprint string and it'll work with the new functions.
Don't forget, you're here forever.

Post Reply

Return to “Implemented mod requests”