Merge pull request 'Add item IDs to the description of items' (#1841) from NO11/MineClone2:item_id into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/1841
This commit is contained in:
NO11 2021-07-20 11:57:33 +00:00
commit a83dd8548f
3 changed files with 42 additions and 0 deletions

View file

@ -0,0 +1,35 @@
local game = "mineclone"
local same_id = {
heads = { "skeleton", "zombie", "creeper", "wither_skeleton" },
mobitems = { "rabbit", "chicken" },
walls = {
"andesite", "brick", "cobble", "diorite", "endbricks",
"granite", "mossycobble", "netherbrick", "prismarine",
"rednetherbrick", "redsandstone", "sandstone",
"stonebrick", "stonebrickmossy",
},
wool = {
"black", "blue", "brown", "cyan", "green",
"grey", "light_blue", "lime", "magenta", "orange",
"pink", "purple", "red", "silver", "white", "yellow",
},
}
tt.register_snippet(function(itemstring)
local def = minetest.registered_items[itemstring]
local desc = def.description
local item_split = itemstring:find(":")
local new_id = game .. itemstring:sub(item_split)
for mod, ids in pairs(same_id) do
for _, id in pairs(ids) do
if itemstring == "mcl_" .. mod .. ":" .. id then
new_id = game .. ":" .. id .. "_" .. mod:gsub("s", "")
end
end
end
minetest.register_alias(new_id, itemstring)
if minetest.settings:get_bool("mcl_item_id_debug", true) then
return new_id, "#555555"
end
end)

View file

@ -0,0 +1,3 @@
name = mcl_item_id
author = NO11
depends = tt

View file

@ -153,3 +153,7 @@ fix_doubleplants (Mcimport double plant fixes) bool true
# Allow players to create Minecraft-like maps.
enable_real_maps (Enable Real Maps) bool true
[Debugging]
# If enabled, this will show the itemstring of an item in the description.
mcl_item_id_debug (Item ID Debug) bool false