We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello!
I'd like to make a extension function in primitive type such as string, byte[], byte and so one.
string
byte[]
byte
I tested with this code but seems not suported in NLua.
Is there any a way to available access a extension function?
namespace LuaConsoleApp { internal class Program { static void Main(string[] args) { using (Lua lua = new Lua()) { lua.State.Encoding = Encoding.UTF8; lua["a"] = "a"; lua.LoadCLRPackage(); lua.DoString("import('LuaConsoleApp','LuaConsoleApp.StringExtensions')"); lua.DoString("a:AddString()"); Console.WriteLine(lua["a"]); } } } } namespace LuaConsoleApp.StringExtensions { public static class StringExtensions { public static string AddString(this string str) { return str += "a"; } } }
Exception
NLua.Exceptions.LuaScriptException: '[string "chunk"]:1: attempt to call a nil value (method 'AddString')'
The text was updated successfully, but these errors were encountered:
It's because a is a Lua string and not C# string. Try a = StringExtensions.AddString(a) and see if it works
a = StringExtensions.AddString(a)
Sorry, something went wrong.
No branches or pull requests
Hello!
I'd like to make a extension function in primitive type such as
string
,byte[]
,byte
and so one.I tested with this code but seems not suported in NLua.
Is there any a way to available access a extension function?
Exception
The text was updated successfully, but these errors were encountered: