Serialization
Serialization
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
-
- Member
- Posts: 4290
- Joined: Sun Sep 09, 2012 17:31
- GitHub: Sokomine
- IRC: Sokomine
- In-game: Sokomine
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.
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.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.
Can you give an example where this would not be an issue?
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.
- rubenwardy
- Moderator
- Posts: 6978
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
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.
- 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.
- rubenwardy
- Moderator
- Posts: 6978
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
You could store function content as a string, and then interprete it into a function on table load.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.
Last edited by rubenwardy on Wed Jun 12, 2013 10:29, edited 1 time in total.
Who is online
Users browsing this forum: No registered users and 8 guests