From e17b89b97256328e51259d4b9a12accb4a3523c3 Mon Sep 17 00:00:00 2001 From: sam-astro <77079540+sam-astro@users.noreply.github.com> Date: Mon, 3 Jan 2022 13:24:41 -0500 Subject: [PATCH] Update builtin.h --- Slang/builtin.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Slang/builtin.h b/Slang/builtin.h index 06bcab3..e69ef7c 100644 --- a/Slang/builtin.h +++ b/Slang/builtin.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "strops.h" #include "graphics.h" @@ -21,6 +22,7 @@ vector builtinVarVals; Parser mainWindow; +// Initial script processing, which loads variables and functions from builtin int GetBuiltins(string script) { script = replace(script, " ", "\t"); @@ -83,16 +85,17 @@ int GetBuiltins(string script) return 0; } -string CPPFunction(string name, vector args) +// Executes +any CPPFunction(string name, vector args) { if (name == "CPP.Math.Sin") - return to_string(sin(stof(args[0]))); + return sin(stof(args[0])); else if (name == "CPP.Math.Cos") - return to_string(cos(stof(args[0]))); + return cos(stof(args[0])); else if (name == "CPP.Math.Tan") - return to_string(tan(stof(args[0]))); + return tan(stof(args[0])); else if (name == "CPP.Math.Round") - return to_string(round(stof(args[0]))); + return round(stof(args[0])); else if (name == "CPP.Graphics.Init") { cout << "\x1B[32mInit graphics\033[0m\t\t" << endl; @@ -101,8 +104,12 @@ string CPPFunction(string name, vector args) } else if (name == "CPP.Graphics.SetPixel") mainWindow.Draw(stoi(args[0]), stoi(args[1]), olc::Pixel(stoi(args[2]), stoi(args[3]), stoi(args[4]))); + else if (name == "CPP.System.Print") + cout << stoi(args[0]); + else if (name == "CPP.System.PrintLine") + cout << stoi(args[0]) << endl; - return ""; + return 0; } -#endif \ No newline at end of file +#endif