private void Start() { string Code = @" -- Jump Every 4 seconds; zone zero; rbjump; wait {jumpTime}; jumpto zero; end; "; // Set custom events var customEvents = new Dictionary <string, Action <CookCompiler, string> >(); customEvents.Add("print", (m, args) => { Debug.Log(args); cook.pointer++; }); customEvents.Add("error", (m, args) => { Debug.LogError(args); cook.pointer++; }); customEvents.Add("wait", (m, args) => { var arg = args.Replace(" ", ""); arg = m.ApplyVariablesInString(arg); time = float.Parse(arg); cook.pointer++; }); customEvents.Add("rbjump", (m, args) => { rb.velocity = 10 * Vector3.up; cook.pointer++; }); // Set custom variables var customVariables = new Dictionary <string, string>(); customVariables.Add("jumpTime", jumpTime.ToString()); //Init everything cook = new CookCompiler(Code, customVariables, customEvents); //Start the code StartCoroutine(RunTheCode()); }
public static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Write -h to get help about the program"); return; } if (args.Length == 1) { Console.WriteLine("You must add a path"); return; } string code = System.IO.File.ReadAllText(args[1]); var compiler = new CookCompiler(code); compiler.Run(); }