C
C#5mo ago
Dzhake

[NLua] How to call function which has <T> from lua?

I have function in C#, which has <T> parameter. How can I call that function with lua?
8 Replies
Thinker
Thinker5mo ago
What library are you using to interoperative with C# from Lua?
Dzhake
Dzhake5mo ago
NLua (forgot to say this somewhere but in title catsweat )
Thinker
Thinker5mo ago
oh, sorry
Dzhake
Dzhake5mo ago
(it's fine, nobody cares about titles, ik)
Pobiega
Pobiega5mo ago
That might be tricky. See, generic C# functions (having one or more <T> arguments) are created as distinct separate functions at compile time meaning A<string> and A<int> get turned into two separate functions in C# you can access a method/class like this at runtime via reflection so if you can somehow invoke reflection or make a "helper" method that you can call from NLua
Dzhake
Dzhake5mo ago
Do they have any "usual" renaming which i could call? after dicussing a bit, looks like this is xy problem lol because i wanted to check if object has some type from lua and now i know that i can use GetType().FullName, which is a string, so i don't need T
Pobiega
Pobiega5mo ago
There you go
Dzhake
Dzhake5mo ago
i can probably just write helper function which converts string to T, and then calls function i needed Thanks for help!