mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 04:51:49 +00:00
Merge branch 'main' into animation
This commit is contained in:
commit
49e7f2c631
89 changed files with 1050 additions and 687 deletions
|
|
@ -42,7 +42,7 @@ static int l_get_model(lua::State* L) {
|
|||
auto& rigConfig = *skeleton->config;
|
||||
auto index = index_range_check(*skeleton, lua::tointeger(L, 2));
|
||||
const auto& modelOverride = skeleton->modelOverrides[index];
|
||||
if (!modelOverride.model.expired()) {
|
||||
if (modelOverride.model.expired()) {
|
||||
return lua::pushstring(L, modelOverride.name);
|
||||
}
|
||||
return lua::pushstring(L, rigConfig.getBones()[index]->model.name);
|
||||
|
|
|
|||
|
|
@ -1127,6 +1127,7 @@ static int l_gui_load_document(lua::State* L) {
|
|||
}
|
||||
|
||||
auto env = scripting::create_doc_environment(parentEnv, alias);
|
||||
auto envId = *env;
|
||||
// namespace extension
|
||||
if (lua::istable(L, 4)) {
|
||||
if (lua::get_from(L, "table", "extend")) {
|
||||
|
|
@ -1148,7 +1149,7 @@ static int l_gui_load_document(lua::State* L) {
|
|||
engine->requireAssets().store(std::move(documentPtr), alias);
|
||||
|
||||
scripting::on_ui_open(*document, {args});
|
||||
return 0;
|
||||
return lua::pushenv(L, envId);
|
||||
}
|
||||
|
||||
static int l_set_syntax_styles(lua::State* L) {
|
||||
|
|
|
|||
|
|
@ -149,6 +149,15 @@ static int l_get_second_inventory(lua::State* L) {
|
|||
}
|
||||
}
|
||||
|
||||
static int l_get_exchange_inventory(lua::State* L) {
|
||||
auto inventory = hud->getExchangeInventory();
|
||||
if (inventory == nullptr) {
|
||||
return lua::pushinteger(L, 0);
|
||||
} else {
|
||||
return lua::pushinteger(L, inventory->getId());
|
||||
}
|
||||
}
|
||||
|
||||
static int l_get_player(lua::State* L) {
|
||||
auto player = hud->getPlayer();
|
||||
return lua::pushinteger(L, player->getId());
|
||||
|
|
@ -216,6 +225,7 @@ const luaL_Reg hudlib[] = {
|
|||
{"show_overlay", wrap_hud<l_show_overlay>},
|
||||
{"get_block_inventory", wrap_hud<l_get_block_inventory>},
|
||||
{"get_second_inventory", wrap_hud<l_get_second_inventory>},
|
||||
{"get_exchange_inventory", wrap_hud<l_get_exchange_inventory>},
|
||||
{"close", wrap_hud<l_close>},
|
||||
{"pause", wrap_hud<l_pause>},
|
||||
{"resume", wrap_hud<l_resume>},
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "world/Level.hpp"
|
||||
#include "world/World.hpp"
|
||||
#include "world/Weather.hpp"
|
||||
|
||||
using namespace scripting;
|
||||
|
||||
|
|
@ -9,6 +10,11 @@ static Weather& require_weather() {
|
|||
if (level == nullptr) {
|
||||
throw std::runtime_error("world is not open");
|
||||
}
|
||||
if (renderer == nullptr) {
|
||||
throw std::runtime_error(
|
||||
"world frontend is not initialized yet (wait for on_hud_open event)"
|
||||
);
|
||||
}
|
||||
return renderer->getWeather();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ static Level& require_level() {
|
|||
}
|
||||
|
||||
static WorldInfo& require_world_info() {
|
||||
return require_level().getWorld()->getInfo();
|
||||
return require_level().getWorld().getInfo();
|
||||
}
|
||||
|
||||
static int l_is_open(lua::State* L) {
|
||||
|
|
@ -139,7 +139,7 @@ static int l_get_chunk_data(lua::State* L) {
|
|||
auto voxelData = std::make_unique<ubyte[]>(CHUNK_DATA_LEN);
|
||||
std::vector<ubyte> chunkData;
|
||||
if (chunk == nullptr) {
|
||||
auto& regions = level->getWorld()->wfile->getRegions();
|
||||
auto& regions = level->getWorld().wfile->getRegions();
|
||||
if (!regions.getVoxels(x, z, voxelData.get())) {
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -218,7 +218,7 @@ static int l_save_chunk_data(lua::State* L) {
|
|||
reinterpret_cast<const ubyte*>(buffer.data()),
|
||||
reinterpret_cast<const ubyte*>(buffer.data()) + buffer.size()
|
||||
),
|
||||
level->getWorld()->wfile->getRegions()
|
||||
level->getWorld().wfile->getRegions()
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -264,6 +264,12 @@ static std::unordered_map<std::string, lua_CFunction> methods {
|
|||
{"min", lua::wrap<l_binop_func<util::min>>},
|
||||
{"max", lua::wrap<l_binop_func<util::max>>},
|
||||
{"abs", lua::wrap<l_unaryop_func<util::abs>>},
|
||||
{"floor", lua::wrap<l_unaryop_func<util::floor>>},
|
||||
{"round", lua::wrap<l_unaryop_func<util::round>>},
|
||||
{"ceil", lua::wrap<l_unaryop_func<util::ceil>>},
|
||||
{"sin", lua::wrap<l_unaryop_func<util::sin>>},
|
||||
{"cos", lua::wrap<l_unaryop_func<util::cos>>},
|
||||
{"tan", lua::wrap<l_unaryop_func<util::tan>>},
|
||||
{"resize", lua::wrap<l_resize>},
|
||||
{"crop", lua::wrap<l_crop>},
|
||||
{"at", lua::wrap<l_at>},
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ void scripting::on_world_load(LevelController* controller) {
|
|||
for (auto& pack : content_control->getAllContentPacks()) {
|
||||
lua::emit_event(L, pack.id + ":.worldopen", [](auto L) {
|
||||
return lua::pushboolean(
|
||||
L, !scripting::level->getWorld()->getInfo().isLoaded
|
||||
L, !scripting::level->getWorld().getInfo().isLoaded
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue