I noticed that it is possible to add custom fields to item definitions. For example, if you do this:
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:hello", {
description="HelloNode",
tiles = { "example_hello.png" },
my_custom_field_1 = "Test",
my_custom_field_2 = 123,
my_custom_field_3 = true,
})
It works! The 3 custom fields will be retained and can later be queried by using minetest.registered_nodes.
I wonder if the practice of adding custom fields to item definitions is “allowed” and intended by Minetest or if this is just possible “by pure luck” and may be deprecated or unsupported later.
Also, is this safe? Can I really store arbitrary information in any item definition like this? Or is there a risk of data loss?
If this is safe and intended, that would be very useful!
If yes, Minetest should introduce some naming conventions.
Like, custom fields should always have the form “x_modname_fieldname” to avoid naming collisions.