Aliases do not have to be registered within the mod which adds the item that the alias references; the alias registering code can be contained within a separate mod. Server owners could simply include one "aliases" mod which registers all of the aliases for all mods' items, so that conflicts are taken care of by default.
You could even make a mod which iterates through a table, using the strings in each row of each line for the parameters passed to the minetest.register_alias() function - instead of writing out the same function call once for each alias, only one function call needs to be existing in the mod file, which is put to work for each entry in the table. This has the result of decreasing the file size (by a fractional amount) when a large number of aliases need to be registered - it also makes the list a lot easier for the human to read, and easier for other mods to modify via table.insert() and other table modifying functions.
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
aliases = {
{"default:stick_pine","stick_pine"},
{"default:stick_jungle","stick_jungle"},
{"pub:bar","bar"},
{"foo:bar","foobar"},
}
for _, row in ipairs(aliases) do
local itemid = row[1]
local alias = row[2]
minetest.register_alias(alias,itemid)
end
However, the server owner would have to make each entry in the list, instead of simply having the alias registry entries done by each individual mod for its own items - also, the list would have to be updated every time a mod (for which an alias is registered) is removed, and every time a new mod is added for which the server owner desires aliases. But, it gets rid of the alias conflict problem, which results from independent mods creating aliases with the same name.