Example #1
0
        /// @endcond

        /// <summary>
        /// Gets the value with the specified string key. Returns a standard type such as
        /// <c>string</c>, <c>float</c>, <c>bool</c>, or <c>null</c>. If the value
        /// is a table, it returns a LuaTableWrapper around it.
        /// </summary>
        /// <param name="key">Key.</param>
        public object this[string key]
        {
            get
            {
                if (luaTable == null)
                {
                    if (DialogueDebug.logErrors)
                    {
                        Debug.LogError(string.Format("{0}: Lua table is null; lookup[{1}] failed", new object[] { DialogueDebug.Prefix, key }));
                    }
                    return(null);
                }
                LuaValue luaValue = LuaNil.Nil;
                if (luaTable.Length > 0)
                {
                    // Get list value:
                    luaValue = luaTable.GetValue(Tools.StringToInt(key));
                }
                else
                {
                    // Get dictionary value:
                    LuaValue luaValueKey = luaTable.GetKey(key);
                    if (luaValueKey == LuaNil.Nil)
                    {
                        //--- Suppressed: if (DialogueDebug.LogErrors) Debug.LogError(string.Format("{0}: Lua table does not contain key [{1}]", new string[] { DialogueDebug.Prefix, key }));
                        return(null);
                    }
                    luaValue = luaTable.GetValue(key);
                }
                if (luaValue is LuaTable)
                {
                    return(new LuaTableWrapper(luaValue as LuaTable));
                }
                else
                {
                    return(LuaInterpreterExtensions.LuaValueToObject(luaValue));
                }
            }
        }