How to register nodes in-game.
I hope some clever member can answer me this riddle:
I am attempting to make an in-game node designer featuring a 3x 16x16 grid for the top and side views.
The idea is that it must be possible to design some shabe in-game, put a material on it and be ready for prodigtion of the new block.
Of course it would be saved in the particular world and be editable but so far I am stuck at simply registering a new node dynamically with textures and all.
This is my test code:
I works nicely in the sende that I can give myself the register_node block, place it and punch it to get the "new_node" registered with minetest.
However it is pictures as an "unkown block" and does not seem to care about the node box, textures or anything else for that matter except the name.
My question is this: What do I do to make minetest process the new node - like any nodes are processed on world startup - to get textures, nodebox etc. registered?
I could be fun to "liberate" minetest from having to only provide shapes which are predefined and allow (priviledged) users to create new shapes in-game.
I hope someone knows the answer to this.
I am attempting to make an in-game node designer featuring a 3x 16x16 grid for the top and side views.
The idea is that it must be possible to design some shabe in-game, put a material on it and be ready for prodigtion of the new block.
Of course it would be saved in the particular world and be editable but so far I am stuck at simply registering a new node dynamically with textures and all.
This is my test code:
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
local node_registered = false
minetest.register_node("kpomod:register_node", {
description = "Register a new node type when punched",
tiles = {"kpomod_white_brick.png"},
inventory_image = minetest.inventorycube("kpomod_white_brick.png"),
is_ground_content = true,
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
on_punch = function(pos, node, puncher)
if node_registered == false then
print("Registering new node: kpomod:new_node")
new_node()
print("Registering new node: kpomod:new_node done")
node_registered = true
end
end
})
new_node = function()
minetest.register_node(
":kpomod:new_node",
{ description = "Register a new node type when punched",
drawtype = "nodebox",
tiles = {"kpomod_white_brick.png"},
inventory_image = minetest.inventorycube("kpomod_white_brick.png"),
is_ground_content = true,
groups = {cracky=3},
node_box = {
type = "fixed",
fixed = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15}
},
on_punch = function(pos, node, puncher)
print("New node punched")
end
})
end
I works nicely in the sende that I can give myself the register_node block, place it and punch it to get the "new_node" registered with minetest.
However it is pictures as an "unkown block" and does not seem to care about the node box, textures or anything else for that matter except the name.
My question is this: What do I do to make minetest process the new node - like any nodes are processed on world startup - to get textures, nodebox etc. registered?
I could be fun to "liberate" minetest from having to only provide shapes which are predefined and allow (priviledged) users to create new shapes in-game.
I hope someone knows the answer to this.