Page 1 of 1

Importing a Blueprint from string?

Posted: Thu Apr 27, 2017 6:00 pm
by ElGaucho
So, the new update added the very cool feature to export and import a blueprint as a string / from a string. Is there anyway to call these fuctionalities from a lua script? Especially importing a blueprint from a string would be awesome.

E.g. this one

Code: Select all

0eNqd0dsKgzAMBuB3+a8rqOu86KuMMTxko6BR2mxMpO8+D7vYQQbzMk36hSQDivpKnbMsMANs2bKHOQzw9sJ5Pb1J3xEMrFADBc6bKTrnXiJxOfuudRIVVAuCguWK7jBJOCoQixVLCzcH/YmvTUFuLPgJKXStH/+2PPUfvWis72HiENQXlf5HxU9JobKOyiWTrbi7LW6UvMN6BdabZv+U02nF803MywkVbuT8MpPWqc50vE/SEB6lJqOt
creates a circle made out of red belts. How can i now import that via a lua script

Re: Importing a Blueprint from string?

Posted: Thu Apr 27, 2017 7:12 pm
by gheift
Basic concept:
  • remove the leading "0", it is a some kind of version
  • decode the base64 string
  • decompress the result, which is zlib compressed ([1] may be helpful)
  • parse the json and do stuff with it
Kind regards, Gerhard

[1] https://unix.stackexchange.com/question ... ta-in-unix

Re: Importing a Blueprint from string?

Posted: Thu Apr 27, 2017 7:57 pm
by ElGaucho
I got the basic concept, but i thought there would be an easier way to use them with a build in function from factorio api ?

Re: Importing a Blueprint from string?

Posted: Sun Apr 30, 2017 10:05 am
by mophydeen
I'd like an easy api way.

eg. add a blueprint book to the "game blueprints"-frame in script.

Code: Select all

game.blueprints.add("somestring")

Re: Importing a Blueprint from string?

Posted: Sun Apr 30, 2017 3:44 pm
by daniel34
I had this already moved to Modding interface requests, but I see you already created a new topic: viewtopic.php?f=28&t=45704