Merge branch 'dev' into pathfinding
This commit is contained in:
@@ -54,7 +54,7 @@ static int l_get_gravity_scale(lua::State* L) {
|
||||
|
||||
static int l_set_gravity_scale(lua::State* L) {
|
||||
if (auto entity = get_entity(L, 1)) {
|
||||
entity->getRigidbody().hitbox.gravityScale = lua::tonumber(L, 2);
|
||||
entity->getRigidbody().hitbox.gravityScale = lua::tovec3(L, 2).y;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@ static void load_texture(
|
||||
}
|
||||
|
||||
static int l_load_texture(lua::State* L) {
|
||||
if (lua::isstring(L, 3) && lua::require_lstring(L, 3) != "png") {
|
||||
throw std::runtime_error("unsupportd image format");
|
||||
}
|
||||
if (lua::istable(L, 1)) {
|
||||
lua::pushvalue(L, 1);
|
||||
size_t size = lua::objlen(L, 1);
|
||||
|
||||
@@ -101,12 +101,9 @@ static int l_set(lua::State* L) {
|
||||
if (static_cast<size_t>(id) >= indices->blocks.count()) {
|
||||
return 0;
|
||||
}
|
||||
int cx = floordiv<CHUNK_W>(x);
|
||||
int cz = floordiv<CHUNK_D>(z);
|
||||
if (!blocks_agent::get_chunk(*level->chunks, cx, cz)) {
|
||||
if (!blocks_agent::set(*level->chunks, x, y, z, id, int2blockstate(state))) {
|
||||
return 0;
|
||||
}
|
||||
blocks_agent::set(*level->chunks, x, y, z, id, int2blockstate(state));
|
||||
|
||||
auto chunksController = controller->getChunksController();
|
||||
if (chunksController == nullptr) {
|
||||
|
||||
@@ -79,9 +79,12 @@ static int l_textbox_paste(lua::State* L) {
|
||||
|
||||
static int l_container_add(lua::State* L) {
|
||||
auto docnode = get_document_node(L);
|
||||
if (docnode.document == nullptr) {
|
||||
throw std::runtime_error("target document not found");
|
||||
}
|
||||
auto node = dynamic_cast<Container*>(docnode.node.get());
|
||||
if (node == nullptr) {
|
||||
return 0;
|
||||
throw std::runtime_error("target container not found");
|
||||
}
|
||||
auto xmlsrc = lua::require_string(L, 2);
|
||||
try {
|
||||
@@ -99,7 +102,7 @@ static int l_container_add(lua::State* L) {
|
||||
UINode::getIndices(subnode, docnode.document->getMapWriteable());
|
||||
node->add(std::move(subnode));
|
||||
} catch (const std::exception& err) {
|
||||
throw std::runtime_error(err.what());
|
||||
throw std::runtime_error("container:add(...): " + std::string(err.what()));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ static int l_open(lua::State* L) {
|
||||
}
|
||||
return lua::pushinteger(L, hud->openInventory(
|
||||
layout,
|
||||
level->inventories->get(invid),
|
||||
lua::isnoneornil(L, 3) ? nullptr : level->inventories->get(invid),
|
||||
playerInventory
|
||||
)->getId());
|
||||
}
|
||||
|
||||
@@ -45,6 +45,12 @@ namespace {
|
||||
|
||||
template <SlotFunc func>
|
||||
int wrap_slot(lua::State* L) {
|
||||
if (lua::isnoneornil(L, 1)) {
|
||||
throw std::runtime_error("inventory id is nil");
|
||||
}
|
||||
if (lua::isnoneornil(L, 2)) {
|
||||
throw std::runtime_error("slot index is nil");
|
||||
}
|
||||
auto invid = lua::tointeger(L, 1);
|
||||
auto slotid = lua::tointeger(L, 2);
|
||||
auto& inv = get_inventory(invid);
|
||||
|
||||
Reference in New Issue
Block a user