ssilk wrote:What I was wondering: as it looks for me, the BPs are lua-code. Well, this is the most future compatible way and good enough for now, but I won't call it then blueprint anymore. Isn't that not much more like a function?
The way it work is Factorio uses a serialization library called serpent
, you can see this if you type
Code: Select all
Should print the contents of your main inventory. This is what I use to export the blueprint data from factorio. To import the data you run the output though a function called loadstring. This is where the trouble comes in, loadstring will load a string as lua code and the allow you to execute. On the main lua page about loadstring it has "Before you use it, make sure that there is no simpler way to solve the problem at hand.". Obviously I ignored that advise.
ssilk wrote:I mean everything can be shared with this, not only BPs but also other useful Lua code, which is to small as mod or give do fix bugs during a game. This is cool.
It is but it means you can never use this mod in multiplayer with people you don't trust as they will always have access to a console. I would like to work around this issue at some point as it really doesn't sit well we me.
ssilk wrote:But in my eyes the BPs are a special file format, or two (compressed and human readable; maybe a mix of pure ascii graphics would and some description part might be also an idea?), and the format should be part of factorio core, but is some interpreted (not directly executed) format.
But it is the right way to implement and discuss this first with blueprints.
It would be nice if there was a official format but it is still early days. This is only an issue because of the text input method we have to use to get data into factorio. If we could load a file from disk it wouldn't matter how big the files were but sadly loading data from disk would cause desync as it can be different in 2 locations.
Ultimately going forward I will need to write an import function that doesn't use loadstring, I avoided doing this for the first release as I wanted to get something out and see what people thought. Once Foreman has a import function that is not executing lua code directly I'll be a lot happier.
But only a bit.
Your post pretty much sums up my though process leading up to release and why I stripped out the crazy format I had invented. Any format needs to be easy to use for other mods so we are not locked in to using what ever drunken crazy idea I came up with even if that means I'm running lua code from untrusted sources in the first release. Glad there is a discussion going on.
I'm updating pocket bots for multiplayer use at the moment but after that Foreman will probably get some more features added. I'm thinking a mirror blueprint feature would be a nice addition as it is something missing in vanilla factorio which shouldn't be to hard to implement. Keep posting blueprints, was great seeing the ones that Boogieman14 posted, even if his defenses are slightly lacking (More turrets!)