forked from MineClone5/MineClone5
Compare commits
No commits in common. "testing" and "master" have entirely different histories.
|
@ -1,24 +0,0 @@
|
||||||
# mcl_item_id
|
|
||||||
Show the item ID of an item in the description.
|
|
||||||
With this API, you can register a different name space than "mineclone" for your mod.
|
|
||||||
|
|
||||||
## mcl_item_id.set_mod_namespace(modname, namespace)
|
|
||||||
Set a name space for all items in a mod.
|
|
||||||
|
|
||||||
* param1: the modname
|
|
||||||
* param2: (optional) string of the desired name space, if nil, it is the name of the mod
|
|
||||||
|
|
||||||
## mcl_item_id.get_mod_namespace(modname)
|
|
||||||
Get the name space of a mod registered with mcl_item_id.set_mod_namespace(modname, namespace).
|
|
||||||
|
|
||||||
* param1: the modname
|
|
||||||
|
|
||||||
### Examples:
|
|
||||||
|
|
||||||
The name of the mod is "mod" which registered an item called "mod:itemname".
|
|
||||||
|
|
||||||
* mcl_item_id.set_mod_namespace("mod", "mymod") will show "mymod:itemname" in the description of "mod:itemname"
|
|
||||||
* mcl_item_id.set_mod_namespace(minetest.get_current_modname()) will show "mod:itemname" in the description of "mod:itemname"
|
|
||||||
* mcl_item_id.get_mod_namespace(minetest.get_current_modname()) will return "mod"
|
|
||||||
|
|
||||||
(If no namespace is set by a mod, mcl_item_id.get_mod_namespace(minetest.get_current_modname()) will return "mineclone")
|
|
|
@ -1,26 +1,6 @@
|
||||||
mcl_item_id = {
|
|
||||||
mod_namespaces = {},
|
|
||||||
}
|
|
||||||
|
|
||||||
local game = "mineclone"
|
local game = "mineclone"
|
||||||
|
|
||||||
function mcl_item_id.set_mod_namespace(modname, namespace)
|
|
||||||
local namespace = namespace or modname
|
|
||||||
mcl_item_id.mod_namespaces[modname] = namespace
|
|
||||||
end
|
|
||||||
|
|
||||||
function mcl_item_id.get_mod_namespace(modname)
|
|
||||||
local namespace = mcl_item_id.mod_namespaces[modname]
|
|
||||||
if namespace then
|
|
||||||
return namespace
|
|
||||||
else
|
|
||||||
return game
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local same_id = {
|
local same_id = {
|
||||||
enchanting = { "table" },
|
|
||||||
experience = { "bottle" },
|
|
||||||
heads = { "skeleton", "zombie", "creeper", "wither_skeleton" },
|
heads = { "skeleton", "zombie", "creeper", "wither_skeleton" },
|
||||||
mobitems = { "rabbit", "chicken" },
|
mobitems = { "rabbit", "chicken" },
|
||||||
walls = {
|
walls = {
|
||||||
|
@ -30,7 +10,7 @@ local same_id = {
|
||||||
"stonebrick", "stonebrickmossy",
|
"stonebrick", "stonebrickmossy",
|
||||||
},
|
},
|
||||||
wool = {
|
wool = {
|
||||||
"black", "blue", "brown", "cyan", "green",
|
"black", "blue", "brown", "cyan", "green",
|
||||||
"grey", "light_blue", "lime", "magenta", "orange",
|
"grey", "light_blue", "lime", "magenta", "orange",
|
||||||
"pink", "purple", "red", "silver", "white", "yellow",
|
"pink", "purple", "red", "silver", "white", "yellow",
|
||||||
},
|
},
|
||||||
|
@ -38,11 +18,9 @@ local same_id = {
|
||||||
|
|
||||||
tt.register_snippet(function(itemstring)
|
tt.register_snippet(function(itemstring)
|
||||||
local def = minetest.registered_items[itemstring]
|
local def = minetest.registered_items[itemstring]
|
||||||
|
local desc = def.description
|
||||||
local item_split = itemstring:find(":")
|
local item_split = itemstring:find(":")
|
||||||
local id_string = itemstring:sub(item_split)
|
local new_id = game .. itemstring:sub(item_split)
|
||||||
local id_modname = itemstring:sub(1, item_split - 1)
|
|
||||||
local new_id = game .. id_string
|
|
||||||
local mod_namespace = mcl_item_id.get_mod_namespace(id_modname)
|
|
||||||
for mod, ids in pairs(same_id) do
|
for mod, ids in pairs(same_id) do
|
||||||
for _, id in pairs(ids) do
|
for _, id in pairs(ids) do
|
||||||
if itemstring == "mcl_" .. mod .. ":" .. id then
|
if itemstring == "mcl_" .. mod .. ":" .. id then
|
||||||
|
@ -50,13 +28,12 @@ tt.register_snippet(function(itemstring)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if mod_namespace ~= game then
|
if new_id ~= game .. ":book_enchanted" then
|
||||||
new_id = mod_namespace .. id_string
|
|
||||||
end
|
|
||||||
if mod_namespace ~= id_modname then
|
|
||||||
minetest.register_alias_force(new_id, itemstring)
|
minetest.register_alias_force(new_id, itemstring)
|
||||||
end
|
end
|
||||||
if minetest.settings:get_bool("mcl_item_id_debug", false) then
|
if minetest.settings:get_bool("mcl_item_id_debug", false) then
|
||||||
return new_id, "#555555"
|
return new_id, "#555555"
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
minetest.register_alias_force(game .. ":book_enchanted", "mcl_enchanting:book_enchanted")
|
||||||
|
|
|
@ -35,13 +35,13 @@ local function potions_init_icons(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
icon_ids[name] = {}
|
icon_ids[name] = {}
|
||||||
for e=1, EFFECT_TYPES do
|
for e=1, EFFECT_TYPES do
|
||||||
local x = -52 * e - 2
|
local x = -7 + -38 * e
|
||||||
local id = player:hud_add({
|
local id = player:hud_add({
|
||||||
hud_elem_type = "image",
|
hud_elem_type = "image",
|
||||||
text = "blank.png",
|
text = "blank.png",
|
||||||
position = { x = 1, y = 0 },
|
position = { x = 1, y = 0 },
|
||||||
offset = { x = x, y = 3 },
|
offset = { x = x, y = 272 },
|
||||||
scale = { x = 3, y = 3 },
|
scale = { x = 2, y = 2 },
|
||||||
alignment = { x = 1, y = 1 },
|
alignment = { x = 1, y = 1 },
|
||||||
z_index = 100,
|
z_index = 100,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue