Page 1 of 1

[0.11.3] Old Serpent Library

Posted: Wed Nov 19, 2014 12:22 am
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

Re: [0.11.3] Old Serpent Library

Posted: Thu Nov 20, 2014 7:36 pm
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.

Re: [0.11.3] Old Serpent Library

Posted: Thu Nov 20, 2014 11:25 pm
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.

Re: [0.11.3] Old Serpent Library

Posted: Sun Nov 23, 2014 10:02 pm
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.

Re: [0.11.3] Old Serpent Library

Posted: Mon Feb 12, 2018 1:15 pm
by Klonan
Seems using a old library isn't really a bug

Re: [0.11.3] Old Serpent Library

Posted: Mon Feb 12, 2018 1:19 pm
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.