diff options
author | Wuzzy <Wuzzy@disroot.org> | 2022-06-03 19:47:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-03 21:47:04 +0200 |
commit | 6a6b579c5472065dd4ba8edcebe120b4b1c9198e (patch) | |
tree | f9cd6f5fd653e9ad394be96ab0ccac7ba82fb26a /src/script/lua_api/l_util.cpp | |
parent | 6d163b72dc777c6dfc62175c7af231cd62e5c2c7 (diff) | |
download | minetest-6a6b579c5472065dd4ba8edcebe120b4b1c9198e.tar.gz minetest-6a6b579c5472065dd4ba8edcebe120b4b1c9198e.tar.bz2 minetest-6a6b579c5472065dd4ba8edcebe120b4b1c9198e.zip |
Add helper functions to make tool usable n times (#12047)
Diffstat (limited to 'src/script/lua_api/l_util.cpp')
-rw-r--r-- | src/script/lua_api/l_util.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/script/lua_api/l_util.cpp b/src/script/lua_api/l_util.cpp index 97068ce4c..f774daf97 100644 --- a/src/script/lua_api/l_util.cpp +++ b/src/script/lua_api/l_util.cpp @@ -159,6 +159,17 @@ int ModApiUtil::l_write_json(lua_State *L) return 1; } +// get_tool_wear_after_use(uses[, initial_wear]) +int ModApiUtil::l_get_tool_wear_after_use(lua_State *L) +{ + NO_MAP_LOCK_REQUIRED; + u32 uses = readParam<int>(L, 1); + u16 initial_wear = readParam<int>(L, 2, 0); + u16 wear = calculateResultWear(uses, initial_wear); + lua_pushnumber(L, wear); + return 1; +} + // get_dig_params(groups, tool_capabilities[, wear]) int ModApiUtil::l_get_dig_params(lua_State *L) { @@ -586,6 +597,7 @@ void ModApiUtil::Initialize(lua_State *L, int top) API_FCT(parse_json); API_FCT(write_json); + API_FCT(get_tool_wear_after_use); API_FCT(get_dig_params); API_FCT(get_hit_params); |