Add Help entry aliases for many core items

This commit is contained in:
Wuzzy 2017-03-20 18:12:05 +01:00
parent b6426df676
commit b1b45274e4
40 changed files with 169 additions and 16 deletions

View file

@ -6,6 +6,9 @@
mcl_clock = {}
-- This is the itemstring of the default clock item. It is used for the default inventory image, help entries, and the like
mcl_clock.stereotype = "mcl_clock:clock"
local watch = {}
watch.old_time = -1
@ -26,21 +29,26 @@ function watch.get_clock_frame()
return tostring(t)
end
local doc_mod = minetest.get_modpath("doc") ~= nil
-- Register items
function watch.register_item(name, image, creative)
local g = 1
if creative then
g = 0
end
local doc = name == "mcl_clock:clock"
local use_doc = name == mcl_clock.stereotype
if doc_mod and not use_doc then
doc.add_entry_alias("craftitems", mcl_clock.stereotype, "craftitems", name)
end
local longdesc, usagehelp
if doc then
if use_doc then
longdesc = "Clocks are tools which shows the current time of day in the Overworld."
usagehelp = "The clock contains a rotating disc with a sun symbol (yellow disc) and moon symbol and a little “pointer” which shows the current time of day by estimating the real position of the sun and the moon in the sky. Noon is represented by the sun symbol and midnight is represented by the moon symbol."
end
minetest.register_craftitem(name, {
description = "Clock",
_doc_items_create_entry = doc,
_doc_items_create_entry = use_doc,
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usagehelp,
inventory_image = image,
@ -69,7 +77,7 @@ minetest.register_globalstep(function(dtime)
for p, player in ipairs(players) do
for s, stack in ipairs(player:get_inventory():get_list("main")) do
local count = stack:get_count()
if stack:get_name() == "mcl_clock:clock" then
if stack:get_name() == mcl_clock.stereotype then
player:get_inventory():set_stack("main", s, "mcl_clock:clock_"..now.." "..count)
elseif string.sub(stack:get_name(), 1, 16) == "mcl_clock:clock_" then
player:get_inventory():set_stack("main", s, "mcl_clock:clock_"..now.." "..count)
@ -80,14 +88,14 @@ end)
-- Immediately set correct clock time after crafting
minetest.register_on_craft(function(itemstack)
if itemstack:get_name() == "mcl_clock:clock" then
if itemstack:get_name() == mcl_clock.stereotype then
itemstack:set_name("mcl_clock:clock_"..watch.get_clock_frame())
end
end)
-- Clock recipe
minetest.register_craft({
output = 'mcl_clock:clock',
output = mcl_clock.stereotype,
recipe = {
{'', 'mcl_core:gold_ingot', ''},
{'mcl_core:gold_ingot', 'mesecons:redstone', 'mcl_core:gold_ingot'},
@ -96,7 +104,7 @@ minetest.register_craft({
})
-- Clock tool
watch.register_item("mcl_clock:clock", watch.images[1], true)
watch.register_item(mcl_clock.stereotype, watch.images[1], true)
-- Faces
for a=0,63,1 do
@ -109,4 +117,3 @@ for a=0,63,1 do
watch.register_item("mcl_clock:clock_"..tostring(a), watch.images[b+1], false)
end
mcl_clock.stereotype = "mcl_clock:clock"