Lua: Add MP.PrintRaw

This commit is contained in:
Lion Kortlepel 2021-09-19 01:20:17 +02:00
parent dd70e88e4c
commit 1ff5107707
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B
3 changed files with 11 additions and 7 deletions

View File

@ -19,5 +19,6 @@ namespace MP {
bool IsPlayerGuest(int ID); bool IsPlayerGuest(int ID);
bool IsPlayerConnected(int ID); bool IsPlayerConnected(int ID);
void Sleep(size_t Ms); void Sleep(size_t Ms);
void PrintRaw(sol::variadic_args);
} }
} }

View File

@ -234,3 +234,12 @@ bool LuaAPI::MP::IsPlayerGuest(int ID) {
return false; return false;
} }
} }
void LuaAPI::MP::PrintRaw(sol::variadic_args Args) {
std::string ToPrint = "";
for (const auto& Arg : Args) {
ToPrint += LuaToString(static_cast<const sol::object>(Arg));
ToPrint += "\t";
}
Application::Console().WriteRaw(ToPrint);
}

View File

@ -9,13 +9,6 @@
#include <random> #include <random>
#include <tuple> #include <tuple>
static std::mt19937_64 MTGen64;
static TLuaStateId GenerateUniqueStateId() {
auto Time = std::chrono::high_resolution_clock::now().time_since_epoch();
return std::to_string(MTGen64()) + std::to_string(std::chrono::duration_cast<std::chrono::nanoseconds>(Time).count());
}
TLuaEngine* LuaAPI::MP::Engine; TLuaEngine* LuaAPI::MP::Engine;
TLuaEngine::TLuaEngine() { TLuaEngine::TLuaEngine() {
@ -327,6 +320,7 @@ TLuaEngine::StateThreadData::StateThreadData(const std::string& Name, std::atomi
return Lua_GetPlayerIdentifiers(ID); return Lua_GetPlayerIdentifiers(ID);
}); });
Table.set_function("Sleep", &LuaAPI::MP::Sleep); Table.set_function("Sleep", &LuaAPI::MP::Sleep);
Table.set_function("PrintRaw", &LuaAPI::MP::PrintRaw);
Table.set_function("Set", &LuaAPI::MP::Set); Table.set_function("Set", &LuaAPI::MP::Set);
Table.set_function("HttpsGET", [&](const std::string& Host, int Port, const std::string& Target) -> std::tuple<int, std::string> { Table.set_function("HttpsGET", [&](const std::string& Host, int Port, const std::string& Target) -> std::tuple<int, std::string> {
unsigned Status; unsigned Status;