New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API for changing a node's appearance #2887
Comments
I guess you will like #1118. |
Well, let's hope that a "snapshot" (if that kind of thing is done here) comes out with such a change so I can work on something that plans to use this functionality. |
Meta_set_nodedef is very powerfull, but it has some limitations:
I think the best approach would be two pronged:
The variant would be stored as a node field (like Here's a example of what an API might look like (string option): minetest.register_node("mymod:colored_wood", {
...
variants = {
blue = {tiles = {"mymod_wood_blue"}},
red = {tiles = {"mymod_wood_red"}},
}
}) |
Agreed, I, too, favour a variant like approach over one where the full nodedef gets specified in the nodedef. With client side scripting we could perhaps even have something even more flexible than what you described above, where the nodedef is returned by a function that gets the variant specifier/name/data as input. So e.g. you'd have client side code like (with the number option): local color_name_table = ["mymod_wood_blue", "mymod_wood_red", "mymod_wood_pink"]
minetest.set_node_variant_function("mymod:colored_wood",
-- returns the table overriding the nodedef, nil if variant_id is invalid
function(variant_id)
local color_name = color_name_table[variant_id]
if not color_name then
return nil
end
return {
tiles = {color_name}
}
end) |
Duplicate of #2107 |
Currently, there are only a few preset ways to change a node's appearance based on its node data. I propose moving this functionality to the API.
Perhaps having
minetest.change_tile(pos, node, tiles)
andminetest.change_nodebox(pos, node, nodebox)
, or making the tile and nodebox fields of the node definitions take functions as well as fixed values?The text was updated successfully, but these errors were encountered: