Register a node based off a another node with an altered Def

Post Reply
User avatar
Extex
Member
Posts: 190
Joined: Wed Mar 14, 2018 23:14
GitHub: Extex101
In-game: Extex

Register a node based off a another node with an altered Def

by Extex » Post

I want to have a function that registers a node with the same properties as the previous one but with the addition of:
paramtype = "light",
light_source = 4,
on_construct = function(pos)
minetest.after(0.1, function()
--change to original node
end)
end,
Player of PK, RIP. Creator of the light_tool and motorbike mods. Working on another mod which should be coming soon!

ThorfinnS
Member
Posts: 253
Joined: Mon Feb 25, 2019 22:05
GitHub: ThorfinnS

Re: Register a node based off a another node with an altered

by ThorfinnS » Post

If you are saying you want two nodes with different properties, and one replaces the other, check out farming or farming redo or plantlife or moretrees or anything where a seedling or sapling is replaced by a mature or more mature version. To define those nodes, check out any of the crops in farming redo. (I'd stick with farming redo for the whole thing -- not only is everything (except corn?) exactly one node big, it's very easy to follow how you add a new property to the previous node.)

User avatar
Extex
Member
Posts: 190
Joined: Wed Mar 14, 2018 23:14
GitHub: Extex101
In-game: Extex

Re: Register a node based off a another node with an altered

by Extex » Post

No not like that here I'll give it to you in pseudocode

Make a function with an argument labeled `name`

Get block with the name of `name`
If it's a valid name then

Declare a table with the properties of the node

Add paramtype = "light" and light_source = 4
Register a node with the new Def with an altered name

end function
Player of PK, RIP. Creator of the light_tool and motorbike mods. Working on another mod which should be coming soon!

User avatar
duane
Member
Posts: 1637
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r
Location: Oklahoma City
Contact:

Re: Register a node based off a another node with an altered

by duane » Post

Extex wrote:Register a node with the new Def with an altered name
This is what I use. You can see it in use here.
Believe in people and you don't need to believe anything else.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest