Add jsonPrint function

This commit is contained in:
Federico Cecchetto
2021-06-20 00:36:07 +02:00
parent 9ead1676b0
commit dbc0a928b9
3 changed files with 27 additions and 0 deletions

View File

@ -9,6 +9,7 @@
#include "game/scripting/array.hpp"
#include "gsc.hpp"
#include "json.hpp"
namespace io
{
@ -20,6 +21,20 @@ namespace io
const auto path = game::Dvar_FindVar("fs_basegame")->current.string;
std::filesystem::current_path(path);
gsc::function::add("jsonprint", [](const gsc::function_args& args) -> scripting::script_value
{
std::string buffer;
for (const auto arg : args.get_raw())
{
buffer.append(json::gsc_to_string(arg));
buffer.append("\t");
}
printf("%s\n", buffer.data());
return {};
});
gsc::function::add("fremove", [](const gsc::function_args& args)
{
const auto path = args[0].as<const char*>();