Skip to content

Overriding Eq metamethod not invoking specified LuaFunction #318

@julcreutz

Description

@julcreutz

Overriding the equality method of a lua table like this function:

private static readonly LuaFunction eq = new(nameof(eq), static (context, _) =>
{
    var a = CharactersByTable[context.GetArgument<LuaTable>(0)];
    var b = CharactersByTable[context.GetArgument<LuaTable>(1)];

    var result = a == b;

    return new ValueTask<int>(context.Return(result));
});

And assigning it to a lua table like so:

new LuaTable
{
    Metatable = Metatable ??= new LuaTable
    {
        [Metamethods.Eq] = eq
    }
};

does not actually invoke the LuaFunction when using the == operator inside Lua.

Is this a known issue that only the Index and Newindex operators are implemented?
Version 0.5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions