Open
Description
For better data-exchange from C# to Lua I would really like to have a LuaTable initializer that I can just pass an array, a dictionary, or both and preferably with internalized LuaValue conversion.
This would be good enough:
LuaValue[] array = ...
var arrayTable = new LuaTable(array);
IDictionary<LuaValue, LuaValue> dict = ...
var dictTable = new LuaTable(dict);
// and both:
var table = new LuaTable(array, dict);
While this would be great:
bool[] boolArray = ...
var arrayTable = new LuaTable(boolArray);
Dictionary<int, SomeUserDataType> userdataDict = ...
var dictTable = new LuaTable(userdataDict);
// and both:
float[] floatArray = ...
Dictionary<string, int> intDict = ...
var table = new LuaTable(floatArray, intDict);
And for best Unity serialization support, since it cannot serialize dictionaries, using two lists for dictionary keys and values to avoid having to first create a dictionary that would then internally get converted to LuaValueDictionary:
ILuaUserData[] array = ...
IEnumerable<string> keys = ...
IEnumerable<int> values = ...
var dictTable = new LuaTable(array, keys, values);
The keys and values enumerables need to have matching lengths.
Again, the types are just for example. Supported LuaValue Types should be automatically converted, otherwise it throws.
Metadata
Metadata
Assignees
Labels
No labels