get_block_rotation, set_block_rotation

This commit is contained in:
MihailRis
2024-02-18 22:24:03 +03:00
parent 43db8ebba1
commit 8341485aef
3 changed files with 29 additions and 0 deletions
+25
View File
@@ -419,6 +419,31 @@ int l_get_block_z(lua_State* L) {
}
}
int l_get_block_rotation(lua_State* L) {
lua::luaint x = lua_tointeger(L, 1);
lua::luaint y = lua_tointeger(L, 2);
lua::luaint z = lua_tointeger(L, 3);
voxel* vox = scripting::level->chunks->get(x, y, z);
int rotation = vox == nullptr ? 0 : vox->rotation();
lua_pushinteger(L, rotation);
return 1;
}
int l_set_block_rotation(lua_State* L) {
lua::luaint x = lua_tointeger(L, 1);
lua::luaint y = lua_tointeger(L, 2);
lua::luaint z = lua_tointeger(L, 3);
lua::luaint value = lua_tointeger(L, 4) & BLOCK_ROT_MASK;
voxel* vox = scripting::level->chunks->get(x, y, z);
if (vox == nullptr) {
return 0;
}
vox->states = (vox->states & (~BLOCK_ROT_MASK)) | value;
return 0;
}
int l_get_block_states(lua_State* L) {
lua::luaint x = lua_tointeger(L, 1);
lua::luaint y = lua_tointeger(L, 2);