New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Play tool breaking sounds. #3605
Conversation
This should be in |
Like the idea. |
Changed to |
edit: also updated |
Note I have added 3 sound effects as well in minetest_game. |
yeah This doesn't even run for me... break is a lua reserved word? |
|
For consistency, adjusted the sound names and names of sound files as well in the |
@est31 also, this properly tests for |
👍 |
@@ -3305,6 +3305,7 @@ Definition tables | |||
}, | |||
damage_groups = {groupname=damage}, | |||
}, | |||
sound.breaks = "default_tool_break", -- tools only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sound
table is already present 10 lines below. Please move breaks
into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh yes, I didn't even know there was a place
sound as well :)
Can be done in subgames or by mods, no need to add this to core. 👎 |
👍 for concept, however, isn't the tool worn elsewhere? It should be consistent. Maybe it should be in the place that sets count to zero after the tool is worn. |
@BlockMen To do this efficiently in mods would require to override the on_wear() of every single tool that you'd want to attach this sound effect to. That's dumb, and not something mods should ever attempt to do. |
@rubenwardy This is the place in lua where the count gets set to zero, and the tool is removed from the inventory. (C++ does the taking, hence the code here detects that that has occurred). |
What about weapons, get worn on punch. And other wear additions. |
@rubenwardy The only occurrence of So hitting a player with a sword will not wear the sword, currently. I can't confirm this at the moment, as hitting myself in the office with a wooden sword would look kind of odd. (This would also be a separate bug, obviously). |
I think @BlockMen raises a valid point here. Why should this be done in core? Also, @sofar, there is no |
@PilzAdam I'm up for solutions, but without a callback there is no way to determine right now in the game that an entity has been hit with a sword, except by coding all the entities and adding damage handlers that also wear out the sword. It seems to me that an implementation that forces the mod writers to call tool:add_wear() inside the entities:on_punch is anything but a structurally good approach. (If it wants to add more wear, or refund some wear, sure, that would be a special circumstance, and the entitiy code already can do that) So something needs to be added in core, this can't be done in minetest_game. At least I don't see how. Even if we'd add an |
👍 |
I count two 👍 from core devs. |
And one 👎 . So it needs one additional 👍 , no? |
I want to see an on_wear callback as well as something like a on_punchentity. |
Hm it almost has 2 disapprovals, so perhaps discussion should continue a little longer. |
I think @est31 were joking, as he has already approved earlier. I don't see a reason for his disapproval either. |
There already is a
So, while @BlockMen is complaining that it can be done in subgames, it completely fails to acknowledge that if that indeed is the major concern, it forces us to to add This patch does not remove the ability of ~~~subgames~~~mods to override the sound - it makes that trivially easy, one can even just override the tooldef So, politely, @BlockMen s disaproval is short-sighted, and this patch adds functionality that makes it significantly easier for mod writers to add tool breaking sounds, and especially, it allows mintest_game to trivially add tool breaking sounds as well. |
Since the disapproval was BlockMen's, core devs need to make an executive decision, which looks to me like PilzAdam's reservations need to be addressed. |
Didn't BlockMen leave Minetest? It seems we have our two approvals, and an expired disapproval. Although, I would prefer an on_wear or on_tool_break callback, though IMHO. |
This isn't a numbers game @C1ffisme - it's a question of ascertaining whether the issues raised are still valid. |
Well i think this can probably go ahead unless there are objections. |
Minor edit needed, then it can be merged. |
Updated, thanks! |
If a tool wears out and is destroyed, it's itemstack count goes to 0, and we can optionally play a breaking sound. This patch implements playing a breaking sound when this occurs. Sounds need to be added to the tool itemdef registration as the sound name string in the .sound.breaks member.
I agree with @0-afflatus on this. |
@PilzAdam any objections to merge? |
I'm obviously somewhat biased on the discussion, but here's how I felt the arguments played out technically: The main argument was: this patch isn't generic enough. The alternative solution proposes to make a function that essentially has a single use (play a sound when a tool breaks). While there may be some use for it, there are arguments against that as well: (a) there's already a far more generic event that can be used to do exactly that, (b) essentially the only use for it in minetest_game will always and forever likely be to play the breaking sound. Now, from a sound perspective, the objection has been that clients are playing the sounds, not the server through lua. My problem with that is that (1) that's almost irrelevant from a mod perspective, and (2) it's against what I think is the right place and way to encode sound properties of a craftitem, which is obviously a "property", and not an event handler. Now, we can't play tool breaking sounds in the client since the client has no way to identify whether a stack went to 0(zero) count because something moved the thing in there, or because the server broke it, so then it would be appropriate for the server code to tell the client to play a breaking sound, right? But that's exactly what this patch does, except it's in lua, and not C++. Then there's an argument for taking this patch, which enables without obstructing further enhancement to convert the current code into what was alternatively proposed. The argument that was brought up that the after_use() event is too complex is a bit nearsighted, as the code needed to wear out is 1 line in C++, and could easily be done in lua IMHO. To me, at the end, I still favor this simple approach. There are a lot of mods that will want to add sound effects to their versions of tools, and I think this is the easiest method. |
I think there should be a default |
If you prefer that all tools have the same breaking sounds, then we should implement an However, I think that doing so isn't appropriate, and this PR doesn't attach a tool breaking sound to any node by default. There are no default node sounds for most nodes, so, similarly, I don't think there should be default tool breaking sounds for tools. |
@sofar I'm not saying that all tools should have the same sound. There still should be |
Will this only work when digging nodes? If that is the case, an |
@PilzAdam, the problem I have is requiring everyone to include 2 lines instead of one, for every tooldef, to enable sounds. First you require Then you still require All I'm saying is, let's do the second part and omit the awkward function callback for now. If it really is such a problem and people revolt, not much is lost by adding it later. |
This would be set by builtin. Same concept as e.g. for |
👍 |
Has 2 approvals but sofar may update this, so wait until after release? @sofar |
Let's revisit this after the release. |
Seeing the code it actually looks like that's basically what's already doing. Just that instead of using a default function, it checks if the function is defined and if not it performs the default action directly there, saving a function call, which might be more efficient. Well, having the default action inside a function has an advantage if you want to expose it for mods to use directly. But I'm not sure if it's useful enough to matter much. |
👍 |
If a tool wears out and is destroyed, it's itemstack count
goes to 0, and we can optionally play a breaking sound.
This patch implements playing a breaking sound when this
occurs. Sounds need to be added to the tool itemdef
registration as the sound name string in the .sound_break
member.