Page 1 of 1

Change node after digging

PostPosted: Fri Jun 26, 2015 13:58
by Wuzzy
Currently, after you have dug a node, it always turns into an “air” node (technically).

I suggest to add something to the node definition so the mod makers could choose to make a different node appear after it has been dug.

For example, you could turn a stone block into a stone block with cracks. Or you could turn an “underwater torch” into water (because air wouldn't be so great). There are a couple of other use cases for this.

Node drops should be unaffected by this; they still would have to be defined seperately.
If unspecified, it should default to air, so if you dig a block, it turns into air, which is the current behaviour.

I know, I know, all this could theoretically be done by using callbacks.
But by extending the node definition, client-side prediction could be made, too. AFAIK this would not be possible with using callbacks only. It also would be easier and faster to write in Lua.

Example:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_node("example:example", {
name = "some example node",
replace_node = "example:example2",
})


So example:example becomes example:example2 after digging.

I am not sure if the name “replace_node” fits best, suggest a better one if you know one.

Re: Change node after digging

PostPosted: Fri Jun 26, 2015 16:37
by LionsDen
I think the on_dig part of the node definition will be able to do what you want. Just add code in that part to check the particulars and make the changes.

Look here:

http://dev.minetest.net/minetest.register_node#on_dig

Re: Change node after digging

PostPosted: Fri Jun 26, 2015 17:42
by rubenwardy
He's talking about client side prediction, a lua method wouldn't be enough.

Re: Change node after digging

PostPosted: Fri Jun 26, 2015 20:48
by Wuzzy
Yes, rubenwardy is right.
Oh, another thing:

Do you think that minetest.remove_node should be changed as well? So that it leaves the “replace_node” behind instead of always air.

Re: Change node after digging

PostPosted: Mon Jun 29, 2015 07:02
by addi
This would a relay great feature. minetest.remove_node should not changed. remove is remove. but mintest.dig_node should.

Re: Change node after digging

PostPosted: Mon Jun 29, 2015 11:52
by Wuzzy
Note that minetest.remove_node(pos) is just a shorthand for
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.set_node(pos, {name="air"})


Anyways, the minetest.dig_node argument is convincing.