WeaselGames / godot_luaAPI

Godot LuaAPI
https://luaapi.weaselgames.info
Other
347 stars 27 forks source link

LuaAPI gives C# null Callables #170

Closed Trey2k closed 9 months ago

Trey2k commented 9 months ago

Describe the bug While working on #169 i noticed c# fails to pull lua callables.

To Reproduce The following CS class gets a null Callable. While the equivalent GDScript works as expected.

using Godot;

using System;

public partial class Node2D : Godot.Node2D
{
    private LuaApi lua = new LuaApi();

    public override void _Ready() {
        LuaError error = lua.DoString(@"
                                  function test()
                                    return ""This is a test message.""
                                  end
                                  ");

        if (error != null && error.Message != "") {
            GD.Print("An error occurred calling DoString.");
            GD.Print("ERROR %d: %s", error.Type, error.Message);
        }

        var val = lua.PullVariant("test");
        if (val.GetType() == typeof(LuaError)) {
            GD.Print("ERROR %d: %s", error.Type, error.Message);
            return;
        }

        Callable test = val.AsCallable();
        Godot.Collections.Array Params = new();
        GD.Print(test.Call(Params));
    }
}

Expected behavior A valid Callable returned

Enviromint:

Trey2k commented 9 months ago

This issue with probably not be resolved for awhile. I suggest c# users stick with lua.call_function for now.

Trey2k commented 9 months ago

Resolved by #172, i dont think C# will get CallableCustoms any time soon.