mirror of
https://github.com/fedddddd/iw5-gsc-utils.git
synced 2025-04-20 21:05:44 +00:00
Add jsonPrint function
This commit is contained in:
parent
9ead1676b0
commit
dbc0a928b9
@ -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*>();
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "game/scripting/array.hpp"
|
||||
|
||||
#include "gsc.hpp"
|
||||
#include "json.hpp"
|
||||
|
||||
#include <json.hpp>
|
||||
|
||||
@ -136,6 +137,11 @@ namespace json
|
||||
}
|
||||
}
|
||||
|
||||
std::string gsc_to_string(const scripting::script_value& value)
|
||||
{
|
||||
return gsc_to_json(value).dump();
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
{
|
||||
public:
|
||||
|
6
src/component/json.hpp
Normal file
6
src/component/json.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace json
|
||||
{
|
||||
std::string gsc_to_string(const scripting::script_value& _value);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user