Beispiel #1
0
        /// <summary>
        /// Calls a function from this container for a particular key and
        /// with particular arguments.
        /// </summary>
        /// <param name="key">The key to find the function at.</param>
        /// <param name="parameters">Optional parameters to pass to the function.
        /// The native lua table will be added as first parameter before calling
        /// the function.</param>
        /// <returns>The first data container that is returned by the function,
        /// or null if none were.</returns>
        internal LuaDataContainer CallSelf(string key, params object[] parameters)
        {
            // Gets the function at the key.
            LuaFunction lf = _luaState.SafeGetField <LuaFunction>(_luaTable, key);

            // Checks if the function exists.
            if (lf == null)
            {
                throw new InvalidOperationException("The function " + key + " does not exist.");
            }

            // Gets a provider for the function and calls it.
            LuaDataProvider provider = _dataFactory.GetProvider(lf, this, false);

            return(provider.FirstContainerOrDefault(parameters));
        }
Beispiel #2
0
        public WherigoCollection <W> GetWherigoObjectListFromProvider <W>(string key, params object[] parameters) where W : WherigoObject
        {
            // Gets the provider at the key.
            LuaFunction lf = _luaState.SafeGetField <LuaFunction>(_luaTable, key);

            if (lf == null)
            {
                return(new WherigoCollection <W>());
            }

            // Gets the self, unprotected, provider.
            LuaDataProvider ldp = _dataFactory.GetProvider(lf, this, false);

            // Executes and gets the first container.
            LuaDataContainer ldc = ldp.FirstContainerOrDefault(parameters);

            // Gets the list for this
            return(_dataFactory.GetWherigoObjectList <W>(ldc));
        }