mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
add bytearray lua-style appending support
This commit is contained in:
parent
487189f4a6
commit
6bf23e5cac
1 changed files with 6 additions and 3 deletions
|
|
@ -105,11 +105,14 @@ static int l_bytearray_meta_newindex(lua::State* L) {
|
|||
return 0;
|
||||
}
|
||||
auto& data = buffer->data();
|
||||
auto index = tointeger(L, 2)-1;
|
||||
if (static_cast<size_t>(index) > data.size()) {
|
||||
auto index = static_cast<size_t>(tointeger(L, 2)-1);
|
||||
auto value = tointeger(L, 3);
|
||||
if (index >= data.size()) {
|
||||
if (index == data.size()) {
|
||||
data.push_back(static_cast<ubyte>(value));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
auto value = tointeger(L, 3);
|
||||
data[index] = static_cast<ubyte>(value);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue