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
Make TNT respect on_blast, implement on_blast for some nodes #450
Conversation
Implemented nodes: - Steel Door: Ignores explosion - Locked Chest: Ignores explosion - Fire: Ignores explosion - TNT: Starts burning - Burning TNT: Explodes immediately - Gunpowder: Starts burning - Burning Gunpowder: Ignores explosion
👍 |
👍 It allows us to protect some nodes which souldn't be destroyed, be randomly destroyed or stay saved. |
👍 What about obsidian and default:cloud? They could ignore the explosion, just to give players and server moderators a way to protect their builds. |
Looks good, but some normal nodes (I mean, nodes you can build with) could be protected against blast (perhaps nodes such as some metal blocks would be a good idea). |
Yeah, or perhaps each metal/obsidian block could have their own destruction scripts with a chance wheather or not they blow up. |
Comments have been added. |
@@ -82,7 +82,14 @@ local function destroy(drops, pos, cid) | |||
if def and def.flammable then | |||
minetest.set_node(pos, fire_node) | |||
else | |||
minetest.remove_node(pos) | |||
local nodename = minetest.get_node(pos).name | |||
local on_blast = minetest.registered_nodes[nodename].on_blast |
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.
Use the cid_data
cache for this to prevent the expensive lookups.
👍 |
@PilzAdam and @ShadowNinja: Done. |
You should make on_blast destruct the other part of the object for multi-node objects (doors, beds, etc.) too; otherwise, looks good. |
@Novatux: Done. I have added Beds seem to already work out of the box, because they use There are no other multi-node objects in Minetest Game as far I know. |
pos.y = pos.y - 1 | ||
check_and_blast(pos, name..other_door_type) | ||
end | ||
end |
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 should use elseif
rather than an else if then end
chain.
Also, you can add a step
value of 1
or -1
instead of copy-pasting the function.
This PR alters the way how TNT destroys nodes in a way which I think is much saner and more mod-friendly.
It makes TNT check first whether the node which is about to be destoyed implements
on_blast
, a function which is supposed to be called when explosions occour (seelua_api.txt
). If this function exists, this function will be called. If this function does not exist, the TNT reverts to the default behavior, which is destroying the node withminetest.remove_node
.This should now finally make it possible to define nodes which are able to “defend themselves” against TNT explosions.
While I was at it, I also implemented on_blast for the following nodes:
This also replaces some of the destruction logic from the TNT node itself, it now only checks against air directly.