diff options
author | rubenwardy <rw@rubenwardy.com> | 2021-01-31 18:49:51 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-31 18:49:51 +0000 |
commit | 6e0e0324a48130376ab3c9fef03b84ee25608242 (patch) | |
tree | 2ca83874980f8ade05401b828477fb0d03867886 /src/script/cpp_api | |
parent | d1ec5117d9095c75aca26a98690e4fcc5385e98c (diff) | |
download | minetest-6e0e0324a48130376ab3c9fef03b84ee25608242.tar.gz minetest-6e0e0324a48130376ab3c9fef03b84ee25608242.tar.bz2 minetest-6e0e0324a48130376ab3c9fef03b84ee25608242.zip |
Fix minetest.dig_node returning true when node isn't diggable (#10890)
Diffstat (limited to 'src/script/cpp_api')
-rw-r--r-- | src/script/cpp_api/s_node.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/script/cpp_api/s_node.cpp b/src/script/cpp_api/s_node.cpp index 269ebacb2..f23fbfbde 100644 --- a/src/script/cpp_api/s_node.cpp +++ b/src/script/cpp_api/s_node.cpp @@ -141,9 +141,14 @@ bool ScriptApiNode::node_on_dig(v3s16 p, MapNode node, push_v3s16(L, p); pushnode(L, node, ndef); objectrefGetOrCreate(L, digger); - PCALL_RES(lua_pcall(L, 3, 0, error_handler)); - lua_pop(L, 1); // Pop error handler - return true; + PCALL_RES(lua_pcall(L, 3, 1, error_handler)); + + // nil is treated as true for backwards compat + bool result = lua_isnil(L, -1) || lua_toboolean(L, -1); + + lua_pop(L, 2); // Pop error handler and result + + return result; } void ScriptApiNode::node_on_construct(v3s16 p, MapNode node) |