Example #1
0
        private string InitActions()
        {
            string errors       = "";
            string errorstrings = "";

            Object[] Objects = new Object[Lib.MaxGameActions];

            Lib.PrintLine("Loading actions...");

            //Load Commands from plugins
            //DirectoryInfo toplevel = new DirectoryInfo(Lib.PathtoRoot);
            ArrayList files = Lib.GetFilesRecursive(Lib.PathtoRoot, "*actions.dll");

            if (files.Count > 0)
            {
                foreach (string file in files)
                {
                    Lib.LoadPlugin(file);
                }
            }
            files = Lib.GetFilesRecursive(Lib.PathtoRootScriptsandPlugins, "*.tma.cs");
            if (files.Count > 0)
            {
                try
                {
                    Objects       = Lib.Compiler.GetObjectsFromFiles(Lib.ConvertToStringArray(files), out errors);
                    errorstrings += errors;
                }
                catch
                {
                    return(errorstrings);
                    //throw new Exception(ex.Message + ex.StackTrace);
                }
                if (Objects != null)
                {
                    // If this comes back equal to it's init length, then nothing was entered into the array
                    if (Objects.Length != Lib.MaxGameActions)
                    {
                        foreach (Object ActionObject in Objects)
                        {
                            Lib.AddAction((IAction)ActionObject);
                        }
                    }
                }
            }
            return(errorstrings);
        }