mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-13 15:01:49 +00:00
commit
88ed15c6d8
2 changed files with 10 additions and 3 deletions
|
|
@ -160,13 +160,13 @@ static void integrate_chunk_client(Chunk& chunk) {
|
||||||
static int l_set_chunk_data(lua::State* L) {
|
static int l_set_chunk_data(lua::State* L) {
|
||||||
int x = static_cast<int>(lua::tointeger(L, 1));
|
int x = static_cast<int>(lua::tointeger(L, 1));
|
||||||
int z = static_cast<int>(lua::tointeger(L, 2));
|
int z = static_cast<int>(lua::tointeger(L, 2));
|
||||||
auto buffer = lua::touserdata<lua::LuaBytearray>(L, 3);
|
auto buffer = lua::require_bytearray(L, 3);
|
||||||
auto chunk = level->chunks->getChunk(x, z);
|
auto chunk = level->chunks->getChunk(x, z);
|
||||||
if (chunk == nullptr) {
|
if (chunk == nullptr) {
|
||||||
return 0;
|
return lua::pushboolean(L, false);
|
||||||
}
|
}
|
||||||
compressed_chunks::decode(
|
compressed_chunks::decode(
|
||||||
*chunk, buffer->data().data(), buffer->data().size()
|
*chunk, buffer.data(), buffer.size()
|
||||||
);
|
);
|
||||||
if (controller->getChunksController()->lighting == nullptr) {
|
if (controller->getChunksController()->lighting == nullptr) {
|
||||||
return lua::pushboolean(L, true);
|
return lua::pushboolean(L, true);
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,13 @@ dv::value lua::tovalue(State* L, int idx) {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case LUA_TUSERDATA: {
|
||||||
|
if (auto bytes = touserdata<LuaBytearray>(L, idx)) {
|
||||||
|
const auto& data = bytes->data();
|
||||||
|
return std::make_shared<dv::objects::Bytes>(data.data(), data.size());
|
||||||
|
}
|
||||||
|
[[fallthrough]];
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"lua type " + std::string(lua_typename(L, type)) +
|
"lua type " + std::string(lua_typename(L, type)) +
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue