Skip to content
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 support for on_blast callback #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Wuzzy2
Copy link

@Wuzzy2 Wuzzy2 commented Sep 24, 2013

on_blast is a nice little callback for nodes to tell them that an explosion happened close to them. Look it up in the documentation.
It is not used in the engine atm, it is intended to be used by mods.

The current version of TNT blindly removes anything, not really taking into account the properties of the node.
This pull request adds support for the callback “on_blast”. Instead of directly removing the node, first we check wheather the node defines the function “on_blast”. If yes, we don’t remove the node and call this function instead. Also there will be no item drop caused by TNT. It is completely the “responsibility” of the node then to handle the explosion. If the on_blast is nil, we do the default behaviour: removing the node and dropping items (or not).

I recently changed the bedrock mod to use on_blast. Use the bedrock mod along with this code if you wish to test. See https://forum.minetest.net/viewtopic.php?pid=111868#p111868.

This pull request also adds on_blast on tnt:tnt and tnt:tnt_burning themselves. This does away with the awkward direct checking like “Are you a TNT? Yes? Then explode!”. This change makes the TNT mod more general purpose, so any other mod that involves explosive just has to call on_blast (if it’s not nil), not even knowing that the node is tnt:tnt and letting the tnt mod do the rest. :-)

Currently, the itensity is not taken into account, the TNT simply explodes always. I assume that TNT is very sensitive to explosions of any kind.

@webD97
Copy link

webD97 commented Oct 13, 2013

+1

@HybridDog
Copy link

Could you make a pull request for my changed tnt mod, too?
https://github.com/HybridDog/TNT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants