add animation.action

This commit is contained in:
MihailRis 2026-09-01 23:01:47 +03:00
parent c19733b594
commit 39a3c1201f
6 changed files with 45 additions and 13 deletions

View file

@ -77,7 +77,7 @@ static void create_libs(State* L, StateType stateType) {
createtable(L, 0, 0);
pushvalue(L, -1);
setglobal(L, "__vc_internals");
setregistry(L, "internals");
setregistry(L, lua::INTERNALS_TABLE);
if (stateType == StateType::SCRIPT) {
getregistry(L, "app");

View file

@ -16,6 +16,7 @@ namespace lua {
inline std::string CHUNKS_TABLE = "$C"; // precompiled lua chunks
inline std::string PACK_ENVS_TABLE = "$P";
inline std::string ENVS_TABLE = "$E";
inline std::string INTERNALS_TABLE = "$I";
extern std::unordered_map<std::type_index, std::string> usertypeNames;
int userdata_destructor(lua::State* L);

View file

@ -291,7 +291,7 @@ void scripting::on_content_load(Content* content) {
lua::getregistry(L, "app");
lua::setglobal(L, "__vc_app");
lua::getregistry(L, "internals");
lua::getregistry(L, lua::INTERNALS_TABLE);
lua::setglobal(L, "__vc_internals");
try {
load_script("post_content.lua", true);
@ -367,7 +367,7 @@ void scripting::on_world_quit() {
for (auto& pack : content_control->getAllContentPacks()) {
lua::emit_event(L, pack.id + ":.worldquit");
}
if (lua::getglobal(L, "__vc_on_world_quit")) {
if (lua::get_from_registry(L, lua::INTERNALS_TABLE, "on_world_quit", true)) {
lua::call_nothrow(L, 0, 0);
}
scripting::level = nullptr;
@ -849,7 +849,7 @@ void scripting::load_vca_animation(
const std::string& identifier
) {
auto L = lua::get_main_state();
if (lua::get_from_registry(L, "internals", "load_vca_animation", true)) {
if (lua::get_from_registry(L, lua::INTERNALS_TABLE, "load_vca_animation", true)) {
lua::pushlstring(L, file.string());
lua::pushlstring(L, identifier);
if (lua::call(L, 2, 0)) {

View file

@ -63,12 +63,15 @@ void scripting::on_frontend_init(
}
void scripting::on_frontend_render() {
auto L = lua::get_main_state();
if (lua::get_from_registry(L, lua::INTERNALS_TABLE, "on_render", true)) {
lua::call_nothrow(L, 0, 0);
}
for (auto& pack : content_control->getAllContentPacks()) {
lua::emit_event(
lua::get_main_state(),
pack.id + ":.hudrender",
[](lua::State* L) { return 0; }
);
lua::emit_event(L, pack.id + ":.hudrender", [](lua::State* L) {
return 0;
});
}
}