Merge branch 'dev' into more-about-projects

This commit is contained in:
MihailRis
2025-08-16 13:57:51 +03:00
14 changed files with 134 additions and 29 deletions
@@ -54,7 +54,7 @@ static int l_get_gravity_scale(lua::State* L) {
static int l_set_gravity_scale(lua::State* L) {
if (auto entity = get_entity(L, 1)) {
entity->getRigidbody().hitbox.gravityScale = lua::tonumber(L, 2);
entity->getRigidbody().hitbox.gravityScale = lua::tovec3(L, 2).y;
}
return 0;
}
+15 -4
View File
@@ -101,12 +101,9 @@ static int l_set(lua::State* L) {
if (static_cast<size_t>(id) >= indices->blocks.count()) {
return 0;
}
int cx = floordiv<CHUNK_W>(x);
int cz = floordiv<CHUNK_D>(z);
if (!blocks_agent::get_chunk(*level->chunks, cx, cz)) {
if (!blocks_agent::set(*level->chunks, x, y, z, id, int2blockstate(state))) {
return 0;
}
blocks_agent::set(*level->chunks, x, y, z, id, int2blockstate(state));
auto chunksController = controller->getChunksController();
if (chunksController == nullptr) {
@@ -364,6 +361,19 @@ static int l_get_textures(lua::State* L) {
return 0;
}
static int l_model_name(lua::State* L) {
if (auto def = require_block(L)) {
// TODO: variant argument
const auto& modelName = def->defaults.model.name;
if (modelName.empty()) {
return lua::pushlstring(L, def->name + ".model");
}
return lua::pushlstring(L, modelName);
}
return 0;
}
static int l_get_model(lua::State* L) {
if (auto def = require_block(L)) {
// TODO: variant argument
@@ -713,6 +723,7 @@ const luaL_Reg blocklib[] = {
{"get_size", lua::wrap<l_get_size>},
{"is_segment", lua::wrap<l_is_segment>},
{"seek_origin", lua::wrap<l_seek_origin>},
{"model_name", lua::wrap<l_model_name>},
{"get_textures", lua::wrap<l_get_textures>},
{"get_model", lua::wrap<l_get_model>},
{"get_hitbox", lua::wrap<l_get_hitbox>},
+1 -1
View File
@@ -46,7 +46,7 @@ static int l_open(lua::State* L) {
}
return lua::pushinteger(L, hud->openInventory(
layout,
level->inventories->get(invid),
lua::isnoneornil(L, 3) ? nullptr : level->inventories->get(invid),
playerInventory
)->getId());
}