Change node after digging

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Change node after digging

by Wuzzy » Fri Jun 26, 2015 13:58

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.
 

User avatar
LionsDen
Member
 
Posts: 525
Joined: Thu Jun 06, 2013 03:19

Re: Change node after digging

by LionsDen » Fri Jun 26, 2015 16:37

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
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Change node after digging

by rubenwardy » Fri Jun 26, 2015 17:42

He's talking about client side prediction, a lua method wouldn't be enough.
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: Change node after digging

by Wuzzy » Fri Jun 26, 2015 20:48

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.
 

User avatar
addi
Member
 
Posts: 605
Joined: Thu Sep 20, 2012 03:16

Re: Change node after digging

by addi » Mon Jun 29, 2015 07:02

This would a relay great feature. minetest.remove_node should not changed. remove is remove. but mintest.dig_node should.
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: Change node after digging

by Wuzzy » Mon Jun 29, 2015 11:52

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.
 


Return to Minetest Features

Who is online

Users browsing this forum: Bing [Bot] and 39 guests

cron