private int LuaNodeNewIndex(IntPtr state) { var val = ToObject(); Lua.lua_pop(state, 1); var key = ToString(-1); Lua.lua_pop(state, 1); var refid = ToReference(); var node = ResolveReference(refid); if (TypeFieldMap.TryGetValue(node.GetType(), out Dictionary <string, FieldInfo> map)) { if (map.TryGetValue(key, out FieldInfo info)) { info.SetValue(node, val); return(0); } } else { var special_field = GetSpecialNewIndexFunc(node.GetType(), key); if (special_field != null) { return(special_field.Invoke(state, val)); } } return(0); }
private int LuaNodeIndex(IntPtr state) { var key = ToString(-1); Lua.lua_pop(state, 1); var refid = ToReference(); var node = ResolveReference(refid); if (TypeFieldMap.TryGetValue(node.GetType(), out Dictionary <string, FieldInfo> map)) { if (map.TryGetValue(key, out FieldInfo info)) { Push(info.GetValue(node)); return(1); } } else { var special_field = GetSpecialIndexFunc(node.GetType(), key); if (special_field != null) { return(special_field.Invoke(state)); } } Lua.lua_pushnil(LuaStatePtr); return(1); }