Serialization

Nore
Member
 
Posts: 468
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

Serialization

by Nore » Sun Jun 09, 2013 17:11

Currently, the serialization is quite limited (cannot serialize functions, coroutines, etc.). What would you think of adding TamedPluto in the libraries ? http://luaos.net/pages/tamed-pluto.php
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

by Sokomine » Sun Jun 09, 2013 21:10

The main problem with the serialization not beeing able to handle functions is that you get an error once a function is encountered. An option to just print/store/ignore "function bla" might help in a lot of cases. I don't know how good the TamedPluto libs are. Lua does not seem particulary forthcoming with helpful error messages, so it won't matter much if that lib's not very good at that point either.
A list of my mods can be found here.
 

Nore
Member
 
Posts: 468
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

by Nore » Mon Jun 10, 2013 06:37

I found some Lua code that serializes functions, etc..., but it can't serialize coroutines. However, coroutine serialization would be a very powerful feature for coding mods.
 

celeron55
Member
 
Posts: 430
Joined: Tue Apr 19, 2011 10:10

by celeron55 » Tue Jun 11, 2013 07:28

Nore wrote:I found some Lua code that serializes functions, etc..., but it can't serialize coroutines. However, coroutine serialization would be a very powerful feature for coding mods.


Function and coroutine serialization is really painful when trying to do stuff that has any kind of cross-version compatibility. And Minetest worlds can be very old.

Can you give an example where this would not be an issue?
 

Nore
Member
 
Posts: 468
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

by Nore » Tue Jun 11, 2013 07:38

I could, but I found that TamedPluto can't serialize coroutines with LuaJIT enabled. However, it would perhaps be doable to replace the current serialization with one that supports functions, without having version issues, since it will still use loadstring. If you think it is a too big secuity issue, what would be at least needed to do is to prevent crash when serializing, by ignoring the types that cannot be serialized.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Tue Jun 11, 2013 11:19

Why would you need to serialize functions?
 

Nore
Member
 
Posts: 468
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

by Nore » Tue Jun 11, 2013 11:25

You see the Luacontroller in mesecons? I wanted to allow using for/while/function/etc., but:
- the code would not hang the server forever, if looping
- the code would be executed only once
The idea I had was to add a coroutine.yield() each iteration of a loop, or each time a function is entered. However, if the code continued after server restart, the coroutine would have needed to be serialized.

About serializing functions, mesecons would crash with Luacontroller before a recent fix. What would be at least needed is prevention from crash.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Wed Jun 12, 2013 10:28

Nore wrote:You see the Luacontroller in mesecons? I wanted to allow using for/while/function/etc., but:
- the code would not hang the server forever, if looping
- the code would be executed only once
The idea I had was to add a coroutine.yield() each iteration of a loop, or each time a function is entered. However, if the code continued after server restart, the coroutine would have needed to be serialized.

About serializing functions, mesecons would crash with Luacontroller before a recent fix. What would be at least needed is prevention from crash.


You could store function content as a string, and then interprete it into a function on table load.
Last edited by rubenwardy on Wed Jun 12, 2013 10:29, edited 1 time in total.
 


Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 7 guests