From 232d3ff473c68af592fe8a91af515bb811ab60e0 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 2 Nov 2016 22:53:34 +0100 Subject: [PATCH] Use new doc_items data format --- depends.txt | 1 + init.lua | 32 +++++++++++++++----------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/depends.txt b/depends.txt index a61ffbc..dc9465e 100644 --- a/depends.txt +++ b/depends.txt @@ -1,3 +1,4 @@ mana? intllib? +doc? doc_items? diff --git a/init.lua b/init.lua index 5297271..35319a1 100644 --- a/init.lua +++ b/init.lua @@ -60,8 +60,21 @@ returnmirror.set_position_active = function(itemstack, user, pointed_thing) end end +local longdesc, usagehelp +if minetest.get_modpath("doc_items") then + usagehelp = S("Rightclick to set the mirror's teleport location. Leftclick to immediately teleport back to the mirror's teleport location.") + if minetest.get_modpath("mana") ~= nil then + longdesc = S("This item allows to teleport the user back to a previously set location, at the cost of mana.") + usagehelp = usagehelp .. " " .. string.format(S("Setting the teleport location costs %d mana, teleporting costs %d mana."), returnmirror.cost_set, returnmirror.cost_teleport) + else + longdesc = S("This item allows to teleport its user back to a previously set location.") + end +end + minetest.register_tool("returnmirror:mirror_inactive", { description = S("Mirror of Returning"), + x_doc_items_longdesc = longdesc, + x_doc_items_usagehelp = usagehelp, inventory_image = "returnmirror_mirror_inactive.png", wield_image = "returnmirror_mirror_inactive.png", tool_capabilities = {}, @@ -75,6 +88,7 @@ minetest.register_tool("returnmirror:mirror_inactive", { minetest.register_tool("returnmirror:mirror_active", { description = S("Mirror of Returning"), + x_doc_items_create_entry = false, stack_max = 1, inventory_image = "returnmirror_mirror_active.png", wield_image = "returnmirror_mirror_active.png", @@ -130,22 +144,6 @@ minetest.register_tool("returnmirror:mirror_active", { minetest.register_alias("returnmirror:mirror_inactive", "returnmirror:returnmirror") -if minetest.get_modpath("doc_items") ~= nil then - local longdesc, usagehelp - usagehelp = S("Rightclick to set the mirror's teleport location. Leftclick to immediately teleport back to the mirror's teleport location.") - if minetest.get_modpath("mana") ~= nil then - longdesc = S("This item allows to teleport the user back to a previously set location, at the cost of mana.") - usagehelp = usagehelp .. " " .. string.format(S("Setting the teleport location costs %d mana, teleporting costs %d mana."), returnmirror.cost_set, returnmirror.cost_teleport) - else - longdesc = S("This item allows to teleport its user back to a previously set location.") - end - - doc.sub.items.set_items_longdesc({ - ["returnmirror:mirror_inactive"] = longdesc, - }) - doc.sub.items.set_items_usagehelp({ - ["returnmirror:mirror_inactive"] = usagehelp - }) - +if minetest.get_modpath("doc") ~= nil then doc.add_entry_alias("tools", "returnmirror:mirror_inactive", "returnmirror:mirror_active") end