Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua code can set table[0], but С# can't read it #315

Open
Killfrra opened this issue Oct 23, 2022 · 1 comment
Open

Lua code can set table[0], but С# can't read it #315

Killfrra opened this issue Oct 23, 2022 · 1 comment

Comments

@Killfrra
Copy link

Killfrra commented Oct 23, 2022

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
Copy link

vlOd2 commented Jun 3, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants