Skip to content

Commit

Permalink
Merge pull request #442 from MihailRis/suspend-players
Browse files Browse the repository at this point in the history
Suspend players
  • Loading branch information
MihailRis authored Jan 18, 2025
2 parents d48c00d + c9adbe8 commit 88ed15c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/logic/scripting/lua/libs/libworld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ static void integrate_chunk_client(Chunk& chunk) {
static int l_set_chunk_data(lua::State* L) {
int x = static_cast<int>(lua::tointeger(L, 1));
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);
if (chunk == nullptr) {
return 0;
return lua::pushboolean(L, false);
}
compressed_chunks::decode(
*chunk, buffer->data().data(), buffer->data().size()
*chunk, buffer.data(), buffer.size()
);
if (controller->getChunksController()->lighting == nullptr) {
return lua::pushboolean(L, true);
Expand Down
7 changes: 7 additions & 0 deletions src/logic/scripting/lua/lua_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ dv::value lua::tovalue(State* L, int idx) {
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:
throw std::runtime_error(
"lua type " + std::string(lua_typename(L, type)) +
Expand Down

0 comments on commit 88ed15c

Please sign in to comment.