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


C# ILuaState.PushString方法代码示例

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


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

示例1: AuxResume

		private static int AuxResume( ILuaState lua, ILuaState co, int narg )
		{
			if(!co.CheckStack(narg)) {
				lua.PushString("too many arguments to resume");
				return -1; // error flag
			}
			if( co.Status == ThreadStatus.LUA_OK && co.GetTop() == 0 )
			{
				lua.PushString( "cannot resume dead coroutine" );
				return -1; // error flag
			}
			lua.XMove( co, narg );
			ThreadStatus status = co.Resume( lua, narg );
			if( status == ThreadStatus.LUA_OK || status == ThreadStatus.LUA_YIELD )
			{
				int nres = co.GetTop();
				if(!lua.CheckStack(nres+1)) {
					co.Pop(nres); // remove results anyway;
					lua.PushString("too many results to resume");
					return -1; // error flag
				}
				co.XMove( lua, nres ); // move yielded values
				return nres;
			}
			else
			{
				co.XMove( lua, 1 ); // move error message
				return -1;
			}
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:30,代码来源:LuaCoroLib.cs

示例2: TBL_Concat

		private static int TBL_Concat( ILuaState lua )
		{
			string sep = lua.L_OptString( 2, "" );
			lua.L_CheckType( 1, LuaType.LUA_TTABLE );
			int i = lua.L_OptInt( 3, 1 );
			int last = lua.L_Opt( lua.L_CheckInteger, 4, lua.L_Len(1) );

			StringBuilder sb = new StringBuilder();
			for( ; i<last; ++i )
			{
				lua.RawGetI( 1, i );
				if( !lua.IsString(-1) )
					lua.L_Error(
						"invalid value ({0}) at index {1} in table for 'concat'",
						lua.L_TypeName(-1), i );
				sb.Append( lua.ToString(-1) );
				sb.Append( sep );
				lua.Pop( 1 );
			}
			if( i == last ) // add last value (if interval was not empty)
			{
				lua.RawGetI( 1, i );
				if( !lua.IsString(-1) )
					lua.L_Error(
						"invalid value ({0}) at index {1} in table for 'concat'",
						lua.L_TypeName(-1), i );
				sb.Append( lua.ToString(-1) );
				lua.Pop( 1 );
			}
			lua.PushString( sb.ToString() );
			return 1;
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:32,代码来源:LuaTableLib.cs

示例3: WidgetReadOper

        protected override bool WidgetReadOper(ILuaState lua, string key)
        {
            switch (key)
            {
                case "name":
                    lua.PushString(gameObject.name);
                    break;
                case "fDir":
                    lua.PushNumber(transform.localEulerAngles.y);
                    break;
                case "position":
                    Vector3ToStack(lua, transform.position);
                    break;
                case "localPosition":
                    Vector3ToStack(lua, transform.localPosition);
                    break;
                case "localRotate":
                    Vector3ToStack(lua, transform.localEulerAngles);
                    break;
                case "localScale":
                    Vector3ToStack(lua, transform.localScale);
                    break;
                case "ambientLight":
                    ColorToStack(lua, RenderSettings.ambientLight);
                    break;
                case "ambientIntensity":
#if UNITY_4_6
                    lua.PushNumber(1.0);
#else
                    lua.PushNumber(RenderSettings.ambientIntensity);
#endif
                    break;
                case "fog":
                    lua.PushBoolean(RenderSettings.fog);
                    break;
                case "fogColor":
                    ColorToStack(lua, RenderSettings.fogColor);
                    break;
                case "fogDensity":
                    lua.PushNumber(RenderSettings.fogDensity);
                    break;
                case "fogEndDistance":
                    lua.PushNumber(RenderSettings.fogEndDistance);
                    break;
                case "fogMode":
                    lua.PushInteger((int)RenderSettings.fogMode);
                    break;
                case "fogStartDistance":
                    lua.PushNumber(RenderSettings.fogStartDistance);
                    break;
                default:
                    return false;
            }
            return true;
        }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:55,代码来源:LuaExport.cs

示例4: 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

示例5: OpenLib

		public static int OpenLib( ILuaState lua )
		{
			var define = new NameFuncPair[]
			{
				new NameFuncPair( "encode", ENC_Encode ),
				new NameFuncPair( "decode", ENC_Decode ),
			};

			lua.L_NewLib( define );

			lua.PushString( ENC_UTF8 );
			lua.SetField( -2, "utf8" );

			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:15,代码来源:LuaEncLib.cs

示例6: Traceback

 private static int Traceback(ILuaState lua)
 {
     var msg = lua.ToString(1);
     if(msg != null) {
         lua.L_Traceback(lua, msg, 1);
     }
     // is there an error object?
     else if(!lua.IsNoneOrNil(1)) {
         // try its `tostring' metamethod
         if(!lua.L_CallMeta(1, "__tostring")) {
             lua.PushString("(no error message)");
         }
     }
     return 1;
 }
开发者ID:Jornason,项目名称:UniLua,代码行数:15,代码来源:LuaScriptController.cs

示例7: ENC_Encode

		private static int ENC_Encode( ILuaState lua )
		{
			var s = lua.ToString(1);
			var e = lua.ToString(2);
			if( e != ENC_UTF8 )
				throw new Exception("unsupported encoding:" + e);

			var bytes = Encoding.UTF8.GetBytes(s);
			var sb = new StringBuilder();
			for( var i=0; i<bytes.Length; ++i )
			{
				sb.Append( (char)bytes[i] );
			}
			lua.PushString( sb.ToString() );
			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:16,代码来源:LuaEncLib.cs

示例8: ENC_Decode

		private static int ENC_Decode( ILuaState lua )
		{
			var s = lua.ToString(1);
			var e = lua.ToString(2);
			if( e != ENC_UTF8 )
				throw new Exception("unsupported encoding:" + e);

			var bytes = new Byte[s.Length];
			for( int i=0; i<s.Length; ++i )
			{
				bytes[i] = (byte)s[i];
			}

			lua.PushString( Encoding.UTF8.GetString( bytes ) );
			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:16,代码来源:LuaEncLib.cs

示例9: ENC_Encode

        private static int ENC_Encode( ILuaState lua )
        {
            var s = lua.ToString(1);
            var e = lua.ToString(2);
            if( e != ENC_UTF8 )
                throw new Exception("unsupported encoding:" + e);

            var bytes = Encoding.UTF8.GetBytes(s);
            var sb = new StringBuilder();
            foreach( var b in bytes )
            {
                sb.Append( b );
            }
            lua.PushString( sb.ToString() );
            return 1;
        }
开发者ID:bharath1097,项目名称:UniLua,代码行数:16,代码来源:LuaEncLib.cs

示例10: OpenLib

		internal static int OpenLib( ILuaState lua )
		{
			NameFuncPair[] define = new NameFuncPair[]
			{
				new NameFuncPair( "assert", 		LuaBaseLib.B_Assert ),
				new NameFuncPair( "collectgarbage", LuaBaseLib.B_CollectGarbage ),
				new NameFuncPair( "dofile", 		LuaBaseLib.B_DoFile ),
				new NameFuncPair( "error", 			LuaBaseLib.B_Error ),
				new NameFuncPair( "ipairs", 		LuaBaseLib.B_Ipairs ),
				new NameFuncPair( "loadfile", 		LuaBaseLib.B_LoadFile ),
				new NameFuncPair( "load", 			LuaBaseLib.B_Load ),
				new NameFuncPair( "loadstring", 	LuaBaseLib.B_Load ),
				new NameFuncPair( "next", 			LuaBaseLib.B_Next ),
				new NameFuncPair( "pairs", 			LuaBaseLib.B_Pairs ),
				new NameFuncPair( "pcall", 			LuaBaseLib.B_PCall ),
				new NameFuncPair( "print", 			LuaBaseLib.B_Print ),
				new NameFuncPair( "rawequal", 		LuaBaseLib.B_RawEqual ),
				new NameFuncPair( "rawlen", 		LuaBaseLib.B_RawLen ),
				new NameFuncPair( "rawget", 		LuaBaseLib.B_RawGet ),
				new NameFuncPair( "rawset", 		LuaBaseLib.B_RawSet ),
				new NameFuncPair( "select", 		LuaBaseLib.B_Select ),
				new NameFuncPair( "getmetatable", 	LuaBaseLib.B_GetMetaTable ),
				new NameFuncPair( "setmetatable", 	LuaBaseLib.B_SetMetaTable ),
				new NameFuncPair( "tonumber", 		LuaBaseLib.B_ToNumber ),
				new NameFuncPair( "tostring", 		LuaBaseLib.B_ToString ),
				new NameFuncPair( "type", 			LuaBaseLib.B_Type ),
				new NameFuncPair( "xpcall", 		LuaBaseLib.B_XPCall ),
			};

			// set global _G
			lua.PushGlobalTable();
			lua.PushGlobalTable();
			lua.SetField( -2, "_G" );

			// open lib into global lib
			lua.L_SetFuncs( define, 0 );
			// lua.RegisterGlobalFunc( "type", 	LuaBaseLib.B_Type );
			// lua.RegisterGlobalFunc( "pairs", 	LuaBaseLib.B_Pairs );
			// lua.RegisterGlobalFunc( "ipairs", 	LuaBaseLib.B_Ipairs );
			// lua.RegisterGlobalFunc( "print",	LuaBaseLib.B_Print );
			// lua.RegisterGlobalFunc( "tostring",	LuaBaseLib.B_ToString );

			lua.PushString( LuaDef.LUA_VERSION );
			lua.SetField( -2, "_VERSION" );

			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:47,代码来源:LuaBaseLib.cs

示例11: FFI_ParseSignature

		// return `ReturnType', `FuncName', `ParameterTypes'
		private static int FFI_ParseSignature( ILuaState lua )
		{
			var signature = lua.ToString(1);
			var result = FuncSignatureParser.Parse( lua, signature );
			if( result.ReturnType != null )
				lua.PushString( result.ReturnType );
			else
				lua.PushNil();
			lua.PushString( result.FuncName );
			if( result.ParameterTypes != null ) {
				lua.NewTable();
				for( int i=0; i<result.ParameterTypes.Length; ++i ) {
					lua.PushString( result.ParameterTypes[i] );
					lua.RawSetI( -2, i+1 );
				}
			}
			else {
				lua.PushNil();
			}
			return 3;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:22,代码来源:LuaFFILib.cs

示例12: AuxResume

 private static int AuxResume( ILuaState lua, ILuaState co, int narg )
 {
     if( co.Status == ThreadStatus.LUA_OK && co.GetTop() == 0 )
     {
         lua.PushString( "cannot resume dead coroutine" );
         return -1; // error flag
     }
     lua.XMove( co, narg );
     ThreadStatus status = co.Resume( lua, narg );
     if( status == ThreadStatus.LUA_OK || status == ThreadStatus.LUA_YIELD )
     {
         int nres = co.GetTop();
         co.XMove( lua, nres ); // move yielded values
         return nres;
     }
     else
     {
         co.XMove( lua, 1 ); // move error message
         return -1;
     }
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:21,代码来源:LuaCoroLib.cs

示例13: Str_Sub

		private static int Str_Sub( ILuaState lua )
		{
			string s = lua.L_CheckString(1);
			int start = PosRelative( lua.L_CheckInteger(2), s.Length );
			int end = PosRelative( lua.L_OptInt(3, -1), s.Length );
			if( start < 1 ) start = 1;
			if( end > s.Length ) end = s.Length;
			if( start <= end )
				lua.PushString( s.Substring(start-1, end-start+1) );
			else
				lua.PushString( "" );
			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:13,代码来源:LuaStrLib.cs

示例14: Str_Reverse

		private static int Str_Reverse( ILuaState lua )
		{
			string s = lua.L_CheckString(1);
			StringBuilder sb = new StringBuilder(s.Length);
			for( int i=s.Length-1; i>=0; --i )
				sb.Append( s[i] );
			lua.PushString( sb.ToString() );
			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:9,代码来源:LuaStrLib.cs

示例15: Str_Char

		private static int Str_Char( ILuaState lua )
		{
			int n = lua.GetTop();
			StringBuilder sb = new StringBuilder();
			for( int i=1; i<=n; ++i )
			{
				int c = lua.L_CheckInteger(i);
				lua.L_ArgCheck( (char)c == c, i, "value out of range" );
				sb.Append( (char)c );
			}
			lua.PushString( sb.ToString() );
			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:13,代码来源:LuaStrLib.cs


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