public bool SetFieldLua(Movie movie, string key) { if (luaState==null) return false; Lua.lua_State l = (Lua.lua_State)luaState; /* 1: LWF_Movie instance */ /* 2: key */ /* 3: value */ if (Lua.lua_isstring(l, 3)!=0 && movie.SearchText(key)) { movie.lwf.SetText( movie.GetFullName() + "." + key, Lua.lua_tostring(l, 3).ToString()); } Lua.lua_getglobal(l, "LWF"); /* -1: LWF.Instances */ if (!Lua.lua_istable(l, -1)) { Lua.lua_pop(l, 1); /* 0 */ return false; } Lua.lua_getfield(l, -1, "Instances"); /* -2: LWF */ /* -1: LWF.Instances */ Lua.lua_remove(l, -2); /* -1: LWF.Instances */ if (!Lua.lua_istable(l, -1)) { Lua.lua_pop(l, 1); /* 0 */ return false; } Lua.lua_getfield(l, -1, instanceIdString); /* -2: LWF.Instances */ /* -1: LWF.Instances.<instanceId> */ Lua.lua_remove(l, -2); /* -1: LWF.Instances.<instanceId> */ if (!Lua.lua_istable(l, -1)) { Lua.lua_pop(l, 1); /* 0 */ return false; } Lua.lua_getfield(l, -1, "Movies"); /* -2: LWF.Instances.<instanceId> */ /* -1: LWF.Instances.<instanceId>.Movies */ Lua.lua_remove(l, -2); /* -1: LWF.Instances.<instanceId>.Movies */ if (!Lua.lua_istable(l, -1)) { Lua.lua_pop(l, 1); return false; } string s = movie.iObjectId.ToString(); Lua.lua_getfield(l, -1, s); /* -2: LWF.Instances.<instanceId>.Movies */ /* -1: LWF.Instances.<instanceId>.Movies.<iObjectId> */ if (!Lua.lua_istable(l, -1)) { Lua.lua_pop(l, 1); /* -1: LWF.Instances.<instanceId>.Movies */ Lua.lua_newtable(l); /* -2: LWF.Instances.<instanceId>.Movies */ /* -1: table */ Lua.lua_pushvalue(l, -1); /* -3: LWF.Instances.<instanceId>.Movies */ /* -2: table */ /* -1: table */ Lua.lua_setfield(l, -3, s); /* -2: LWF.Instances.<instanceId>.Movies */ /* -1: table LWF.Instances.<instanceId>.Movies.<iObjectId> */ } Lua.lua_pushvalue(l, 3); /* -2: LWF.Instances.<instanceId>.Movies.<iObjectId> */ /* -1: value */ Lua.lua_setfield(l, -2, key); /* -1: LWF.Instances.<instanceId>.Movies.<iObjectId> */ Lua.lua_pop(l, 1); /* 0 */ return true; }
public bool SetFieldLua(Movie movie, string key) { if (luaState == null) { return(false); } Lua.lua_State l = (Lua.lua_State)luaState; /* 1: LWF_Movie instance */ /* 2: key */ /* 3: value */ if (Lua.lua_isstring(l, 3) != 0 && movie.SearchText(key)) { movie.lwf.SetText( movie.GetFullName() + "." + key, Lua.lua_tostring(l, 3).ToString()); } Lua.lua_getglobal(l, "LWF"); /* -1: LWF.Instances */ if (!Lua.lua_istable(l, -1)) { Lua.lua_pop(l, 1); /* 0 */ return(false); } Lua.lua_getfield(l, -1, "Instances"); /* -2: LWF */ /* -1: LWF.Instances */ Lua.lua_remove(l, -2); /* -1: LWF.Instances */ if (!Lua.lua_istable(l, -1)) { Lua.lua_pop(l, 1); /* 0 */ return(false); } Lua.lua_getfield(l, -1, instanceIdString); /* -2: LWF.Instances */ /* -1: LWF.Instances.<instanceId> */ Lua.lua_remove(l, -2); /* -1: LWF.Instances.<instanceId> */ if (!Lua.lua_istable(l, -1)) { Lua.lua_pop(l, 1); /* 0 */ return(false); } Lua.lua_getfield(l, -1, "Movies"); /* -2: LWF.Instances.<instanceId> */ /* -1: LWF.Instances.<instanceId>.Movies */ Lua.lua_remove(l, -2); /* -1: LWF.Instances.<instanceId>.Movies */ if (!Lua.lua_istable(l, -1)) { Lua.lua_pop(l, 1); return(false); } string s = movie.iObjectId.ToString(); Lua.lua_getfield(l, -1, s); /* -2: LWF.Instances.<instanceId>.Movies */ /* -1: LWF.Instances.<instanceId>.Movies.<iObjectId> */ if (!Lua.lua_istable(l, -1)) { Lua.lua_pop(l, 1); /* -1: LWF.Instances.<instanceId>.Movies */ Lua.lua_newtable(l); /* -2: LWF.Instances.<instanceId>.Movies */ /* -1: table */ Lua.lua_pushvalue(l, -1); /* -3: LWF.Instances.<instanceId>.Movies */ /* -2: table */ /* -1: table */ Lua.lua_setfield(l, -3, s); /* -2: LWF.Instances.<instanceId>.Movies */ /* -1: table LWF.Instances.<instanceId>.Movies.<iObjectId> */ } Lua.lua_pushvalue(l, 3); /* -2: LWF.Instances.<instanceId>.Movies.<iObjectId> */ /* -1: value */ Lua.lua_setfield(l, -2, key); /* -1: LWF.Instances.<instanceId>.Movies.<iObjectId> */ Lua.lua_pop(l, 1); /* 0 */ return(true); }