Add extended item tooltips

This commit is contained in:
Wuzzy 2019-12-05 10:30:46 +01:00
parent 477250afdb
commit c19a852667
31 changed files with 292 additions and 19 deletions

View File

@ -326,4 +326,13 @@ achievements.register_achievement(
times = 1,
})
if minetest.get_modpath("tt") then
tt.register_snippet(function(itemstring)
if minetest.get_item_group(itemstring, "is_armor") == 1 then
local a = minetest.get_item_group(itemstring, "armor")
return S("Protection: +@1%", a)
end
end)
end
default.log("mod:armor", "loaded")

View File

@ -271,6 +271,7 @@ minetest.register_node(
"bed:bed_foot",
{
description = S("Bed"),
_tt_help = S("Use it to sleep and pass the night"),
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",

View File

@ -14,6 +14,7 @@ minetest.register_craftitem(
":default:book",
{
description = S("Unnamed Book"),
_tt_help = S("Write down some notes"),
inventory_image = "default_book.png",
stack_max = 1,

View File

@ -1,9 +1,9 @@
local S = minetest.get_translator("default")
local water_buckets = {
{ "water", S("Water Bucket"), "default_bucket_water.png", "default:water_source" },
{ "river_water", S("River Water Bucket"), "default_bucket_river_water.png", "default:river_water_source" },
{ "swamp_water", S("Swamp Water Bucket"), "default_bucket_swamp_water.png", "default:swamp_water_source" },
{ "water", S("Water Bucket"), "default_bucket_water.png", "default:water_source", S("Places a water source") },
{ "river_water", S("River Water Bucket"), "default_bucket_river_water.png", "default:river_water_source", S("Places a river water source") },
{ "swamp_water", S("Swamp Water Bucket"), "default_bucket_swamp_water.png", "default:swamp_water_source", S("Places a swamp water source") },
}
for b=1, #water_buckets do
@ -12,6 +12,7 @@ for b=1, #water_buckets do
"default:bucket_"..bucket[1],
{
description = bucket[2],
_tt_help = bucket[5],
inventory_image = bucket[3],
stack_max = 1,
wield_scale = {x=1,y=1,z=2},
@ -65,6 +66,7 @@ minetest.register_craftitem(
"default:bucket",
{
description = S("Empty Bucket"),
_tt_help = S("Place it to collect a liquid source"),
inventory_image = "default_bucket.png",
stack_max = 10,
wield_scale = {x=1,y=1,z=2},

View File

@ -25,6 +25,7 @@ minetest.register_node(
"default:chest",
{
description = S("Chest"),
_tt_help = S("Provides 32 inventory slots"),
tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_sides.png",
"default_chest_sides.png", "default_chest_sides.png", "default_chest_front.png"},
paramtype2 = "facedir",
@ -76,6 +77,7 @@ minetest.register_node(
"default:bookshelf",
{
description = S("Bookshelf"),
_tt_help = S("Provides 32 inventory slots"),
tiles = {"default_wood.png", "default_wood.png", "default_bookshelf.png"},
paramtype2 = "facedir",
groups = {snappy = 2,choppy = 3,oddly_breakable_by_hand = 2},

View File

@ -6,6 +6,7 @@ minetest.register_node(
"default:fertilized_dirt",
{
description = S("Fertilized Dirt"),
_tt_help = S("Speeds up the growth of plants"),
tiles = {
"default_dirt.png^default_fertilizer.png",
"default_dirt.png",
@ -28,6 +29,7 @@ minetest.register_node(
"default:fertilized_dry_dirt",
{
description = S("Fertilized Dry Dirt"),
_tt_help = S("Speeds up the growth of plants"),
tiles = {
"default_dry_dirt.png^default_fertilizer.png",
"default_dry_dirt.png",
@ -50,6 +52,7 @@ minetest.register_node(
"default:fertilized_swamp_dirt",
{
description = S("Fertilized Swamp Dirt"),
_tt_help = S("Speeds up the growth of plants"),
tiles = {
"default_swamp_dirt.png^default_fertilizer.png",
"default_swamp_dirt.png",
@ -72,6 +75,7 @@ minetest.register_node(
"default:fertilized_sand",
{
description = S("Fertilized Sand"),
_tt_help = S("Speeds up the growth of plants"),
tiles = {"default_sand.png^default_fertilizer.png", "default_sand.png", "default_sand.png"},
groups = {
crumbly = 3,
@ -91,6 +95,7 @@ minetest.register_craftitem(
"default:fertilizer",
{
description = S("Fertilizer"),
_tt_help = S("Used to fertilize dirt and sand to speed up plant growth"),
inventory_image = "default_fertilizer_inventory.png",
wield_scale = {x=1,y=1,z=2},
on_place = function(itemstack, user, pointed_thing)

View File

@ -103,6 +103,7 @@ minetest.register_node(
"default:furnace",
{
description = S("Furnace"),
_tt_help = S("Uses fuel to smelt a material into something else"),
tiles ={"default_furnace_top.png", "default_furnace_top.png", "default_furnace_sides.png",
"default_furnace_sides.png", "default_furnace_sides.png", "default_furnace_front.png"},
paramtype2 = "facedir",
@ -139,7 +140,7 @@ minetest.register_node(
minetest.register_node(
"default:furnace_active",
{
description = S("Furnace (active)"),
description = S("Furnace (active)").. "\n" .. S("Uses fuel to smelt a material into something else"),
tiles ={"default_furnace_top.png", "default_furnace_top.png", "default_furnace_sides.png",
"default_furnace_sides.png", "default_furnace_sides.png", "default_furnace_front.png^default_furnace_flame.png"},
paramtype2 = "facedir",

View File

@ -396,6 +396,7 @@ minetest.register_node(
"default:sapling",
{
description = S("Sapling"),
_tt_help = S("Grows into an apple tree"),
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"default_sapling.png"},
@ -427,6 +428,7 @@ minetest.register_node(
"default:sapling_oak",
{
description = S("Oak Sapling"),
_tt_help = S("Grows into an oak tree"),
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"default_sapling_oak.png"},
@ -457,6 +459,7 @@ minetest.register_node(
"default:sapling_birch",
{
description = S("Birch Sapling"),
_tt_help = S("Grows into a birch tree"),
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"default_sapling_birch.png"},
@ -519,6 +522,7 @@ minetest.register_node(
"default:leaves",
{
description = S("Leaves"),
_tt_help = S("Will decay if not near a tree"),
drawtype = "allfaces_optional",
visual_scale = 1.3,
tiles = {"default_leaves.png"},
@ -544,6 +548,7 @@ minetest.register_node(
"default:leaves_oak",
{
description = S("Oak Leaves"),
_tt_help = S("Will decay if not near a tree"),
drawtype = "allfaces_optional",
visual_scale = 1.3,
tiles = {"default_leaves_oak.png"},
@ -570,6 +575,7 @@ minetest.register_node( -- looks just like default oak leaves, except they decay
{
description = S("Oak Leaves (Huge)"),
drawtype = "allfaces_optional",
_tt_help = S("Will decay if not near a tree"),
visual_scale = 1.3,
tiles = {"default_leaves_oak.png"},
paramtype = "light",
@ -595,6 +601,7 @@ minetest.register_node(
"default:leaves_birch",
{
description = S("Birch Leaves"),
_tt_help = S("Will decay if not near a tree"),
drawtype = "allfaces_optional",
visual_scale = 1.3,
tiles = {"default_leaves_birch.png"},
@ -620,6 +627,7 @@ minetest.register_node(
"default:dry_leaves",
{
description = S("Dry Leaves"),
_tt_help = S("Will decay if not near a tree"),
drawtype = "allfaces_optional",
visual_scale = 1.3,
tiles = {"default_dry_leaves.png"},
@ -647,6 +655,10 @@ minetest.register_node(
"default:cactus",
{
description = S("Cactus"),
_tt_help = S("Grows on sand"),
_tt_food = true,
_tt_food_hp = 2,
_tt_food_satiation = 5,
drawtype = "nodebox",
paramtype = "light",
node_box = {
@ -679,6 +691,7 @@ minetest.register_node(
"default:rope",
{
description = S("Rope"),
_tt_help = S("Can be climbed"),
drawtype = "nodebox",
tiles = {"default_rope.png"},
inventory_image = "default_rope_inventory.png",
@ -705,6 +718,7 @@ minetest.register_node(
"default:papyrus",
{
description = S("Papyrus"),
_tt_help = S("Can be climbed") .. "\n" .. S("Grows on sand or dirt near water"),
drawtype = "nodebox",
tiles = {"default_papyrus.png"},
inventory_image = "default_papyrus_inventory.png",
@ -819,6 +833,7 @@ minetest.register_node(
"default:ladder",
{
description = S("Ladder"),
_tt_help = S("Can be climbed"),
drawtype = "nodebox",
tiles = {
"default_ladder_sides.png",
@ -940,6 +955,7 @@ minetest.register_node(
"default:flower",
{
description = S("Flower"),
_tt_help = S("It looks beautiful"),
drawtype = "nodebox",
node_box = {
type = "fixed",
@ -1069,6 +1085,7 @@ minetest.register_node(
"default:thistle",
{
description = S("Thistle"),
_tt_help = S("Careful, it stings!"),
drawtype = "plantlike",
selection_box = {
type = "fixed",
@ -1097,6 +1114,9 @@ minetest.register_node(
"default:apple",
{
description = S("Apple"),
_tt_food = true,
_tt_food_hp = 2,
_tt_food_satiation = 10,
drawtype = "nodebox",
visual_scale = 1.0,
tiles = {"default_apple_top.png", "default_apple_bottom.png", "default_apple_side.png"},
@ -1122,6 +1142,9 @@ minetest.register_node(
"default:clam",
{
description = S("Clam"),
_tt_food = true,
_tt_food_hp = 4,
_tt_food_satiation = 40,
drawtype = "nodebox",
tiles = {"default_clam.png"},
inventory_image = "default_clam_inventory.png",

View File

@ -6,6 +6,7 @@ minetest.register_node(
"default:sign",
{
description = S("Sign"),
_tt_help = S("Write a short message"),
drawtype = "nodebox",
tiles = {"default_sign.png"},
inventory_image = "default_sign_inventory.png",

View File

@ -224,6 +224,7 @@ minetest.register_tool(
"default:creative_tool",
{
description = S("Creative Tool"),
_tt_help = S("Dig everything you want!"),
inventory_image = "default_creative_tool.png",
tool_capabilities = {
full_punch_interval = 0.5,
@ -244,12 +245,19 @@ minetest.register_tool(
groups = { no_item_drop = 1 },
})
local tt_pick = S("Digs hard, cracky blocks")
local tt_shovel = S("Digs soft, crumbly blocks")
local tt_axe = S("Chops wood")
local tt_spear = S("Melee weapon")
local tt_shears = S("Cuts leaves and plants and shears sheep")
-- Pickaxes
minetest.register_tool(
"default:pick_wood",
{
description = S("Wooden Pickaxe"),
_tt_help = tt_pick,
inventory_image = "default_pick_wood.png",
tool_capabilities = {
max_drop_level=0,
@ -265,6 +273,7 @@ minetest.register_tool(
"default:pick_stone",
{
description = S("Stone Pickaxe"),
_tt_help = tt_pick,
inventory_image = "default_pick_stone.png",
tool_capabilities = {
max_drop_level = 0,
@ -281,6 +290,7 @@ minetest.register_tool(
"default:pick_wrought_iron",
{
description = S("Wrought Iron Pickaxe"),
_tt_help = tt_pick,
inventory_image = "default_pick_wrought_iron.png",
tool_capabilities = {
max_drop_level=1,
@ -297,6 +307,7 @@ minetest.register_tool(
"default:pick_steel",
{
description = S("Steel Pickaxe"),
_tt_help = tt_pick,
inventory_image = "default_pick_steel.png",
tool_capabilities = {
max_drop_level=1,
@ -313,6 +324,7 @@ minetest.register_tool(
"default:pick_carbon_steel",
{
description = S("Carbon Steel Pickaxe"),
_tt_help = tt_pick,
inventory_image = "default_pick_carbon_steel.png",
tool_capabilities = {
max_drop_level=1,
@ -329,6 +341,7 @@ minetest.register_tool(
"default:pick_bronze",
{
description = S("Bronze Pickaxe"),
_tt_help = tt_pick,
inventory_image = "default_pick_bronze.png",
tool_capabilities = {
max_drop_level=1,
@ -347,6 +360,7 @@ minetest.register_tool(
"default:shovel_wood",
{
description = S("Wooden Shovel"),
_tt_help = tt_shovel,
inventory_image = "default_shovel_wood.png",
tool_capabilities = {
max_drop_level=0,
@ -363,6 +377,7 @@ minetest.register_tool(
"default:shovel_stone",
{
description = S("Stone Shovel"),
_tt_help = tt_shovel,
inventory_image = "default_shovel_stone.png",
tool_capabilities = {
max_drop_level=0,
@ -379,6 +394,7 @@ minetest.register_tool(
"default:shovel_wrought_iron",
{
description = S("Wrought Iron Shovel"),
_tt_help = tt_shovel,
inventory_image = "default_shovel_wrought_iron.png",
tool_capabilities = {
max_drop_level=1,
@ -395,6 +411,7 @@ minetest.register_tool(
"default:shovel_steel",
{
description = S("Steel Shovel"),
_tt_help = tt_shovel,
inventory_image = "default_shovel_steel.png",
tool_capabilities = {
max_drop_level=1,
@ -411,6 +428,7 @@ minetest.register_tool(
"default:shovel_carbon_steel",
{
description = S("Carbon Steel Shovel"),
_tt_help = tt_shovel,
inventory_image = "default_shovel_carbon_steel.png",
tool_capabilities = {
max_drop_level=1,
@ -427,6 +445,7 @@ minetest.register_tool(
"default:shovel_bronze",
{
description = S("Bronze Shovel"),
_tt_help = tt_shovel,
inventory_image = "default_shovel_bronze.png",
tool_capabilities = {
max_drop_level=1,
@ -445,6 +464,7 @@ minetest.register_tool(
"default:axe_wood",
{
description = S("Wooden Axe"),
_tt_help = tt_axe,
inventory_image = "default_axe_wood.png",
tool_capabilities = {
max_drop_level=0,
@ -462,6 +482,7 @@ minetest.register_tool(
"default:axe_stone",
{
description = S("Stone Axe"),
_tt_help = tt_axe,
inventory_image = "default_axe_stone.png",
tool_capabilities = {
max_drop_level=0,
@ -479,6 +500,7 @@ minetest.register_tool(
"default:axe_wrought_iron",
{
description = S("Wrought Iron Axe"),
_tt_help = tt_axe,
inventory_image = "default_axe_wrought_iron.png",
tool_capabilities = {
max_drop_level=1,
@ -496,6 +518,7 @@ minetest.register_tool(
"default:axe_steel",
{
description = S("Steel Axe"),
_tt_help = tt_axe,
inventory_image = "default_axe_steel.png",
tool_capabilities = {
max_drop_level=1,
@ -513,6 +536,7 @@ minetest.register_tool(
"default:axe_carbon_steel",
{
description = S("Carbon Steel Axe"),
_tt_help = tt_axe,
inventory_image = "default_axe_carbon_steel.png",
tool_capabilities = {
max_drop_level=1,
@ -530,6 +554,7 @@ minetest.register_tool(
"default:axe_bronze",
{
description = S("Bronze Axe"),
_tt_help = tt_axe,
inventory_image = "default_axe_bronze.png",
tool_capabilities = {
max_drop_level=1,
@ -549,6 +574,7 @@ minetest.register_tool(
"default:spear_wood",
{
description = S("Wooden Spear"),
_tt_help = tt_spear,
inventory_image = "default_spear_wood.png",
wield_image = "default_spear_wood.png^[transformR90",
tool_capabilities = {
@ -567,6 +593,7 @@ minetest.register_tool(
"default:spear_stone",
{
description = S("Stone Spear"),
_tt_help = tt_spear,
inventory_image = "default_spear_stone.png",
wield_image = "default_spear_stone.png^[transformR90",
tool_capabilities = {
@ -585,6 +612,7 @@ minetest.register_tool(
"default:spear_wrought_iron",
{
description = S("Wrought Iron Spear"),
_tt_help = tt_spear,
inventory_image = "default_spear_wrought_iron.png",
wield_image = "default_spear_wrought_iron.png^[transformR90",
tool_capabilities = {
@ -603,6 +631,7 @@ minetest.register_tool(
"default:spear_steel",
{
description = S("Steel Spear"),
_tt_help = tt_spear,
inventory_image = "default_spear_steel.png",
wield_image = "default_spear_steel.png^[transformR90",
tool_capabilities = {
@ -621,6 +650,7 @@ minetest.register_tool(
"default:spear_carbon_steel",
{
description = S("Carbon Steel Spear"),
_tt_help = tt_spear,
inventory_image = "default_spear_carbon_steel.png",
wield_image = "default_spear_carbon_steel.png^[transformR90",
tool_capabilities = {
@ -639,6 +669,7 @@ minetest.register_tool(
"default:spear_bronze",
{
description = S("Bronze Spear"),
_tt_help = tt_spear,
inventory_image = "default_spear_bronze.png",
wield_image = "default_spear_bronze.png^[transformR90",
tool_capabilities = {
@ -659,6 +690,7 @@ minetest.register_tool(
"default:broadsword",
{
description = S("Broadsword"),
_tt_help = S("A mighty melee weapon"),
inventory_image = "default_broadsword.png",
wield_image = "default_broadsword.png",
wield_scale = {x = 2.0, y = 2.0, z = 1.0},
@ -692,6 +724,7 @@ minetest.register_tool(
"default:shears",
{
description = S("Wrought Iron Shears"),
_tt_help = tt_shears,
inventory_image = "default_shears.png",
wield_image = "default_shears.png^[transformR90",
sound = { breaks = "default_tool_breaks" },
@ -709,6 +742,7 @@ minetest.register_tool(
"default:shears_steel",
{
description = S("Steel Shears"),
_tt_help = tt_shears,
inventory_image = "default_shears_steel.png",
wield_image = "default_shears_steel.png^[transformR90",
sound = { breaks = "default_tool_breaks" },
@ -726,6 +760,7 @@ minetest.register_tool(
"default:shears_carbon_steel",
{
description = S("Carbon Steel Shears"),
_tt_help = tt_shears,
inventory_image = "default_shears_carbon_steel.png",
wield_image = "default_shears_carbon_steel.png^[transformR90",
sound = { breaks = "default_tool_breaks" },
@ -743,6 +778,7 @@ minetest.register_tool(
"default:shears_bronze",
{
description = S("Bronze Shears"),
_tt_help = tt_shears,
inventory_image = "default_shears_bronze.png",
wield_image = "default_shears_bronze.png^[transformR90",
sound = { breaks = "default_tool_breaks" },
@ -757,10 +793,18 @@ minetest.register_tool(
on_place = trim,
})
local tt_flint_and_steel
if minetest.settings:get_bool("tnt_enable", true) then
tt_flint_and_steel = S("Ingnites TNT and lights up torches")
else
tt_flint_and_steel = S("Lights up torches")
end
minetest.register_tool(
"default:flint_and_steel",
{
description = S("Flint and Steel"),
_tt_help = tt_flint_and_steel,
inventory_image = "default_flint_and_steel.png",
sound = { breaks = "default_tool_breaks" },
on_use = function(itemstack, user, pointed_thing)

View File

@ -4,11 +4,12 @@ local S = minetest.get_translator("default")
local function register_torch(subname, description, tiles, overlay_tiles, overlay_side_R90, inv_image, light)
local function register_torch(subname, description, tt_help, tiles, overlay_tiles, overlay_side_R90, inv_image, light)
minetest.register_node(
"default:"..subname,
{
description = description,
_tt_help = tt_help,
drawtype = "nodebox",
tiles = tiles,
overlay_tiles = overlay_tiles,
@ -167,9 +168,9 @@ local overlay_tiles_normal = {
local overlayR90_weak = "default_torch_weak_overlayR90.png"
local overlayR90_normal = "default_torch_overlayR90.png"
register_torch("torch_dead", S("Dead Torch"), {"default_torch_ends.png","default_torch_ends.png","default_torch_base.png"}, nil, nil, "default_torch_dead_inventory.png")
register_torch("torch_weak", S("Weak Torch"), {"default_torch_ends.png","default_torch_ends.png","default_torch_base.png"}, overlay_tiles_weak, overlayR90_weak, "default_torch_weak_inventory.png", default.LIGHT_MAX-4)
register_torch("torch", S("Torch"), {"default_torch_ends.png","default_torch_ends.png","default_torch_base.png"}, overlay_tiles_normal, overlayR90_normal, "default_torch_inventory.png", default.LIGHT_MAX-1)
register_torch("torch_dead", S("Dead Torch"), S("Doesn't provide any light"), {"default_torch_ends.png","default_torch_ends.png","default_torch_base.png"}, nil, nil, "default_torch_dead_inventory.png")
register_torch("torch_weak", S("Weak Torch"), S("Provides a bit of light but it will eventually burn out"), {"default_torch_ends.png","default_torch_ends.png","default_torch_base.png"}, overlay_tiles_weak, overlayR90_weak, "default_torch_weak_inventory.png", default.LIGHT_MAX-4)
register_torch("torch", S("Torch"), S("It's bright and burns forever"), {"default_torch_ends.png","default_torch_ends.png","default_torch_base.png"}, overlay_tiles_normal, overlayR90_normal, "default_torch_inventory.png", default.LIGHT_MAX-1)
minetest.register_lbm({
label = "Upgrade wall torches",

View File

@ -30,6 +30,9 @@ minetest.register_craftitem(
"farming:bread",
{
description = S("Bread"),
_tt_food = true,
_tt_food_hp = 4,
_tt_food_satiation = 40,
inventory_image = "farming_bread.png",
groups = { food = 2 },
on_use = minetest.item_eat({hp = 4, sat = 40})

View File

@ -7,6 +7,7 @@ minetest.register_node(
"farming:wheat_1",
{
description = S("Wheat Seed"),
_tt_help = S("Grows on dirt and swamp dirt. It likes water"),
drawtype = "plantlike",
tiles = {"farming_wheat_1.png"},
inventory_image = "farming_wheat_seed.png",
@ -119,6 +120,7 @@ minetest.register_node(
"farming:cotton_1",
{
description = S("Cotton Seed"),
_tt_help = S("Grows on dirt, swamp dirt, dry dirt and sand. It likes water"),
drawtype = "plantlike",
tiles = {"farming_cotton_1.png"},
inventory_image = "farming_cotton_seed.png",

View File

@ -277,6 +277,7 @@ minetest.register_craftitem(
"gold:trading_book",
{
description = S("Trading Book"),
_tt_help = S("Show this to a villager to start trading"),
inventory_image = "default_book.png^gold_bookribbon.png",
stack_max = 1,
})

View File

@ -132,6 +132,8 @@ function jewels.register_jewel(toolname, new_toolname, def)
new_tooldef.inventory_image = new_tool_invimage
new_tooldef.wield_image = new_tool_wieldimage
-- TODO: Add support for tt mod
new_tooldef._tt_ignore = true
if data.stats.range then
if not new_tooldef.range then
@ -256,6 +258,7 @@ minetest.register_node(
"jewels:bench",
{
description = S("Jeweler's Workbench"),
_tt_help = S("Improves your tools with jewels"),
tiles ={"jewels_bench_top.png", "jewels_bench_bottom.png", "jewels_bench_sides.png"},
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},

View File

@ -52,6 +52,7 @@ minetest.register_tool(
"locks:pick",
{
description = S("Lock Pick"),
_tt_help = S("It helps you crack locked chests"),
inventory_image = "locks_pick.png",
wield_image = "locks_pick.png",
@ -135,6 +136,7 @@ minetest.register_craftitem(
"locks:lock",
{
description = S("Lock"),
_tt_help = S("Used to craft locked chests"),
inventory_image = "locks_lock.png",
wield_image = "locks_lock.png",
@ -144,6 +146,7 @@ minetest.register_node(
"locks:chest",
{
description = S("Locked Chest"),
_tt_help = S("Provides 32 inventory slots") .. "\n" .. S("Can only be opened by owner, or if you have a lockpick"),
tiles ={
"default_chest_top.png",
"default_chest_top.png",

View File

@ -62,6 +62,7 @@ minetest.register_node(
"lumien:crystal_on",
{
description = S("Glowing Lumien Crystal"),
_tt_help = S("It glows"),
inventory_image = "lumien_crystal_on.png",
tiles = {"lumien_block.png"},
paramtype = "light",
@ -85,6 +86,7 @@ minetest.register_node(
"lumien:crystal_off",
{
description = S("Lumien Crystal"),
_tt_help = S("Glows when someone is close"),
inventory_image = "lumien_crystal.png",
tiles = {"lumien_block.png"},
paramtype = "light",
@ -107,6 +109,7 @@ minetest.register_node(
"lumien:block",
{
description = S("Lumien Block"),
_tt_help = S("It shines so bright"),
tiles = {"lumien_block.png"},
groups = {cracky = 1},
light_source = 14,

View File

@ -22,6 +22,9 @@ minetest.register_craftitem(
"mobs:meat_raw",
{
description = S("Raw Meat"),
_tt_food = true,
_tt_food_hp = 3,
_tt_food_satiation = 30,
inventory_image = "mobs_meat_raw.png",
groups = { food = 2 },
on_use = minetest.item_eat({hp = 3, sat = 30}),
@ -33,6 +36,9 @@ minetest.register_craftitem(
"mobs:meat",
{
description = S("Cooked Meat"),
_tt_food = true,
_tt_food_hp = 7,
_tt_food_satiation = 70,
inventory_image = "mobs_meat_cooked.png",
groups = { food = 2 },
on_use = minetest.item_eat({hp = 7, sat = 70}),
@ -51,7 +57,8 @@ minetest.register_craft(
minetest.register_tool(
"mobs:net",
{
description = S("Net").."\n"..S("(Right-click to capture)"),
description = S("Net"),
_tt_help = S("Good for capturing small animals"),
inventory_image = "mobs_net.png",
})
@ -69,7 +76,8 @@ crafting.register_craft(
minetest.register_tool(
"mobs:lasso",
{
description = S("Lasso").."\n"..S("(Right-click to capture)"),
description = S("Lasso"),
_tt_help = S("Good for capturing large animals"),
inventory_image = "mobs_lasso.png",
})

View File

@ -78,6 +78,9 @@ minetest.register_craftitem(
"mobs:pork_raw",
{
description = S("Raw Porkchop"),
_tt_food = true,
_tt_food_hp = 4,
_tt_food_satiation = 30,
inventory_image = "mobs_pork_raw.png",
groups = { food = 2 },
on_use = minetest.item_eat({hp = 4, sat = 30}),
@ -89,6 +92,9 @@ minetest.register_craftitem(
"mobs:pork",
{
description = S("Cooked Porkchop"),
_tt_food = true,
_tt_food_hp = 8,
_tt_food_satiation = 50,
inventory_image = "mobs_pork_cooked.png",
groups = { food = 2 },
on_use = minetest.item_eat({hp = 8, sat = 50}),

View File

@ -106,6 +106,7 @@ if minetest.settings:get_bool("music_enable") then
"music:player",
{
description = S("Music Player"),
_tt_help = S("Play those funky tunes!"),
tiles = {"music_top.png", "music_bottom.png", "music_side.png"},
@ -177,6 +178,7 @@ else
"music:player",
{
description = S("Music Player"),
_tt_help = S("Play those funky tunes!"),
tiles = {"music_top.png", "music_bottom.png", "music_side.png"},

View File

@ -39,10 +39,14 @@ minetest.register_globalstep(on_globalstep)
-- Items
local d = S("Compass")
local t = S("It points to the North")
minetest.register_craftitem(
"nav:compass_0",
{
description = S("Compass"),
description = d,
_tt_help = t,
inventory_image = "nav_compass_inventory_0.png",
wield_image = wield_image_0,
@ -54,7 +58,8 @@ minetest.register_craftitem(
minetest.register_craftitem(
"nav:compass_1",
{
description = S("Compass"),
description = d,
_tt_help = t,
inventory_image = "nav_compass_inventory_1.png",
wield_image = wield_image_1,
@ -66,7 +71,8 @@ minetest.register_craftitem(
minetest.register_craftitem(
"nav:compass_2",
{
description = S("Compass"),
description = d,
_tt_help = t,
inventory_image = "nav_compass_inventory_0.png^[transformR270",
wield_image = wield_image_0 .. "^[transformR270",
@ -78,7 +84,8 @@ minetest.register_craftitem(
minetest.register_craftitem(
"nav:compass_3",
{
description = S("Compass"),
description = d,
_tt_help = t,
inventory_image = "nav_compass_inventory_1.png^[transformR270",
wield_image = wield_image_1 .. "^[transformR270",
@ -91,7 +98,8 @@ minetest.register_craftitem(
minetest.register_craftitem(
"nav:compass_4",
{
description = S("Compass"),
description = d,
_tt_help = t,
inventory_image = "nav_compass_inventory_0.png^[transformR180",
wield_image = wield_image_0 .. "^[transformR180",
@ -103,7 +111,8 @@ minetest.register_craftitem(
minetest.register_craftitem(
"nav:compass_5",
{
description = S("Compass"),
description = d,
_tt_help = t,
inventory_image = "nav_compass_inventory_1.png^[transformR180",
wield_image = wield_image_1 .. "^[transformR180",
@ -115,7 +124,8 @@ minetest.register_craftitem(
minetest.register_craftitem(
"nav:compass_6",
{
description = S("Compass"),
description = d,
_tt_help = t,
inventory_image = "nav_compass_inventory_0.png^[transformR90",
wield_image = wield_image_0 .. "^[transformR90",
@ -127,7 +137,8 @@ minetest.register_craftitem(
minetest.register_craftitem(
"nav:compass_7",
{
description = S("Compass"),
description = d,
_tt_help = t,
inventory_image = "nav_compass_inventory_1.png^[transformR90",
wield_image = wield_image_1 .. "^[transformR90",

View File

@ -75,6 +75,7 @@ minetest.register_craftitem(
"nav:map",
{
description = S("Map"),
_tt_help = S("Carry this item and view the map with the 'minimap' key"),
inventory_image = "nav_inventory.png",
wield_image = "nav_inventory.png",
stack_max = 1,

View File

@ -20,6 +20,7 @@ end
minetest.register_craftitem(
"parachute:parachute", {
description = S("Parachute"),
_tt_help = S("Lets you glide safely to the ground when falling"),
inventory_image = "parachute_inventory.png",
wield_image = "parachute_inventory.png",
stack_max = 1,

View File

@ -242,19 +242,22 @@ minetest.register_on_mods_loaded(on_load)
-- Nodes
local top_tex, desc
local top_tex, desc, tt
if tnt_enable then
top_tex = "tnt_top.png"
desc = S("TNT")
tt = S("Will explode when ignited by flint and steel")
else
top_tex = "tnt_top_disabled.png"
desc = S("TNT (defused)")
tt = S("It's harmless")
end
minetest.register_node(
"tnt:tnt",
{
description = desc,
_tt_help = tt,
tiles = {top_tex, "tnt_bottom.png", "tnt_sides.png"},
is_ground_content = false,
groups = {handy = 2},

29
mods/tt/API.md Normal file
View File

@ -0,0 +1,29 @@
# Tooltip API
This API explains how to handle the extended item tooltips (`description` field).
## Fields
Add these to the item definition.
* `_tt_ignore`: If `true`, the `description` of this item won't be altered at all
* `_tt_help`: Custom help text
* `_tt_food`: If `true`, item is a food item that can be consumed by the player
* `_tt_food_hp`: Health increase (in HP) for player when consuming food item
* `_tt_food_satiation`: Satiation increase for player when consuming food item (note: the meaning of satiation is depending on the game being used; some games might not have a satiation mechanic at all, in which case you can skip this field)
Once this mod had overwritten the `description` field of an item was overwritten, it will save the original (unaltered) `description` in the `_tt_original_description` field.
## `tt.register_snippet(func)`
Register a custom snippet function.
`func` is a function of the form `func(itemstring)`. It will be called for (nearly) every itemstring and it must return a string you want to append to this item or `nil` if nothing shall be appended.
Example:
```
tt.register_snippet(function(itemstring)
if minetest.get_item_group(itemstring, "magic") == 1 then
return "This item is magic"
end
end)
```

11
mods/tt/README.md Normal file
View File

@ -0,0 +1,11 @@
# Extended Tooltip (`tt`)
This mod extends the tooltip of items to add more informative texts.
Features:
* Weapon damage and speed
* Tool information
* Food satiation
* Custom help text (added by mods) (example:
## License
MIT License.

76
mods/tt/init.lua Normal file
View File

@ -0,0 +1,76 @@
local S = minetest.get_translator("tt")
local color = "#d0ffd0"
tt = {}
tt.registered_snippets = {}
local function append_descs()
for itemstring, def in pairs(minetest.registered_items) do
if itemstring ~= "" and itemstring ~= "air" and itemstring ~= "ignore" and itemstring ~= "unknown" and def ~= nil and def.description ~= nil and def._tt_ignore ~= true then
local desc = def.description
local orig_desc = desc
-- Custom text
if def._tt_help then
desc = desc .. "\n" .. minetest.colorize(color, def._tt_help)
end
if def.tool_capabilities then
-- Digging stats
if def.tool_capabilities.groupcaps then
-- TODO: Add more detail (such as digging speed)
--local groups = {}
--for group, caps in pairs(def.tool_capabilities.groupcaps) do
-- table.insert(groups, group)
--end
--desc = desc .. "\n" .. minetest.colorize(color, S("Digs: @1", table.concat(groups, ", ")))
end
-- Weapon stats
if def.tool_capabilities.damage_groups then
for group, damage in pairs(def.tool_capabilities.damage_groups) do
if group == "fleshy" then
desc = desc .. "\n" .. minetest.colorize(color, S("Damage: @1", damage))
else
desc = desc .. "\n" .. minetest.colorize(color, S("Damage (@1): @2", group, damage))
end
end
local full_punch_interval = def.tool_capabilities.full_punch_interval
if not full_punch_interval then
full_punch_interval = 1
end
desc = desc .. "\n" .. minetest.colorize(color, S("Full punch interval: @1s", full_punch_interval))
end
end
-- Food
if def._tt_food then
desc = desc .. "\n" .. minetest.colorize(color, S("Food item"))
if def._tt_food_hp then
msg = S("+@1 food points", def._tt_food_hp)
desc = desc .. "\n" .. minetest.colorize(color, msg)
end
-- NOTE: This is unused atm
--[[if def._tt_food_satiation then
if def._tt_food_satiation >= 0 then
msg = S("+@1 satiation", def._tt_food_satiation)
else
msg = S("@1 satiation", def._tt_food_satiation)
end
desc = desc .. "\n" .. minetest.colorize(color, msg)
end]]
end
-- Custom functions
for s=1, #tt.registered_snippets do
local str = tt.registered_snippets[s](itemstring)
if str then
desc = desc .. "\n" .. minetest.colorize(color, str)
end
end
minetest.override_item(itemstring, { description = desc, _tt_original_description = orig_desc })
end
end
end
tt.register_snippet = function(func)
table.insert(tt.registered_snippets, func)
end
minetest.register_on_mods_loaded(append_descs)

View File

@ -0,0 +1,8 @@
# textdomain:tt
Damage: @1=
Damage (@1): @2=
Full punch interval: @1s=
Food item=
+@1 satiation=
@1 satiation=
+@1 food points=

8
mods/tt/locale/tt.de.tr Normal file
View File

@ -0,0 +1,8 @@
# textdomain:tt
Damage: @1=Schaden: @1
Damage (@1): @2=Schaden (@1): @2
Full punch interval: @1s=Zeit zum Ausholen: @1s
Food item=Lebensmittel
+@1 satiation=+@1 Sättigung
@1 satiation=@1 Sättigung
+@1 food points=+@1 Nahrungspunkte

2
mods/tt/mod.conf Normal file
View File

@ -0,0 +1,2 @@
name = tt
description = Appends a helpful tooltip to the item description

View File

@ -33,6 +33,7 @@ minetest.register_node(
"village:entity_spawner",
{
description = S("Village Entity Spawner"),
_tt_help = S("Placeholder that marks a position at which to spawn an entity during village generation"),
drawtype = "airlike",
pointable = false,
inventory_image = "village_entity.png",
@ -79,6 +80,7 @@ minetest.register_node(
"village:grassland_village",
{
description = S("Village Spawner"),
_tt_help = S("Generates a village when placed"),
tiles = {
"village_gen.png", "village_gen.png", "village_gen.png",
"village_gen.png", "village_gen.png^[transformFX", "village_gen.png^[transformFX",