public void SetupEnginePieces()
 {
     //setup print function
     myengine = myengine
                .SetValue("print", new Action <object>(Value => { engineOut += ("\n" + Value + "\n"); }));
     //add a load function
     myengine = myengine.SetValue("load", new Func <string, object>(
                                      path => myengine.Execute(File.ReadAllText(path))
                                      .GetCompletionValue()));
     //setup Assembly-Csharp,Assembly-csharp-firstpass
     myengine = JintAdditons.AddGameSpecificClasses(myengine);
 }
        public static void RunMe()
        {
            var engine = new Engine(cfg => { cfg.AllowClr(AppDomain.CurrentDomain.GetAssemblies()); });

            engine
            .SetValue("print", new Action <object>(Value => { MelonModLogger.Log(Value.ToString()); }))
            .SetValue("load", new Func <string, object>(
                          path => engine.Execute(File.ReadAllText(path))
                          .GetCompletionValue()));
            engine = JintAdditons.AddGameSpecificClasses(engine);

            MelonModLogger.Log("Type 'exit' to leave, " +
                               "'print()' to write on the console, " +
                               "'load()' to load scripts.");
            MelonModLogger.Log("");

            var defaultColor = Console.ForegroundColor;

            while (true)
            {
                Console.ForegroundColor = defaultColor;
                MelonModLogger.Log("jint> ");
                var input = Console.ReadLine();
                if (input == "exit")
                {
                    return;
                }

                try
                {
                    var result = engine.GetValue(engine.Execute(input).GetCompletionValue());
                    if (result.Type != Types.None && result.Type != Types.Null && result.Type != Types.Undefined)
                    {
                        var str = TypeConverter.ToString(engine.Json.Stringify(engine.Json,
                                                                               Arguments.From(result, Undefined.Instance, "  ")));
                        MelonModLogger.Log("=> {0}", str);
                    }
                }
                catch (JavaScriptException je)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    MelonModLogger.Log(je.ToString());
                }
                catch (Exception e)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    MelonModLogger.Log(e.Message);
                }
            }
        }
 public void SetupEnginePieces()
 {
     //setup print function
     myengine = myengine
                .SetValue("print", new Action <object>(Value => { engineOut += ("\n" + Value + "\n"); }));
     //add a load function
     myengine = myengine.SetValue("load", new Func <string, object>(
                                      path => myengine.Execute(File.ReadAllText(path))
                                      .GetCompletionValue()));
     //setup Assembly-Csharp,Assembly-csharp-firstpass
     myengine = JintAdditons.AddGameSpecificClasses(myengine);
     myengine = myengine.Execute(
         "function testing() {return cs_VRCPlayer.field_Internal_Static_VRCPlayer_0.transform}");
     myengine = myengine.Execute(
         "function worldUrl() { return \"https://vrchat.com/home/launch?worldId=\"+cs_RoomManagerBase.field_Internal_Static_ApiWorldInstance_0.instanceWorld.id}");
 }