Interop of LUA and vice versa
On this page we will explain how to interop LUA and interop C# from LUA.
This is a real unstable API which might not work, currently.
Valid LUA Types
There are several LUA types which are allowed in Onsharp when interacting with LUA or calling remote events. Following is a list of all valid LUA types:
String
Double
Integer
Boolean
Table
For the table you need a wrapper class in order to use it, the Onsharp.Interop.LuaTable
. It wraps the native value and offers functionality to manage this table. Please have a look in the XML documentation if you don't know how to use it. The LuaTable represents the list as well as the dictonary.
Export C# Method to LUA
Now we want to export a C# functions so we can use these functions in LUA. For that we need a function and marking the function as exportable like so:
To call the C# function we need to know two things: With which name the function was exported and the plugin id of the plugin the method is in. If we know these two things we can easily call the function like this:
Register Exportables
Import LUA Function
Importing the package is quite simple:
Now you could call a function like these:
by invoke them like this:
Last updated
Was this helpful?