[0.11.3] Old Serpent Library

Bugs that are actually features.
Scaevolus
Burner Inserter
Burner Inserter
Posts: 6
Joined: Tue Nov 18, 2014 11:58 pm
Contact:

[0.11.3] Old Serpent Library

Post by Scaevolus »

Minor issue: Factorio is using an old version of Serpent (v0.15) for dumping blueprints (and other data?).

The important change is that new Serpent (v0.27) has pretty array dumping.

An example blueprint is 7% smaller with a newer Serpent version.

Before (2159 chars)

Code: Select all

do local _={icons={[1]="assembling-machine-2",[2]="assembling-machine-2"},entities={[1]={orientation=0,position={x=-3.5,y=-0.5},entitynumber=1,type="assembling-machine",name="assembling-machine-2",direction=0},[2]={connections={red={},green={}},requestfilters={[1]={index=1,amount=1},[2]={index=2,amount=1},[3]={index=3,amount=1},[4]={index=4,amount=1},[5]={index=5,amount=1},[6]={index=6,amount=1},[7]={index=7,amount=1},[8]={index=8,amount=1},[9]={index=9,amount=1},[10]={index=10,amount=1}},orientation=0,position={x=-0.5,y=-1.5},entitynumber=2,type="logistic-container",name="logistic-chest-passive-provider",direction=0},[3]={connections={red={},green={}},direction=6,entitynumber=3,type="inserter",filters={[1]={index=1},[2]={index=2},[3]={index=3},[4]={index=4},[5]={index=5}},conditions={green={operator=">",count=1},logistics={operator="<",count=10},red={operator=">",count=1}},orientation=0,name="smart-inserter",position={x=-1.5,y=-1.5}},[4]={connections={red={},green={}},orientation=0,position={x=0.5,y=-0.5},entitynumber=4,type="electric-pole",name="medium-electric-pole",direction=0},[5]={connections={red={},green={}},direction=2,entitynumber=5,type="inserter",filters={[1]={index=1},[2]={index=2},[3]={index=3},[4]={index=4},[5]={index=5}},conditions={green={operator=">",count=1},logistics={operator="<",count=10},red={operator=">",count=1}},orientation=0,name="smart-inserter",position={x=0.5,y=-1.5}},[6]={orientation=0,position={x=2.5,y=-0.5},entitynumber=6,type="assembling-machine",name="assembling-machine-2",direction=0},[7]={connections={red={},green={}},requestfilters={[1]={index=1,amount=1},[2]={index=2,amount=1},[3]={index=3,amount=1},[4]={index=4,amount=1},[5]={index=5,amount=1},[6]={index=6,amount=1},[7]={index=7,amount=1},[8]={index=8,amount=1},[9]={index=9,amount=1},[10]={index=10,amount=1}},orientation=0,position={x=-0.5,y=0.5},entitynumber=7,type="logistic-container",name="logistic-chest-requester",direction=0},[8]={orientation=0,position={x=-1.5,y=0.5},entitynumber=8,type="inserter",name="fast-inserter",direction=2},[9]={orientation=0,position={x=0.5,y=0.5},entitynumber=9,type="inserter",name="fast-inserter",direction=6}}};return _;end
After (2017 chars)

Code: Select all

