C
C#11mo 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
Thinker11mo ago
What library are you using to interoperative with C# from Lua?
Dzhake
DzhakeOP11mo ago
NLua (forgot to say this somewhere but in title catsweat )
Thinker
Thinker11mo ago
oh, sorry
Dzhake
DzhakeOP11mo ago
(it's fine, nobody cares about titles, ik)
Pobiega
Pobiega11mo 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
DzhakeOP11mo 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
Pobiega11mo ago
There you go
Dzhake
DzhakeOP11mo ago
i can probably just write helper function which converts string to T, and then calls function i needed Thanks for help!
Want results from more Discord servers?
Add your server