aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
Diffstat (limited to 'src/script')
-rw-r--r--src/script/common/c_content.cpp10
-rw-r--r--src/script/lua_api/l_object.cpp5
2 files changed, 7 insertions, 8 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index 9eba4cbf2..cb0253c32 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -164,11 +164,7 @@ void push_item_definition_full(lua_State *L, const ItemDefinition &i)
lua_pushboolean(L, i.liquids_pointable);
lua_setfield(L, -2, "liquids_pointable");
if (i.type == ITEM_TOOL) {
- push_tool_capabilities(L, ToolCapabilities(
- i.tool_capabilities->full_punch_interval,
- i.tool_capabilities->max_drop_level,
- i.tool_capabilities->groupcaps,
- i.tool_capabilities->damageGroups));
+ push_tool_capabilities(L, *i.tool_capabilities);
lua_setfield(L, -2, "tool_capabilities");
}
push_groups(L, i.groups);
@@ -1253,7 +1249,8 @@ void push_tool_capabilities(lua_State *L,
{
lua_newtable(L);
setfloatfield(L, -1, "full_punch_interval", toolcap.full_punch_interval);
- setintfield(L, -1, "max_drop_level", toolcap.max_drop_level);
+ setintfield(L, -1, "max_drop_level", toolcap.max_drop_level);
+ setintfield(L, -1, "punch_attack_uses", toolcap.punch_attack_uses);
// Create groupcaps table
lua_newtable(L);
// For each groupcap
@@ -1375,6 +1372,7 @@ ToolCapabilities read_tool_capabilities(
ToolCapabilities toolcap;
getfloatfield(L, table, "full_punch_interval", toolcap.full_punch_interval);
getintfield(L, table, "max_drop_level", toolcap.max_drop_level);
+ getintfield(L, table, "punch_attack_uses", toolcap.punch_attack_uses);
lua_getfield(L, table, "groupcaps");
if(lua_istable(L, -1)){
int table_groupcaps = lua_gettop(L);
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index 22445fc9a..efdb345c9 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -187,7 +187,8 @@ int ObjectRef::l_punch(lua_State *L)
u16 dst_origin_hp = puncher->getHP();
// Do it
- co->punch(dir, &toolcap, puncher, time_from_last_punch);
+ u16 wear = co->punch(dir, &toolcap, puncher, time_from_last_punch);
+ lua_pushnumber(L, wear);
// If the punched is a player, and its HP changed
if (src_original_hp != co->getHP() &&
@@ -202,7 +203,7 @@ int ObjectRef::l_punch(lua_State *L)
getServer(L)->SendPlayerHPOrDie((PlayerSAO *)puncher,
PlayerHPChangeReason(PlayerHPChangeReason::PLAYER_PUNCH, co));
}
- return 0;
+ return 1;
}
// right_click(self, clicker); clicker = an another ObjectRef