Esempio n. 1
0
        //
        // Return parameter information for a script entrypoint.
        //
        public NWN2ScriptParameterCollection GetScriptEntryPointParameters(string ScriptName, string OutputDirectory)
        {
            string Entrypoint;
            string Warnings;
            NWN2ScriptParameterCollection Parameters;
            NWN2ScriptParameter Parameter;
            int ParameterCount;

            //
            // First, compile the script and check that we succeeded at that.
            //

            if (!String.IsNullOrEmpty(CompileScript(ScriptName, OutputDirectory, false, out Warnings)))
                return null;

            if (m_Compiler == IntPtr.Zero)
                return null;

            Parameters = new NWN2ScriptParameterCollection();

            if (m_Compiling)
                return null;

            m_Compiling = true;

            try
            {
                Entrypoint = Marshal.PtrToStringAnsi(NscGetEntrypointSymbolName(m_Compiler));
                ParameterCount = NscGetFunctionParameterCount(m_Compiler, Entrypoint);

                for (int ParamIdx = 0; ParamIdx < ParameterCount; ParamIdx += 1)
                {
                    Parameter = new NWN2ScriptParameter();

                    switch ((NWACTION_TYPE) NscGetFunctionParameterType(m_Compiler, Entrypoint, ParamIdx))
                    {

                        case NWACTION_TYPE.ACTIONTYPE_INT:
                            Parameter.ParameterType = NWN2ScriptParameterType.Int;
                            break;

                        case NWACTION_TYPE.ACTIONTYPE_FLOAT:
                            Parameter.ParameterType = NWN2ScriptParameterType.Float;
                            break;

                        case NWACTION_TYPE.ACTIONTYPE_STRING:
                            Parameter.ParameterType = NWN2ScriptParameterType.String;
                            break;

                        default:
                            throw new ApplicationException("Invalid parameter type for script entrypoint.");

                    }

                    Parameters.Add(Parameter);
                }
            }
            catch
            {
                m_Compiling = false;
                throw;
            }

            m_Compiling = false;

            return Parameters;
        }
Esempio n. 2
0
        //
        // Return parameter information for a script entrypoint.
        //

        public NWN2ScriptParameterCollection GetScriptEntryPointParameters(string ScriptName, string OutputDirectory)
        {
            string Entrypoint;
            string Warnings;
            NWN2ScriptParameterCollection Parameters;
            NWN2ScriptParameter           Parameter;
            int ParameterCount;

            //
            // First, compile the script and check that we succeeded at that.
            //

            if (!String.IsNullOrEmpty(CompileScript(ScriptName, OutputDirectory, false, out Warnings)))
            {
                return(null);
            }

            if (m_Compiler == IntPtr.Zero)
            {
                return(null);
            }

            Parameters = new NWN2ScriptParameterCollection();

            if (m_Compiling)
            {
                return(null);
            }

            m_Compiling = true;

            try
            {
                Entrypoint     = Marshal.PtrToStringAnsi(NscGetEntrypointSymbolName(m_Compiler));
                ParameterCount = NscGetFunctionParameterCount(m_Compiler, Entrypoint);

                for (int ParamIdx = 0; ParamIdx < ParameterCount; ParamIdx += 1)
                {
                    Parameter = new NWN2ScriptParameter();

                    switch ((NWACTION_TYPE)NscGetFunctionParameterType(m_Compiler, Entrypoint, ParamIdx))
                    {
                    case NWACTION_TYPE.ACTIONTYPE_INT:
                        Parameter.ParameterType = NWN2ScriptParameterType.Int;
                        break;

                    case NWACTION_TYPE.ACTIONTYPE_FLOAT:
                        Parameter.ParameterType = NWN2ScriptParameterType.Float;
                        break;

                    case NWACTION_TYPE.ACTIONTYPE_STRING:
                        Parameter.ParameterType = NWN2ScriptParameterType.String;
                        break;

                    default:
                        throw new ApplicationException("Invalid parameter type for script entrypoint.");
                    }

                    Parameters.Add(Parameter);
                }
            }
            catch
            {
                m_Compiling = false;
                throw;
            }

            m_Compiling = false;

            return(Parameters);
        }