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
Add minetest.register_on_punchplayer #2691
Conversation
Please note that forceloaded areas are saved when the server restarts. | ||
* `minetest.register_on_punchplayer(player, hitter, time_from_last_punch, tool_capabilities, dir)` |
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.
I'm missing a func(
here.
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.
Fixed. It was in the original pull request like this and I didn't see the mistake.
When you
|
How can I force the send of an HP packet? The problem is, if I'm correct, that the HP packet is only send for an HP change (reasonable) but the client predicts the damage and applies it. Maybe the client should ask for a new HP packet after it predicts the damage? |
Ah I see. Ok, then it isn't required. 👍 if it gets squashed. |
Squashed. |
Changed the return from RUN_CALLBACKS_MODE_LAST to RUN_CALLBACKS_MODE_OR so any mods can log punch actions without re-enabling the damage. (Same commit) |
I fixed the damage prediction and server log anyway. Should I squash again? |
Please note that forceloaded areas are saved when the server restarts. | ||
* `minetest.register_on_punchplayer(func(player, hitter, time_from_last_punch, tool_capabilities, dir))` |
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.
This is in the wrong place, you should add it where all the other register_ons are.
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.
Sorry, fixed.
As a general rule, don't look at surrounding code for a style guide. People usually correct code around their patches, but that doesn't matter much. (Not usually a condition of merging) |
Style guide here. |
} | ||
|
||
|
||
actionstream<<"Player "<<m_player->getName()<<" punched by " |
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.
There should be spaces before and after each <<
.
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.
Fixed.
Very nice. I've already 👍 ed it. |
Maybe I should also pass the inflicted damage? I just realized it was missing. |
} else { | ||
actionstream << ", damage handled by lua"; | ||
} | ||
actionstream<<std::endl; |
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.
spaces :)
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.
Missed it. Now fixed.
Always squash the commits if the "function"/intent of the PR remains the same. E.g. something that fixes a typo or style issue in your PR should always be squashed. E.g.#2 none of the current extra commits changes what the PR does -- i.e. "add minetest.register_on_punchplayer" -- so they should be squashed, yes. |
Also pass the damage value to the on_punchplayer function and squashed everything in one commit. |
Fixed wrong comment, stating on_dieplayers and fixing the table name to core.registered_on_punchplayers (the s was missing). |
👍 |
@@ -38,6 +40,9 @@ class ScriptApiPlayer | |||
void on_joinplayer(ServerActiveObject *player); | |||
void on_leaveplayer(ServerActiveObject *player); | |||
void on_cheat(ServerActiveObject *player, const std::string &cheat_type); | |||
bool on_punchplayer(ServerActiveObject *player, |
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.
remove trailing whitespace please
removed them. c5b4e54 |
Rebase of #1307
Additionally adds a return value.
Return true to disable the damage handling.