public static RootNode GetRootNode(string ScriptFile, List <int> rootNodeIndeces)
        {
            string path;

            ScriptFileMap.TryGetValue(ScriptFile.ToLower(), out path);
            if (path == null)
            {
                //path = Path.GetFullPath(ScriptFile);
                path = Path.GetFullPath(Path.Combine(Core.BaseDirectory, ParsedScripts.UberScriptDirectory, ScriptFile));
                if (!File.Exists(path))
                {
                    throw new UberScriptException("Script file did not exist at " + path);
                }
                ScriptFileMap.Add(ScriptFile.ToLower(), path);
            }

            RootNode parsedScriptRoot;

            if (!Scripts.ContainsKey(path))
            {
                parsedScriptRoot = UberTreeParser.ParseFile(path);
                if (parsedScriptRoot == null)
                {
                    return(null);
                }
                Scripts.Add(path, parsedScriptRoot);
            }
            else
            {
                parsedScriptRoot = Scripts[path];
            }
            try
            {
                // in the case where there are child root (i.e. spawn) nodes
                // we need to traverse the tree down to the node that pertains to
                // that particular spawn... e.g the following sequence has two onDeath trigger handlers,
                // so we need to travel to the spawn node under which the trigger handler is pertinent
                // orc
                // {
                //    onDeath
                //    {
                //      troll
                //      {
                //          onDeath
                //          {
                //              MSG(TRIGMOB(),You did it!)
                //          }
                //      }
                //    }
                // }
                foreach (int index in rootNodeIndeces)
                {
                    parsedScriptRoot = parsedScriptRoot.ChildRoots[index];
                }
            }
            catch
            {
                throw new UberScriptException("ChildRoots of script " + path + " did not match the input indeces... "
                                              + "a script has been reloaded without the same amount/sequence of root nodes "
                                              + "and an existing spawned mob or item was created with that script before the change was made!");
            }
            return(parsedScriptRoot);
        }
        public static void AddScript(string ScriptFile)
        {
            //only add if it hasn't already been added
            try
            {
                string path;
                ScriptFileMap.TryGetValue(ScriptFile.ToLower(), out path);
                if (path == null)
                {
                    path = Path.GetFullPath(Path.Combine(Core.BaseDirectory, ParsedScripts.UberScriptDirectory, ScriptFile));
                    if (!File.Exists(path))
                    {
                        throw new UberScriptException("Script file did not exist at " + path);
                    }
                    ScriptFileMap.Add(ScriptFile.ToLower(), path);
                }

                if (!Scripts.ContainsKey(path))
                {
                    RootNode parsedScriptRoot = UberTreeParser.ParseFile(path);
                    if (parsedScriptRoot == null)
                    {
                        throw new UberScriptException("UberTreeParser.ParseFile returned null node!");
                    }
                    Scripts.Add(path, parsedScriptRoot);
                }
            }
            catch (UberScriptException e)
            {
                if (DebugLevel >= (int)DebugLevels.ScriptDebugMessages)
                {
                    Console.WriteLine("Error Parsing script file: " + ScriptFile);
                    Exception innerMostException = e;
                    Console.WriteLine(e.Message);
                    int level = 0;
                    while (true)
                    {
                        if (innerMostException.InnerException == null)
                        {
                            break;
                        }
                        level++;
                        innerMostException = innerMostException.InnerException;
                        for (int i = 0; i < level; i++)
                        {
                            Console.Write("\t");
                        }
                        Console.WriteLine(innerMostException.Message);
                    }
                    if (DebugLevel >= (int)DebugLevels.ScriptDebugMessagesAndStackTrace)
                    {
                        Console.WriteLine(innerMostException.StackTrace);
                    }
                }
            }
            catch (Exception general)
            {
                Console.WriteLine("Error Parsing script file: " + ScriptFile);
                Console.WriteLine("GENERAL UNCAUGHT ERROR: this should never happen!");
                Console.WriteLine(general.Message);
                Console.WriteLine(general.StackTrace);
            }
        }