Serialization

Post Reply
Nore
Developer
Posts: 501
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

Serialization

by Nore » Post

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: 4290
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

by Sokomine » Post

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
Developer
Posts: 501
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

by Nore » Post

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.

User avatar
celeron55
Administrator
Posts: 533
Joined: Tue Apr 19, 2011 10:10
GitHub: celeron55
IRC: celeron55

by celeron55 » Post

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
Developer
Posts: 501
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

by Nore » Post

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
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

Why would you need to serialize functions?
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

Nore
Developer
Posts: 501
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

by Nore » Post

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
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

by rubenwardy » Post

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.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests