mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 11:31:49 +00:00
add gfx.text3d.spawn(...)
This commit is contained in:
parent
c4170c07c5
commit
eb5715eba9
7 changed files with 57 additions and 15 deletions
|
|
@ -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[];
|
||||
|
|
|
|||
29
src/logic/scripting/lua/libs/libtext3d.cpp
Normal file
29
src/logic/scripting/lua/libs/libtext3d.cpp
Normal file
|
|
@ -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}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue