add gfx.text3d.spawn(...)

This commit is contained in:
MihailRis
2024-11-14 10:32:50 +03:00
parent c4170c07c5
commit eb5715eba9
7 changed files with 57 additions and 15 deletions
+2 -1
View File
@@ -33,7 +33,8 @@ extern const luaL_Reg mat4lib[];
extern const luaL_Reg packlib[];
extern const luaL_Reg particleslib[];
extern const luaL_Reg playerlib[];
extern const luaL_Reg quatlib[]; // quat.cpp
extern const luaL_Reg quatlib[];
extern const luaL_Reg text3dlib[];
extern const luaL_Reg timelib[];
extern const luaL_Reg tomllib[];
extern const luaL_Reg utf8lib[];
@@ -0,0 +1,29 @@
#include "api_lua.hpp"
#include "logic/scripting/scripting_hud.hpp"
#include "graphics/render/WorldRenderer.hpp"
#include "graphics/render/TextsRenderer.hpp"
#include "graphics/render/TextNote.hpp"
#include "engine.hpp"
using namespace scripting;
static int l_spawn(lua::State* L) {
auto position = lua::tovec3(L, 1);
auto text = lua::require_wstring(L, 2);
auto preset = lua::tovalue(L, 3);
auto extension = lua::tovalue(L, 4);
NotePreset notePreset {};
notePreset.deserialize(preset);
if (extension != nullptr) {
notePreset.deserialize(extension);
}
auto note = std::make_unique<TextNote>(text, notePreset, position);
return lua::pushinteger(L, renderer->texts->add(std::move(note)));
}
const luaL_Reg text3dlib[] = {
{"spawn", lua::wrap<l_spawn>},
{NULL, NULL}
};
+1
View File
@@ -25,6 +25,7 @@ void scripting::on_frontend_init(Hud* hud, WorldRenderer* renderer) {
lua::openlib(L, "hud", hudlib);
lua::openlib(L, "gfx", "particles", particleslib);
lua::openlib(L, "gfx", "text3d", text3dlib);
if (lua::getglobal(L, "__vc_create_hud_rules")) {
lua::call_nothrow(L, 0, 0);