Lua code can set table[0], but С# can't read it
Killfrra opened this issue · 1 comments
Killfrra commented
Setup:
T = {}
T[0] = "something"
Callback(T)
static void Callback(Table table)
{
foreach(var pair in table.Pairs)
{
Console.WriteLine($"{pair.Key} {pair.Value.UserData.Object}");
}
DynValue dynObj = table.Get(0);
Console.WriteLine(dynObj);
}
Result:
0 something
nil
The problem is somewhere here in Table.cs
if (key.Type == DataType.Number)
{
int idx = GetIntegralKey(key.Number);
if (idx > 0)
{
Set(idx, value);
return;
}
}
Set
is not called
vlOd2 commented
Set is not called
You can even see in the code, that idx must be bigger than 0 to be called, since indexes in Lua start at 1, NOT at 0 (as it's a general convention and you are recommended to use 1, not 0)