Modify a node property from another mod

User avatar
Zerock
Member
 
Posts: 10
Joined: Sat May 23, 2015 15:06
GitHub: 2mac
IRC: Zerock
In-game: Zerock

Modify a node property from another mod

by Zerock » Thu Jun 09, 2016 17:54

I plan on soon beginning development on an extensive modpack which will require overrides of many default node definitions. Rather than having to fork the default mod, I'd like to re-register the ones that need changing.

Question 1: can you even re-register a node with the same name as an existing one?

If possible then,

Question 2: would I have to redefine the entire node, or could I somehow get all the properties of, say, default:dirt, make my modifications, and re-register default:dirt with the new node table?
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: Modify a node property from another mod

by kaeza » Thu Jun 09, 2016 21:46

Look for `override_item` in the API docs. Here is an example of use.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
Zerock
Member
 
Posts: 10
Joined: Sat May 23, 2015 15:06
GitHub: 2mac
IRC: Zerock
In-game: Zerock

Re: Modify a node property from another mod

by Zerock » Fri Jun 10, 2016 02:01

If I wanted to modify the groups of the node, would I have to know the original groups, or can I append to them?
 

User avatar
duane
Member
 
Posts: 776
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r

Re: Modify a node property from another mod

by duane » Fri Jun 10, 2016 02:15

Zerock wrote:If I wanted to modify the groups of the node, would I have to know the original groups, or can I append to them?


Try "node.groups.newgroup = 1"
 

User avatar
Zerock
Member
 
Posts: 10
Joined: Sat May 23, 2015 15:06
GitHub: 2mac
IRC: Zerock
In-game: Zerock

Re: Modify a node property from another mod

by Zerock » Fri Jun 10, 2016 13:30

How can I get "node" in that context? I've been looking at the API docs for node lookup, but the only functions with names resembling what I'd expect to get node information are only lookups by position, not registered node name.
 

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

Re: Modify a node property from another mod

by rubenwardy » Fri Jun 10, 2016 13:36

minetest.registered_nodes["modname:itemname"] gives you the def table
 

User avatar
Zerock
Member
 
Posts: 10
Joined: Sat May 23, 2015 15:06
GitHub: 2mac
IRC: Zerock
In-game: Zerock

Re: Modify a node property from another mod

by Zerock » Fri Jun 10, 2016 14:27

Very good. I'll give this a shot.
 

User avatar
Zerock
Member
 
Posts: 10
Joined: Sat May 23, 2015 15:06
GitHub: 2mac
IRC: Zerock
In-game: Zerock

Re: Modify a node property from another mod

by Zerock » Fri Jun 10, 2016 17:56

This doesn't seem to work.

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.registered_nodes['default:dirt'].groups.falling_node = 1


throws

attempt to index field 'default:dirt' (a nil value)
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Modify a node property from another mod

by Krock » Fri Jun 10, 2016 18:27

Zerock wrote:attempt to index field 'default:dirt' (a nil value)

Is "default" in your depends.txt file? If not, add it. (Create the file if it's missing)
This error means that the node was not registered yet to the time when Minetest loaded your mod. Adding it to the dependencies will load your mod after the listed mods.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
Zerock
Member
 
Posts: 10
Joined: Sat May 23, 2015 15:06
GitHub: 2mac
IRC: Zerock
In-game: Zerock

Re: Modify a node property from another mod

by Zerock » Fri Jun 10, 2016 22:25

Okay, that seems to have worked, but now the line seems to have no effect. Dirt doesn't fall.
 

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

Re: Modify a node property from another mod

by rubenwardy » Fri Jun 10, 2016 23:20

You also need to depend on farming, as farming destructively overrides the dirty groups
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron