Ejemplo n.º 1
0
        static public void CompileScriptAsync(string filename, ref M22.Script.Script _out)
        {
            M22.Script.Script output = new M22.Script.Script();
            _out = output;
            var aThread = new System.Threading.Thread(() => CompileScript(filename, ref output));

            aThread.Start();
            return;
        }
Ejemplo n.º 2
0
 public void LoadScript(string _fname)
 {
     BackgroundMaster.UnloadBackgrounds();
     ScriptCompiler.UnloadCheckpoints();
     AudioMaster.UnloadAudio();
     VNHandler.UnloadCharacters();
     Resources.UnloadUnusedAssets();
     currentScript_c = M22.ScriptCompiler.CompileScript(_fname);
     //M22.ScriptCompiler.CompileScriptAsync(_fname, ref currentScript_c);
     lineIndex = 0;
     TEXT.Reset(true);
     CURRENT_LINE = currentScript_c.GetLine(lineIndex);
     TEXT.SetNewCurrentLine(CURRENT_LINE.m_lineContents);
     ExecuteFunction(CURRENT_LINE);
 }
Ejemplo n.º 3
0
        static public M22.Script.Script CompileScript(string filename)
        {
            var result = new M22.Script.Script();

            LoadedVariables loadedVars = LoadVariablesFile();

            //var file = File.ReadAllText(filename, Encoding.UTF8);
            var file = UnityWrapper.LoadTextFileAsString(filename);

            if (file.Length == 0)
            {
                UnityWrapper.LogError("Failed to load script file: " + filename);
                return(result);
            }

            var scriptLines = SplitByChar('\n', ref file);

            file = "";

            //List<string> CURRENT_LINE_SPLIT = new List<string>();
            int scriptPos = 0;

            for (int i = 0; i < scriptLines.Count; i++)
            {
                string currScriptLine = scriptLines[i];

                for (int n = 0; n < loadedVars.variables.Length; n++)
                {
                    if (loadedVars.variables[n] != null)
                    {
                        string tempStr = "[[" + loadedVars.variables[n] + "]]";
                        currScriptLine = currScriptLine.Replace(tempStr, loadedVars.variableData[n]);
                    }
                }

                M22.line_c tempLine_c = CompileLine(ref currScriptLine, i); // ref can't be an index so have to copy then copy back
                scriptLines[i] = currScriptLine;
                //if(tempLine_c.m_lineType == LINETYPE.NULL_OPERATOR)
                result.AddLine(tempLine_c);
                scriptPos++;
            }

            result.ClearNullOperators();

            return(result);
        }
Ejemplo n.º 4
0
 static public void CompileScript(string filename, ref M22.Script.Script _out)
 {
     _out = CompileScript(filename);
 }