Compare commits

...

15 Commits

Author SHA1 Message Date
NO11 6b3d9f7213 Merge branch 'production' into testing 2021-08-02 12:32:31 +00:00
kay27 a1e6aeb79d Merge remote-tracking branch 'origin/master' into testing 2021-08-02 02:35:22 +04:00
kay27 2582da99e8 Merge remote-tracking branch 'mcl2/master' into testing 2021-08-02 02:35:19 +04:00
NO11 4aabd7d9e7 Make size/position of potion HUD more MC like 2021-08-01 12:10:00 +00:00
kay27 d9c29d156b Merge pull request 'Merge critical fix into production' (#20) from master into production
Reviewed-on: MineClone5/MineClone5#20
Reviewed-by: Emojigit <emojigit@noreply.git.minetest.land>
2021-07-29 07:45:06 +00:00
Elias Fleckenstein 88f253bf66 Merge pull request 'raycast based buckets' (#1811) from buckets into master
Reviewed-on: MineClone2/MineClone2#1811
2021-07-26 16:59:15 +00:00
NO11 289ba826ba Merge pull request 'Fix #1842 (several fixes for `mcl_item_id`)' (#1843) from NO11/MineClone2:item_id_fixes into master
Reviewed-on: MineClone2/MineClone2#1843
2021-07-24 19:15:53 +00:00
NO11 4846076c8f `mcl_item_id` simplify code 2021-07-24 19:07:44 +00:00
NO11 5c5c405ccf Add missing check 2021-07-24 15:19:10 +00:00
NO11 65d33b935a Add API-md for `mcl_item_id` 2021-07-24 14:45:55 +00:00
NO11 c05e57efb1 Fix some crashes with set_mod_namespace and bugs 2021-07-24 14:09:47 +00:00
NO11 e44e9eaf62 Fix typo 2021-07-23 21:35:10 +00:00
NO11 09a68443cd Better fix for #1842 (make other mods not using "mineclone" name space for item ids) 2021-07-23 16:12:43 +00:00
NO11 75b425ffd7 Fix #1842 make other mods not using "mineclone" name space for item ids 2021-07-23 12:23:30 +00:00
NO11 0a9ea7e46a Merge pull request 'master' (#4) from MineClone2/MineClone2:master into master
Reviewed-on: NO11/MineClone2#4
2021-07-23 12:18:22 +00:00
3 changed files with 57 additions and 10 deletions

View File

@ -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")

View File

@ -1,6 +1,26 @@
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 = {
@ -10,7 +30,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",
}, },
@ -18,9 +38,11 @@ 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 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 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
@ -28,12 +50,13 @@ tt.register_snippet(function(itemstring)
end end
end 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) 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")

View File

@ -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 = -7 + -38 * e local x = -52 * e - 2
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 = 272 }, offset = { x = x, y = 3 },
scale = { x = 2, y = 2 }, scale = { x = 3, y = 3 },
alignment = { x = 1, y = 1 }, alignment = { x = 1, y = 1 },
z_index = 100, z_index = 100,
}) })