protected override bool WidgetReadOper(ILuaState lua, string key) { switch (key) { case "speed": lua.PushNumber(_speed); return true; case "dwMMethod": lua.PushInteger(_dwMMethod); return true; case "bMoving": lua.PushBoolean(_bMoving); return true; case "fUpdateInterval": lua.PushNumber(_fUpdateInterval); return true; case "fAnimSpeed": if (_animator) { lua.PushNumber(_animator.speed); } else { lua.PushNumber(0); } return true; } return base.WidgetReadOper(lua, key); }
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; } }
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; }
public static int OpenLib( ILuaState lua ) { NameFuncPair[] define = new NameFuncPair[] { new NameFuncPair( "byte", Str_Byte ), new NameFuncPair( "char", Str_Char ), new NameFuncPair( "dump", Str_Dump ), new NameFuncPair( "find", Str_Find ), new NameFuncPair( "format", Str_Format ), new NameFuncPair( "gmatch", Str_Gmatch ), new NameFuncPair( "gsub", Str_Gsub ), new NameFuncPair( "len", Str_Len ), new NameFuncPair( "lower", Str_Lower ), new NameFuncPair( "match", Str_Match ), new NameFuncPair( "rep", Str_Rep ), new NameFuncPair( "reverse", Str_Reverse ), new NameFuncPair( "sub", Str_Sub ), new NameFuncPair( "upper", Str_Upper ), }; lua.L_NewLib( define ); CreateMetaTable( lua ); return 1; }
public static int OpenLib( ILuaState lua ) { var define = new NameFuncPair[] { new NameFuncPair( "clear_assembly_list", FFI_ClearAssemblyList ), new NameFuncPair( "add_assembly", FFI_AddAssembly ), new NameFuncPair( "clear_using_list", FFI_ClearUsingList ), new NameFuncPair( "using", FFI_Using ), new NameFuncPair( "parse_signature", FFI_ParseSignature ), new NameFuncPair( "get_type", FFI_GetType ), new NameFuncPair( "get_constructor", FFI_GetConstructor ), new NameFuncPair( "get_static_method", FFI_GetStaticMethod ), new NameFuncPair( "get_method", FFI_GetMethod ), new NameFuncPair( "call_method", FFI_CallMethod ), new NameFuncPair( "get_field", FFI_GetField ), new NameFuncPair( "get_field_value", FFI_GetFieldValue ), new NameFuncPair( "set_field_value", FFI_SetFieldValue ), new NameFuncPair( "get_prop", FFI_GetProp ), new NameFuncPair( "get_static_prop", FFI_GetStaticProp ), new NameFuncPair( "get_prop_value", FFI_GetPropValue ), new NameFuncPair( "set_prop_value", FFI_SetPropValue ), // new NameFuncPair( "call_constructor", FFI_CallConstructor ), }; lua.L_NewLib( define ); return 1; }
private static int FFI_CallMethod( ILuaState lua ) { var ffiMethod = (FFIMethodBase)lua.ToUserData(1); if (ffiMethod != null) { try { return ffiMethod.Call(lua); } catch( Exception e ) { lua.PushString( "call_method Exception: " + e.Message + "\nSource:\n" + e.Source + "\nStaceTrace:\n" + e.StackTrace ); lua.Error(); return 0; } } else { lua.PushString( "call_method cannot find MethodInfo" ); lua.Error(); return 0; } }
public static int applyTranslate(ILuaState luaState) { if (luaState.IsTable(-1)) { TranslateResult transRes = new TranslateResult(); // 位移目标 luaState.GetField(-1, "target"); transRes.target = (Unit)luaState.ToUserData(-1); luaState.Pop(1); // 行偏移量 luaState.GetField(-1, "offsetRow"); transRes.offsetRow = luaState.ToInteger(-1); luaState.Pop(1); // 列偏移量 luaState.GetField(-1, "offsetCol"); transRes.offsetCol = luaState.ToInteger(-1); luaState.Pop(1); //// 位移原因 //luaState.GetField(-1, "translateReason"); //transRes. = luaState.ToInteger(-1); //luaState.Pop(1); ProcessManager.getInstance().addResult(transRes); } return 0; }
void Awake() { Debug.Log("LuaScriptController Awake"); if( Lua == null ) { Lua = LuaAPI.NewState(); Lua.L_OpenLibs(); var status = Lua.L_DoFile( LuaScriptFile ); if( status != ThreadStatus.LUA_OK ) { throw new Exception( Lua.ToString(-1) ); } if( ! Lua.IsTable(-1) ) { throw new Exception( "framework main's return value is not a table" ); } AwakeRef = StoreMethod( "awake" ); StartRef = StoreMethod( "start" ); UpdateRef = StoreMethod( "update" ); LateUpdateRef = StoreMethod( "late_update" ); FixedUpdateRef = StoreMethod( "fixed_update" ); Lua.Pop(1); Debug.Log("Lua Init Done"); } CallMethod( AwakeRef ); }
public static int addEffectToBuff(ILuaState luaState) { SkillEffect effect = (SkillEffect)luaState.ToUserData(-2); BuffDataDriven buff = (BuffDataDriven)luaState.ToUserData(-1); buff.addEffect(effect); return 0; }
public static int applyDamage(ILuaState luaState) { if (luaState.IsTable(-1)) { DamageResult dmgRes = new DamageResult(); // 攻击者 luaState.GetField(-1, "attacker"); dmgRes.attacker = (Unit)luaState.ToUserData(-1); luaState.Pop(1); // 受害者 luaState.GetField(-1, "victim"); dmgRes.victim = (Unit)luaState.ToUserData(-1); luaState.Pop(1); // 伤害 luaState.GetField(-1, "physicalDamage"); dmgRes.physicalDamage = luaState.ToInteger(-1); luaState.Pop(1); luaState.GetField(-1, "spellDamage"); dmgRes.spellDamage = luaState.ToInteger(-1); luaState.Pop(1); luaState.GetField(-1, "hpRemoval"); dmgRes.hpRemoval = luaState.ToInteger(-1); luaState.Pop(1); // 伤害原因 luaState.GetField(-1, "damageReason"); dmgRes.damageReason = (BattleConsts.DamageReason)luaState.ToInteger(-1); luaState.Pop(1); ProcessManager.getInstance().addResult(dmgRes); } return 0; }
public static int addBuffToUnit(ILuaState luaState) { BuffDataDriven buff = (BuffDataDriven)luaState.ToUserData(-2); Unit unit = (Unit)luaState.ToUserData(-1); unit.addBuff(buff); return 0; }
protected override bool WidgetWriteOper(ILuaState lua, string key) { switch (key) { case "onFinish": { //lua.L_UnrefRegistry(ref m_pfnFinish); if (lua.Type(3) != LuaType.LUA_TFUNCTION) { return true; } lua.PushValue(3); m_pfnFinish = lua.L_Ref(LuaDef.LUA_REGISTRYINDEX); } return true; case "bDestroyOnFinish": m_bDestroyOnFinish = lua.ToBoolean(3); return true; case "finishTime": m_fEffectTime = (float)lua.ToNumber(3); return true; } return base.WidgetWriteOper(lua, key); }
private static int CO_Create( ILuaState lua ) { lua.L_CheckType( 1, LuaType.LUA_TFUNCTION ); ILuaState newLua = lua.NewThread(); lua.PushValue( 1 ); // move function to top lua.XMove( newLua, 1 ); // move function from lua to newLua return 1; }
private int Lua_ObjectMetaReader(ILuaState lua) { string key = lua.L_CheckString(2); if (WidgetReadOper(lua, key)) return 1; return 0; }
public static int initLib(ILuaState luaState) { var define = new NameFuncPair[] { new NameFuncPair("testLuaCall", testLuaCall), }; luaState.L_NewLib(define); return 1; }
public static int B_DoFile( ILuaState lua ) { string filename = lua.L_OptString( 1, null ); lua.SetTop( 1 ); if( lua.L_LoadFile( filename ) != ThreadStatus.LUA_OK ) lua.Error(); lua.CallK( 0, LuaDef.LUA_MULTRET, 0, DoFileContinuation ); return DoFileContinuation( lua ); }
private int Lua_ObjectMetaWriter(ILuaState lua) { string key = lua.L_CheckString(2); if (WidgetWriteOper(lua, key)) return 0; lua.RawSet(1); return 0; }
private int storeMethod(ILuaState luaState, string name) { luaState.GetField(-1, "cost"); if (luaState.IsFunction(-1)) { return luaState.L_Ref(LuaDef.LUA_REGISTRYINDEX); } return 0; }
public static int OpenLib( ILuaState lua ) { NameFuncPair[] define = new NameFuncPair[] { new NameFuncPair( "traceback", DBG_Traceback ), }; lua.L_NewLib( define ); return 1; }
protected virtual bool WidgetWriteOper(ILuaState lua, string key) { switch (key) { case "typeinfo": Debug.LogWarning("LuaObject set typeinfo failed ready only!"); return true; } return false; }
private static int FFI_AddAssembly( ILuaState lua ) { var name = lua.ToString(1); var assembly = Assembly.Load( name ); if( assembly != null ) AssemblyList.Add( assembly ); else UnityEngine.Debug.LogError("assembly not found:" + name); return 0; }
public static int OpenLib( ILuaState lua ) { NameFuncPair[] define = new NameFuncPair[] { new NameFuncPair("clock", OS_Clock), }; lua.L_NewLib( define ); return 1; }
public static int getEffectTarget(ILuaState luaState) { SkillEffect effect = (SkillEffect)luaState.ToUserData(-1); if (effect == null) { throw new ArgumentException("effect is null!"); } luaState.PushInteger(effect.getTarget()); return 1; }
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; }
public void initSkill(ILuaState luaState) { if ( !luaState.IsTable(-1) ) { Debug.Log(this._skillId + ".lua does not return a table!"); } this._cost = storeMethod(luaState,"cost"); luaState.Pop(1); // 主动效果 // 被动效果 }
public static int B_GetMetaTable( ILuaState lua ) { lua.L_CheckAny( 1 ); if( !lua.GetMetaTable( 1 ) ) { lua.PushNil(); return 1; // no metatable } lua.L_GetMetaField( 1, "__metatable" ); return 1; }
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 }
private int lua_ChangeCamera(ILuaState lua) { // int cameraIndex = lua.L_CheckInteger (2); // CameraMgr cameraMgr = Camera.main.GetComponent<CameraMgr>(); // if(cameraMgr != null) // { // cameraMgr.ActiveCamera(cameraIndex); // } return 0; }
protected override bool WidgetReadOper(ILuaState lua, string key) { switch (key) { case "bRecalculate": lua.PushBoolean(bRecalculate); break; default: return base.WidgetReadOper(lua, key); } return true; }
public static int B_Error( ILuaState lua ) { int level = lua.L_OptInt( 2, 1 ); lua.SetTop( 1 ); if( lua.IsString( 1 ) && level > 0 ) { lua.L_Where( level ); lua.PushValue( 1 ); lua.Concat( 2 ); } return lua.Error(); }
public static int CL_CloseNPCTalk(ILuaState lua) { CQuestMgr.Inst.ClearTalkNPC(); GameUIManager.Instance().HideFrame(GUIDefine.UIF_NPCTALKFRAME); return(0); }
private static int DBG_Traceback(ILuaState lua) { return(0); }
private static int AuxGetN(ILuaState lua, int n) { lua.L_CheckType(n, LuaType.LUA_TTABLE); return(lua.L_Len(n)); }
// @desc sizeDelta // @decl set_size_delta(self, x, y) // @decl set_size_delta(self, v) // @param x X座標 // @param y Y座標 // @param v vec2(x, y) private static int L_set_size_delta(ILuaState lua) { check_identifier(lua, 1, klassName); get_internal <RectTransform>(lua, 1).sizeDelta = get_vector2(lua, 2); return(0); }
// @desc sibling index // @decl set_as_last_sibling(self) private static int L_set_as_last_sibling(ILuaState lua) { check_identifier(lua, 1, klassName); get_internal <Transform>(lua, 1).SetAsLastSibling(); return(0); }
protected override int PushReturnValue(ILuaState lua, object o) { return(LuaStackUtil.PushRawValue(lua, o, ReturnType)); }
protected virtual int PushReturnValue(ILuaState lua, object o) { return(0); }
private static int FFI_ClearAssemblyList(ILuaState lua) { AssemblyList.Clear(); return(0); }
public static object ToRawValue(ILuaState lua, int index, Type t) { switch (t.FullName) { case "System.Boolean": return(lua.ToBoolean(index)); case "System.Char": { var s = lua.ToString(index); if (string.IsNullOrEmpty(s)) { return(null); } return(s[0]); } case "System.Byte": return((byte)lua.ToNumber(index)); case "System.SByte": return((sbyte)lua.ToNumber(index)); case "System.Int16": return((short)lua.ToNumber(index)); case "System.UInt16": return((ushort)lua.ToNumber(index)); case "System.Int32": return((int)lua.ToNumber(index)); case "System.UInt32": return((uint)lua.ToNumber(index)); case "System.Int64": return((Int64)lua.ToUserData(index)); case "System.UInt64": return((UInt64)lua.ToUserData(index)); case "System.Single": return((float)lua.ToNumber(index)); case "System.Double": return((double)lua.ToNumber(index)); case "System.Decimal": return((decimal)lua.ToUserData(index)); case "System.String": return(lua.ToString(index)); case "System.Object": return((object)lua.ToUserData(index)); default: { var u = lua.ToUserData(index); if (u == null) { return(null); } else { return(u); } } } }
private int L_Trace(ILuaState s) { Debug.Log("Lua trace: " + s.L_CheckString(1)); return(1); }
private int L_Pause(ILuaState s) { runFlag = false; _temp_state = s; return(s.YieldK(s.GetTop(), 0, null)); }
protected override int PushReturnValue(ILuaState lua, object o) { lua.PushLightUserData(o); return(1); }
private static int Str_Format(ILuaState lua) { int top = lua.GetTop(); StringBuilder sb = new StringBuilder(); int arg = 1; string format = lua.L_CheckString(arg); int s = 0; int e = format.Length; while (s < e) { if (format[s] != L_ESC) { sb.Append(format[s++]); continue; } if (format[++s] == L_ESC) { sb.Append(format[s++]); continue; } // else format item if (++arg > top) { lua.L_ArgError(arg, "no value"); } string form; s = ScanFormat(lua, format, s, out form); switch (format[s++]) // TODO: properly handle form { case 'c': { sb.Append((char)lua.L_CheckInteger(arg)); break; } case 'd': case 'i': { int n = lua.L_CheckInteger(arg); sb.Append(n.ToString()); break; } case 'u': { int n = lua.L_CheckInteger(arg); lua.L_ArgCheck(n >= 0, arg, "not a non-negative number is proper range"); sb.Append(n.ToString()); break; } case 'o': { int n = lua.L_CheckInteger(arg); lua.L_ArgCheck(n >= 0, arg, "not a non-negative number is proper range"); sb.Append(Convert.ToString(n, 8)); break; } case 'x': { int n = lua.L_CheckInteger(arg); lua.L_ArgCheck(n >= 0, arg, "not a non-negative number is proper range"); // sb.Append( string.Format("{0:x}", n) ); sb.AppendFormat("{0:x}", n); break; } case 'X': { int n = lua.L_CheckInteger(arg); lua.L_ArgCheck(n >= 0, arg, "not a non-negative number is proper range"); // sb.Append( string.Format("{0:X}", n) ); sb.AppendFormat("{0:X}", n); break; } case 'e': case 'E': { sb.AppendFormat("{0:E}", lua.L_CheckNumber(arg)); break; } case 'f': { sb.AppendFormat("{0:F}", lua.L_CheckNumber(arg)); break; } #if LUA_USE_AFORMAT case 'a': case 'A': #endif case 'g': case 'G': { sb.AppendFormat("{0:G}", lua.L_CheckNumber(arg)); break; } case 'q': { AddQuoted(lua, sb, arg); break; } case 's': { sb.Append(lua.L_CheckString(arg)); break; } default: // also treat cases `pnLlh' { return(lua.L_Error("invalid option '{0}' to 'format'", format[s - 1])); } } } lua.PushString(sb.ToString()); return(1); }
private static int FFI_ClearUsingList(ILuaState lua) { UsingList.Clear(); return(0); }
// public static int PushNew(ILuaState lua, RectTransform trs) { return(push_new <RectTransform>(lua, klassName, trs, trs.gameObject)); }
private static int StrFindAux(ILuaState lua, bool find) { string s = lua.L_CheckString(1); string p = lua.L_CheckString(2); int init = PosRelative(lua.L_OptInt(3, 1), s.Length); if (init < 1) { init = 1; } else if (init > s.Length + 1) // start after string's end? { lua.PushNil(); // cannot find anything return(1); } // explicit request or no special characters? if (find && (lua.ToBoolean(4) || NoSpecials(p))) { // do a plain search int pos = s.IndexOf(p, init - 1); if (pos >= 0) { lua.PushInteger(pos + 1); lua.PushInteger(pos + p.Length); return(2); } } else { int s1 = init - 1; int ppos = 0; bool anchor = p[ppos] == '^'; if (anchor) { ppos++; // skip anchor character } MatchState ms = new MatchState(); ms.Lua = lua; ms.Src = s; ms.SrcInit = s1; ms.SrcEnd = s.Length; ms.Pattern = p; ms.PatternEnd = p.Length; do { ms.Level = 0; int res = Match(ms, s1, ppos); if (res != -1) { if (find) { lua.PushInteger(s1 + 1); // start lua.PushInteger(res); // end return(PushCaptures(lua, ms, -1, 0) + 2); } else { return(PushCaptures(lua, ms, s1, res)); } } } while(s1++ < ms.SrcEnd && !anchor); } lua.PushNil(); // not found return(1); }
private static int Str_Match(ILuaState lua) { return(StrFindAux(lua, false)); }
// @desc anchoredPosition // @decl set_anchored_position(self, x, y) // @decl set_anchored_position(self, v) // @param x X座標 // @param y Y座標 // @param v vec2(x, y) private static int L_set_anchored_position(ILuaState lua) { check_identifier(lua, 1, klassName); get_internal <RectTransform>(lua, 1).anchoredPosition = get_vector2(lua, 2); return(0); }
private static int Str_Gsub(ILuaState lua) { string src = lua.L_CheckString(1); int srcl = src.Length; string p = lua.L_CheckString(2); LuaType tr = lua.Type(3); int max_s = lua.L_OptInt(4, srcl + 1); int anchor = 0; if (p[0] == '^') { p = p.Substring(1); anchor = 1; } int n = 0; MatchState ms = new MatchState(); StringBuilder b = new StringBuilder(srcl); lua.L_ArgCheck(tr == LuaType.LUA_TNUMBER || tr == LuaType.LUA_TSTRING || tr == LuaType.LUA_TFUNCTION || tr == LuaType.LUA_TTABLE, 3, "string/function/table expected"); ms.Lua = lua; ms.Src = src; ms.SrcInit = 0; ms.SrcEnd = srcl; ms.Pattern = p; ms.PatternEnd = p.Length; int s = 0; while (n < max_s) { ms.Level = 0; int e = Match(ms, s, 0); if (e != -1) { n++; Add_Value(ms, b, s, e); } if ((e != -1) && e > s) /* non empty match? */ { s = e; /* skip it */ } else if (s < ms.SrcEnd) { char c = src[s]; ++s; b.Append(c); } else { break; } if (anchor != 0) { break; } } b.Append(src.Substring(s, ms.SrcEnd - s)); lua.PushString(b.ToString()); lua.PushInteger(n); /* number of substitutions */ return(2); }
// @desc positionを設定する // @decl set_position(self, x, y, z) // @decl set_position(self, pos) // @param x X座標 // @param y Y座標 // @param z Z座標 // @param pos 座標を入れた配列 // @sample g.transform:set_position(0, 0, 0) // @sample local t = { 1, 2, 3 } // @sample g.transform:set_position(t) private static int L_set_position(ILuaState lua) { get_internal <Transform>(lua, 1).position = get_vector3(lua, 2); return(0); }
private static void AuxSort(ILuaState lua, int l, int u) { while (l < u) // for tail recursion { // sort elements a[l], a[(l+u)/2] and a[u] lua.RawGetI(1, l); lua.RawGetI(1, u); if (SortComp(lua, -1, -2)) // a[u] < a[l]? { Set2(lua, l, u); } else { lua.Pop(2); } if (u - l == 1) { break; // only 2 elements } int i = (l + u) / 2; lua.RawGetI(1, i); lua.RawGetI(1, l); if (SortComp(lua, -2, -1)) // a[i] < a[l]? { Set2(lua, i, l); } else { lua.Pop(1); // remove a[l] lua.RawGetI(1, u); if (SortComp(lua, -1, -2)) // a[u] < a[i]? { Set2(lua, i, u); } else { lua.Pop(2); } } if (u - l == 2) { break; // only 3 arguments } lua.RawGetI(1, i); // Pivot lua.PushValue(-1); lua.RawGetI(1, u - 1); Set2(lua, i, u - 1); /* a[l] <= P == a[u-1] <= a[u], only need to sort from l+1 to u-2 */ i = l; int j = u - 1; for (;;) /* invariant: a[l..i] <= P <= a[j..u] */ /* repeat ++i until a[i] >= P */ { lua.RawGetI(1, ++i); while (SortComp(lua, -1, -2)) { if (i >= u) { lua.L_Error("invalid order function for sorting"); } lua.Pop(1); /* remove a[i] */ lua.RawGetI(1, ++i); } /* repeat --j until a[j] <= P */ lua.RawGetI(1, --j); while (SortComp(lua, -3, -1)) { if (j <= l) { lua.L_Error("invalid order function for sorting"); } lua.Pop(1); /* remove a[j] */ lua.RawGetI(1, --j); } if (j < i) { lua.Pop(3); /* pop pivot, a[i], a[j] */ break; } Set2(lua, i, j); } lua.RawGetI(1, u - 1); lua.RawGetI(1, i); Set2(lua, u - 1, i); /* swap pivot (a[u-1]) with a[i] */ /* a[l..i-1] <= a[i] == P <= a[i+1..u] */ /* adjust so that smaller half is in [j..i] and larger one in [l..u] */ if (i - l < u - i) { j = l; i = i - 1; l = i + 2; } else { j = i + 1; i = u; u = j - 2; } AuxSort(lua, j, i); /* call recursively the smaller one */ } /* repeat the routine for the larger one */ }
// @decl set_local_euler(self, x, y, z) // @decl set_local_euler(self, pos) // @param x X座標 // @param y Y座標 // @param z Z座標 // @param pos オイラー角を入れた配列 private static int L_set_local_euler(ILuaState lua) { check_identifier(lua, 1, klassName); get_internal <Transform>(lua, 1).localRotation = Quaternion.Euler(get_vector3(lua, 2)); return(0); }
// quick sort //////////////////////////////////////////////////////// private static void Set2(ILuaState lua, int i, int j) { lua.RawSetI(1, i); lua.RawSetI(1, j); }
// @decl set_local_scale(self, x, y, z) // @decl set_local_scale(self, pos) // @param x X軸の拡大率 // @param y Y軸の拡大率 // @param z Z軸の拡大率 // @param pos 各軸の拡大率を入れた配列 private static int L_set_local_scale(ILuaState lua) { check_identifier(lua, 1, klassName); get_internal <Transform>(lua, 1).localScale = get_vector3(lua, 2); return(0); }
private static int Str_Rep(ILuaState lua) { // TODO throw new System.NotImplementedException(); }
public static void ExtendClass(ILuaState lua, NameFuncPair[] funcs) { extend_class(lua, klassName, funcs); }
private static int DoFileContinuation(ILuaState lua) { return(lua.GetTop() - 1); }
// @desc sibling index // @decl set_sibling_index(self, index) // @param index 指定するインデックス private static int L_set_sibling_index(ILuaState lua) { check_identifier(lua, 1, klassName); get_internal <Transform>(lua, 1).SetSiblingIndex(lua.ToInteger(-1)); return(0); }
public static int PushRawValue(ILuaState lua, object o, Type t) { switch (t.FullName) { case "System.Boolean": { lua.PushBoolean((bool)o); return(1); } case "System.Char": { lua.PushString(((char)o).ToString()); return(1); } case "System.Byte": { lua.PushNumber((byte)o); return(1); } case "System.SByte": { lua.PushNumber((sbyte)o); return(1); } case "System.Int16": { lua.PushNumber((short)o); return(1); } case "System.UInt16": { lua.PushNumber((ushort)o); return(1); } case "System.Int32": { lua.PushNumber((int)o); return(1); } case "System.UInt32": { lua.PushNumber((uint)o); return(1); } case "System.Int64": { throw new NotImplementedException(); } case "System.UInt64": { lua.PushUInt64((ulong)o); return(1); } case "System.Single": { lua.PushNumber((float)o); return(1); } case "System.Double": { lua.PushNumber((double)o); return(1); } case "System.Decimal": { lua.PushLightUserData((decimal)o); return(1); } case "System.String": { lua.PushString(o as string); return(1); } case "System.Object": { lua.PushLightUserData((object)o); return(1); } default: { lua.PushLightUserData(o); return(1); } } }
private static int Str_Find(ILuaState lua) { return(StrFindAux(lua, true)); }