do local _={entities={{name="assembling-machine-2",direction=0,type="assembling-machine",entitynumber=1,position={y=-0.5,x=-3.5},orientation=0},{name="logistic-chest-passive-provider",connections={red={},green={}},direction=0,type="logistic-container",requestfilters={{index=1,amount=1},{index=2,amount=1},{index=3,amount=1},{index=4,amount=1},{index=5,amount=1},{index=6,amount=1},{index=7,amount=1},{index=8,amount=1},{index=9,amount=1},{index=10,amount=1}},entitynumber=2,position={y=-1.5,x=-0.5},orientation=0},{direction=6,entitynumber=3,filters={{index=1},{index=2},{index=3},{index=4},{index=5}},connections={red={},green={}},conditions={green={count=1,operator=">"},red={count=1,operator=">"},logistics={count=10,operator="<"}},name="smart-inserter",orientation=0,position={y=-1.5,x=-1.5},type="inserter"},{name="medium-electric-pole",connections={red={},green={}},direction=0,type="electric-pole",entitynumber=4,position={y=-0.5,x=0.5},orientation=0},{direction=2,entitynumber=5,filters={{index=1},{index=2},{index=3},{index=4},{index=5}},connections={red={},green={}},conditions={green={count=1,operator=">"},red={count=1,operator=">"},logistics={count=10,operator="<"}},name="smart-inserter",orientation=0,position={y=-1.5,x=0.5},type="inserter"},{name="assembling-machine-2",direction=0,type="assembling-machine",entitynumber=6,position={y=-0.5,x=2.5},orientation=0},{name="logistic-chest-requester",connections={red={},green={}},direction=0,type="logistic-container",requestfilters={{index=1,amount=1},{index=2,amount=1},{index=3,amount=1},{index=4,amount=1},{index=5,amount=1},{index=6,amount=1},{index=7,amount=1},{index=8,amount=1},{index=9,amount=1},{index=10,amount=1}},entitynumber=7,position={y=0.5,x=-0.5},orientation=0},{name="fast-inserter",direction=2,type="inserter",entitynumber=8,position={y=0.5,x=-1.5},orientation=0},{name="fast-inserter",direction=6,type="inserter",entitynumber=9,position={y=0.5,x=0.5},orientation=0}},icons={"assembling-machine-2","assembling-machine-2"}};return _;end

slpwnd
Factorio Staff
Factorio Staff
Posts: 1835
Joined: Sun Feb 03, 2013 2:51 pm
Contact:

Re: [0.11.3] Old Serpent Library

Post by slpwnd »

Not really a bug but a feature request. Moving to minor issues.

We use Serpent v0.15 because that was the time when relevant code was done:) Does anyone happen to know whether the loading is backwards compatible? Otherwise the migration would require to keep Serpent v0.15 for loading older versions and Serpent v0.27 for dumping the new ones.

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

Re: [0.11.3] Old Serpent Library

Post by DaveMcW »

slpwnd wrote:Does anyone happen to know whether the loading is backwards compatible? Otherwise the migration would require to keep Serpent v0.15 for loading older versions and Serpent v0.27 for dumping the new ones.
If you are using lua's load() or loadstring() it is backwards compatible.

Serpent v0.27 added a serpent.load() method, which is useful for guaranteeing there are no functions in the input. But you don't have to use it.

Rseding91
Factorio Staff
Factorio Staff
Posts: 14142
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.11.3] Old Serpent Library

Post by Rseding91 »

EDIT: this particular issue (below) was fixed in one of the 0.11 updates :)

I just discovered this issue today: https://github.com/pkulchenko/serpent/issues/8 while working on a Mod for Factorio.

It causes parts of saved numerical tables to be lost between the save-load process. It's very easy to reproduce (as the bug report shows) and caused me quite some grief trying to figure out what I had done wrong when in the end I didn't do anything wrong :P

A simple method to reproduce it (using a test mod):

https://www.dropbox.com/s/9862rxn1xwfr8 ... 0.zip?dl=0
  • install the mod
  • Start a new game
  • run /c remote.call("test", "run")
  • Save the game
  • Load the game
  • run /c remote.call("test", "print")
note how index 5 is missing after the save-load is done.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5246
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.11.3] Old Serpent Library

Post by Klonan »

Seems using a old library isn't really a bug

Bilka
Factorio Staff
Factorio Staff
Posts: 3308
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: [0.11.3] Old Serpent Library

Post by Bilka »

Didnt the library also get updated so this bug should no longer be present? I'm referring to the 0.16.0 changelog
Updated the serpent library to version 0.30.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Post Reply

Return to “Not a bug”