mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-01 23:35:41 +00:00
LuaAPI: Show quotes around strings in table dumps (#60)
This commit is contained in:
parent
b6fa3574fd
commit
f1148ed1c4
@ -96,10 +96,6 @@ void Application::CheckForUpdates() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// thread name stuff
|
||||
|
||||
static std::map<std::thread::id, std::string> threadNameMap {};
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define SOL_ALL_SAFETIES_ON 1
|
||||
#include <sol/sol.hpp>
|
||||
|
||||
static std::string LuaToString(const sol::object Value, size_t Indent = 1) {
|
||||
static std::string LuaToString(const sol::object Value, size_t Indent = 1, bool QuoteStrings = false) {
|
||||
if (Indent > 80) {
|
||||
return "[[possible recursion, refusing to keep printing]]";
|
||||
}
|
||||
@ -32,7 +32,11 @@ static std::string LuaToString(const sol::object Value, size_t Indent = 1) {
|
||||
return ss.str();
|
||||
}
|
||||
case sol::type::string:
|
||||
return Value.as<std::string>();
|
||||
if (QuoteStrings) {
|
||||
return "\"" + Value.as<std::string>() + "\"";
|
||||
} else {
|
||||
return Value.as<std::string>();
|
||||
}
|
||||
case sol::type::number: {
|
||||
std::stringstream ss;
|
||||
ss << Value.as<float>();
|
||||
@ -53,7 +57,7 @@ static std::string LuaToString(const sol::object Value, size_t Indent = 1) {
|
||||
for (size_t i = 0; i < Indent; ++i) {
|
||||
Result << "\t";
|
||||
}
|
||||
Result << LuaToString(Entry.first, Indent + 1) << ": " << LuaToString(Entry.second, Indent + 1) << ",";
|
||||
Result << LuaToString(Entry.first, Indent + 1) << ": " << LuaToString(Entry.second, Indent + 1, true) << ",";
|
||||
}
|
||||
Result << "\n";
|
||||
}
|
||||
@ -160,49 +164,49 @@ void LuaAPI::MP::RemoveVehicle(int PID, int VID) {
|
||||
|
||||
void LuaAPI::MP::Set(int ConfigID, sol::object NewValue) {
|
||||
switch (ConfigID) {
|
||||
case 0: //debug
|
||||
case 0: // debug
|
||||
if (NewValue.is<bool>()) {
|
||||
Application::Settings.DebugModeEnabled = NewValue.as<bool>();
|
||||
beammp_info(std::string("Set `Debug` to ") + (Application::Settings.DebugModeEnabled ? "true" : "false"));
|
||||
} else
|
||||
beammp_lua_error("set invalid argument [2] expected boolean");
|
||||
break;
|
||||
case 1: //private
|
||||
case 1: // private
|
||||
if (NewValue.is<bool>()) {
|
||||
Application::Settings.Private = NewValue.as<bool>();
|
||||
beammp_info(std::string("Set `Private` to ") + (Application::Settings.Private ? "true" : "false"));
|
||||
} else
|
||||
beammp_lua_error("set invalid argument [2] expected boolean");
|
||||
break;
|
||||
case 2: //max cars
|
||||
case 2: // max cars
|
||||
if (NewValue.is<int>()) {
|
||||
Application::Settings.MaxCars = NewValue.as<int>();
|
||||
beammp_info(std::string("Set `MaxCars` to ") + std::to_string(Application::Settings.MaxCars));
|
||||
} else
|
||||
beammp_lua_error("set invalid argument [2] expected integer");
|
||||
break;
|
||||
case 3: //max players
|
||||
case 3: // max players
|
||||
if (NewValue.is<int>()) {
|
||||
Application::Settings.MaxPlayers = NewValue.as<int>();
|
||||
beammp_info(std::string("Set `MaxPlayers` to ") + std::to_string(Application::Settings.MaxPlayers));
|
||||
} else
|
||||
beammp_lua_error("set invalid argument [2] expected integer");
|
||||
break;
|
||||
case 4: //Map
|
||||
case 4: // Map
|
||||
if (NewValue.is<std::string>()) {
|
||||
Application::Settings.MapName = NewValue.as<std::string>();
|
||||
beammp_info(std::string("Set `Map` to ") + Application::Settings.MapName);
|
||||
} else
|
||||
beammp_lua_error("set invalid argument [2] expected string");
|
||||
break;
|
||||
case 5: //Name
|
||||
case 5: // Name
|
||||
if (NewValue.is<std::string>()) {
|
||||
Application::Settings.ServerName = NewValue.as<std::string>();
|
||||
beammp_info(std::string("Set `Name` to ") + Application::Settings.ServerName);
|
||||
} else
|
||||
beammp_lua_error("set invalid argument [2] expected string");
|
||||
break;
|
||||
case 6: //Desc
|
||||
case 6: // Desc
|
||||
if (NewValue.is<std::string>()) {
|
||||
Application::Settings.ServerDesc = NewValue.as<std::string>();
|
||||
beammp_info(std::string("Set `Description` to ") + Application::Settings.ServerDesc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user