Vans S
Vans S

Reputation: 1813

mapping C# classes to LUA functions using LuaInterface

Is there a way to map classes directly to C# functions by just loading the class? Instead of making 100+ RegisterFunctions and mapping them?

EX: Something like

this.lua = new LuaInterface.Lua();
RegisterAll(Class1.MainClass);
lua.DoFile(this.filePath);

inside lua:

function Start
    MainClass.MappedPrintFunc("hihi");
end

Upvotes: 1

Views: 1650

Answers (1)

Vans S
Vans S

Reputation: 1813

You can do so by setting a variable in LUA to your function that exports funcs or props.

EX:

Class Manager()
public static GameLocalPlayer LocalPlayer { get; set; }

LuaInterace lua = new LuaInterface;
lua["variablename"]=Manager.LocalPlayer;  

---lua----
variablename.Health;
variablename:AttackTarget(target);

Upvotes: 2

Related Questions