forked from MineClone5/MineClone5
Compare commits
15 Commits
Author | SHA1 | Date |
---|---|---|
NO11 | 6b3d9f7213 | |
kay27 | a1e6aeb79d | |
kay27 | 2582da99e8 | |
NO11 | 4aabd7d9e7 | |
kay27 | d9c29d156b | |
Elias Fleckenstein | 88f253bf66 | |
NO11 | 289ba826ba | |
NO11 | 4846076c8f | |
NO11 | 5c5c405ccf | |
NO11 | 65d33b935a | |
NO11 | c05e57efb1 | |
NO11 | e44e9eaf62 | |
NO11 | 09a68443cd | |
NO11 | 75b425ffd7 | |
NO11 | 0a9ea7e46a |
|
@ -0,0 +1,24 @@
|
|||
# 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,6 +1,26 @@
|
|||
mcl_item_id = {
|
||||
mod_namespaces = {},
|
||||
}
|
||||
|
||||
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 = {
|
||||
enchanting = { "table" },
|
||||
experience = { "bottle" },
|
||||
heads = { "skeleton", "zombie", "creeper", "wither_skeleton" },
|
||||
mobitems = { "rabbit", "chicken" },
|
||||
walls = {
|
||||
|
@ -10,7 +30,7 @@ local same_id = {
|
|||
"stonebrick", "stonebrickmossy",
|
||||
},
|
||||
wool = {
|
||||
"black", "blue", "brown", "cyan", "green",
|
||||
"black", "blue", "brown", "cyan", "green",
|
||||
"grey", "light_blue", "lime", "magenta", "orange",
|
||||
"pink", "purple", "red", "silver", "white", "yellow",
|
||||
},
|
||||
|
@ -18,9 +38,11 @@ local same_id = {
|
|||
|
||||
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)
|
||||
local id_string = 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 _, id in pairs(ids) do
|
||||
if itemstring == "mcl_" .. mod .. ":" .. id then
|
||||
|
@ -28,12 +50,13 @@ tt.register_snippet(function(itemstring)
|
|||
end
|
||||
end
|
||||
end
|
||||
if new_id ~= game .. ":book_enchanted" then
|
||||
if mod_namespace ~= game then
|
||||
new_id = mod_namespace .. id_string
|
||||
end
|
||||
if mod_namespace ~= id_modname then
|
||||
minetest.register_alias_force(new_id, itemstring)
|
||||
end
|
||||
if minetest.settings:get_bool("mcl_item_id_debug", false) then
|
||||
return new_id, "#555555"
|
||||
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()
|
||||
icon_ids[name] = {}
|
||||
for e=1, EFFECT_TYPES do
|
||||
local x = -7 + -38 * e
|
||||
local x = -52 * e - 2
|
||||
local id = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
text = "blank.png",
|
||||
position = { x = 1, y = 0 },
|
||||
offset = { x = x, y = 272 },
|
||||
scale = { x = 2, y = 2 },
|
||||
offset = { x = x, y = 3 },
|
||||
scale = { x = 3, y = 3 },
|
||||
alignment = { x = 1, y = 1 },
|
||||
z_index = 100,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue