From 81554fbf720300e36060a628c786902918328612 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Thu, 7 Jun 2012 00:03:42 +0300 Subject: Add minetest.serialize() and minetest.deserialize() --- doc/lua_api.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'doc/lua_api.txt') diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 16587144d..61bc8e1c2 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -805,6 +805,17 @@ minetest.get_item_group(name, group) -> rating ^ Get rating of a group of an item. (0 = not in group) minetest.get_node_group(name, group) -> rating ^ Deprecated: An alias for the former. +minetest.serialize(table) -> string +^ Convert a table containing tables, strings, numbers, booleans and nils + into string form readable by minetest.deserialize +^ Example: serialize({foo='bar'}) -> 'return { ["foo"] = "bar" }' +minetest.deserialize(string) -> table +^ Convert a string returned by minetest.deserialize into a table +^ String is loaded in an empty sandbox environment. +^ Will load functions, but they cannot access the global environment. +^ Example: deserialize('return { ["foo"] = "bar" }') -> {foo='bar'} +^ Example: deserialize('print("foo")') -> nil (function call fails) + ^ error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value) Global objects: minetest.env - EnvRef of the server environment and world. -- cgit v1.2.3