Пример #1
0
    public void Close()
    {
        Started = false;
        SharpLua.LuaObject close = L.GetFunction("close");
        L.CallFunction(close);

        L.Close();
        L = null;
    }
Пример #2
0
    public void FixedUpdate()
    {
        if (!Started)
        {
            return;
        }

        SharpLua.LuaObject fixedupdate = L.GetFunction("fixedupdate");
        L.CallFunction(fixedupdate, Time.fixedDeltaTime);
    }
Пример #3
0
    public void Update()
    {
        if (!Started)
        {
            return;
        }

        SharpLua.LuaObject update = L.GetFunction("update");
        L.CallFunction(update, Time.deltaTime);
    }
Пример #4
0
    public LuaVM(string main, string init)
    {
        L = new SharpLua(main, init);

        SharpLua.LuaObject     set_print  = L.GetFunction("set_print");
        SharpLua.SharpFunction sharpPrint = LuaPrint;
        L.CallFunction(set_print, sharpPrint);

        SharpLua.LuaObject     loader    = L.GetFunction("unity_res_load");
        SharpLua.SharpFunction luaLoader = LuaLoader;
        L.CallFunction(loader, luaLoader);
    }
Пример #5
0
    public void Start(params object[] args)
    {
        Started = true;
        SharpLua.LuaObject init = L.GetFunction("init");
        L.CallFunction(init);

        SharpLua.LuaObject     message  = L.GetFunction("set_call_sharp");
        SharpLua.SharpFunction sharpMsg = LuaCaller;
        L.CallFunction(message, sharpMsg);

        SharpLua.LuaObject start = L.GetFunction("start");
        L.CallFunction(start, args);
    }
Пример #6
0
    static public void Main()
    {
        SharpLua l = new SharpLua("main.lua");

        SharpLua.LuaObject load   = l.GetFunction("load");
        SharpLua.LuaObject f      = (SharpLua.LuaObject)l.CallFunction(load, "return ...")[0];
        object[]           result = l.CallFunction(f, "Hello World", l);
        Console.WriteLine((string)result[0]);
        Console.WriteLine(result[1].GetType());
        SharpLua.LuaObject gc = l.GetFunction("collectgarbage");
        l.CallFunction(gc, "collect");
        l.CollectGarbage();

        SharpLua.LuaObject     init = l.GetFunction("init");
        SharpLua.SharpFunction func = FuncCallByLua;
        l.CallFunction(init, func);
        SharpLua.LuaObject callback = l.GetFunction("callback");
        l.CallFunction(callback, 1, null, "string");
    }
Пример #7
0
 public void GC()
 {
     SharpLua.LuaObject gc = L.GetFunction("collectgarbage");
     L.CallFunction(gc, "collect");
     L.CollectGarbage();
 }
Пример #8
0
 public void CallLua(params object[] args)
 {
     SharpLua.LuaObject input = L.GetFunction("call_by_sharp");
     L.CallFunction(input, args);
 }