update block.get_field, block.set_field and fields-related docs

This commit is contained in:
MihailRis
2024-10-02 17:56:19 +03:00
parent e0a4876f3f
commit 87cf6c41bc
6 changed files with 26 additions and 8 deletions
+8
View File
@@ -489,6 +489,10 @@ static int l_get_field(lua::State* L) {
if (field == nullptr) {
return 0;
}
if (index >= field->elements) {
throw std::out_of_range(
"index out of bounds [0, "+std::to_string(field->elements)+"]");
}
const ubyte* src = chunk->blocksMetadata.find(voxelIndex);
if (src == nullptr) {
return 0;
@@ -553,6 +557,10 @@ static int l_set_field(lua::State* L) {
if (field == nullptr) {
return 0;
}
if (index >= field->elements) {
throw std::out_of_range(
"index out of bounds [0, "+std::to_string(field->elements)+"]");
}
ubyte* dst = chunk->blocksMetadata.find(voxelIndex);
if (dst == nullptr) {
dst = chunk->blocksMetadata.allocate(voxelIndex, dataStruct.size());