当前位置: 首页>>代码示例>>C#>>正文


C# ILuaState.CreateTable方法代码示例

本文整理汇总了C#中ILuaState.CreateTable方法的典型用法代码示例。如果您正苦于以下问题:C# ILuaState.CreateTable方法的具体用法?C# ILuaState.CreateTable怎么用?C# ILuaState.CreateTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILuaState的用法示例。


在下文中一共展示了ILuaState.CreateTable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateMetaTable

		private static void CreateMetaTable( ILuaState lua )
		{
			lua.CreateTable(0, 1); // table to be metatable for strings
			lua.PushString( "" ); // dummy string
			lua.PushValue( -2 ); // copy table
			lua.SetMetaTable( -2 ); // set table as metatable for strings
			lua.Pop( 1 );
			lua.PushValue( -2 ); // get string library
			lua.SetField( -2, "__index" ); // metatable.__index = string
			lua.Pop( 1 ); // pop metatable
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:11,代码来源:LuaStrLib.cs

示例2: CreateSearchersTable

		private static void CreateSearchersTable( ILuaState lua )
		{
			CSharpFunctionDelegate[] searchers = new CSharpFunctionDelegate[]
			{
				SearcherPreload,
				SearcherLua,
			};
			lua.CreateTable( searchers.Length, 0 );
			for( int i=0; i<searchers.Length; ++i )
			{
				lua.PushValue( -2 ); // set `package' as upvalue for all searchers
				lua.PushCSharpClosure( searchers[i], 1 );
				lua.RawSetI( -2, i+1 );
			}
		}
开发者ID:bharath1097,项目名称:UniLua,代码行数:15,代码来源:LuaPkgLib.cs

示例3: TBL_Pack

		private static int TBL_Pack( ILuaState lua )
		{
			int n = lua.GetTop(); // number of elements to pack
			lua.CreateTable( n, 1 ); // create result table
			lua.PushInteger( n );
			lua.SetField( -2, "n" ); // t.n = number of elements
			if( n > 0 ) // at least one element?
			{
				lua.PushValue( 1 );
				lua.RawSetI( -2, 1 ); // insert first element
				lua.Replace( 1 ); // move table into index 1
				for( int i=n; i>=2; --i ) // assign other elements
					lua.RawSetI( 1, i );
			}
			return 1; // return table
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:16,代码来源:LuaTableLib.cs

示例4: createargtable

 /// <summary>
 /// Create the 'arg' table, which stores all arguments from the
 /// command line ('argv'). It should be aligned so that, at index 0,
 /// it has 'argv[script]', which is the script name. The arguments
 /// to the script (everything after 'script') go to positive indices;
 /// other arguments (before the script name) go to negative indices.
 /// If there is no script name, assume interpreter's name as base.
 /// </summary>
 static void createargtable(ILuaState L, String[] argv, int argc, int script)
 {
     int i, narg;
     if (script == argc) script = 0;  /* no script name? */
     narg = argc - (script + 1);  /* number of positive indices */
     L.CreateTable(narg, script + 1);
     for (i = 0; i < argc; i++)
     {
         L.PushString(argv[i]);
         L.RawSetI(-2, i - script);
     }
     L.SetGlobal("arg");
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:21,代码来源:Program.cs


注:本文中的ILuaState.CreateTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。