public static void Main( string[] args ) { try { TestRemoting( ); using( Lua state = new Lua( ) ) { LuaFunction print = state["print"] as LuaFunction; LuaTable table = state.CreateTable(); table.SetValue( "test", "value" ); state["incomingTable"] = table; state.DoFile( "test.lua" ); var f = new Function(); state["TestClr"] = f; LuaFunction f1 = state["AFunction"] as LuaFunction; state.DoString( "AFunction = nil" ); print.Call( "AFunction returned: " + f1.Call( )[0] ); f1.Dispose( ); LuaFunction f2 = state["BFunction"] as LuaFunction; f2.Call( ); f2.Dispose( ); LuaTable sillytable = state["SillyTable"] as LuaTable; string str = sillytable["aaa"] as string; print.Call( str ); sillytable["aaa"] = 9001; foreach( var val in sillytable ) { Console.WriteLine("{0} = {1}", val.Key, val.Value); } print.Call( state["SillyTable", "aaa"] ); sillytable.Dispose( ); state.CreateTable( "table" ); print.Call( state["table"] as LuaTable ); print.Dispose( ); GC.KeepAlive(f); } } catch( LuaException e ) { Console.WriteLine( "Fail: " + e.Message ); } Console.ReadKey(); }
public static void Main( string[] args ) { try { using( Lua state = new Lua( ) ) { state.DoFile( "test.lua" ); LuaFunction f1 = state["AFunction"] as LuaFunction; state.DoString( "AFunction = nil" ); f1.Call( ); f1.Dispose( ); LuaFunction f2 = state["BFunction"] as LuaFunction; f2.Call( ); f2.Dispose( ); LuaFunction print = state["print"] as LuaFunction; LuaTable sillytable = state["SillyTable"] as LuaTable; string str = sillytable["aaa"] as string; print.Call( str ); sillytable["aaa"] = 9001; print.Call( state["SillyTable", "aaa"] ); sillytable.Dispose( ); state.CreateTable( "table" ); print.Call( state["table"] as LuaTable ); print.Dispose( ); } } catch( LuaException e ) { Console.WriteLine( "Fail: " + e.Message ); } }