From c19a8526676e7ff388ab117fb185379f5318f50d Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 5 Dec 2019 10:30:46 +0100 Subject: [PATCH] Add extended item tooltips --- mods/armor/init.lua | 9 +++++ mods/bed/init.lua | 1 + mods/book/init.lua | 1 + mods/default/bucket.lua | 8 ++-- mods/default/container.lua | 2 + mods/default/fertilizer.lua | 5 +++ mods/default/furnace.lua | 3 +- mods/default/nodes.lua | 23 +++++++++++ mods/default/sign.lua | 1 + mods/default/tools.lua | 44 +++++++++++++++++++++ mods/default/torch.lua | 9 +++-- mods/farming/craft.lua | 3 ++ mods/farming/nodes.lua | 2 + mods/gold/init.lua | 1 + mods/jewels/init.lua | 3 ++ mods/locks/init.lua | 3 ++ mods/lumien/init.lua | 3 ++ mods/mobs/crafts.lua | 12 +++++- mods/mobs/mob_boar.lua | 6 +++ mods/music/init.lua | 2 + mods/nav/compass.lua | 27 +++++++++---- mods/nav/map.lua | 1 + mods/parachute/init.lua | 1 + mods/tnt/init.lua | 5 ++- mods/tt/API.md | 29 ++++++++++++++ mods/tt/README.md | 11 ++++++ mods/tt/init.lua | 76 +++++++++++++++++++++++++++++++++++++ mods/tt/locale/template.txt | 8 ++++ mods/tt/locale/tt.de.tr | 8 ++++ mods/tt/mod.conf | 2 + mods/village/mapgen.lua | 2 + 31 files changed, 292 insertions(+), 19 deletions(-) create mode 100644 mods/tt/API.md create mode 100644 mods/tt/README.md create mode 100644 mods/tt/init.lua create mode 100644 mods/tt/locale/template.txt create mode 100644 mods/tt/locale/tt.de.tr create mode 100644 mods/tt/mod.conf diff --git a/mods/armor/init.lua b/mods/armor/init.lua index 766edce..d1ca27a 100644 --- a/mods/armor/init.lua +++ b/mods/armor/init.lua @@ -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") diff --git a/mods/bed/init.lua b/mods/bed/init.lua index 98e4d2b..9d3241f 100644 --- a/mods/bed/init.lua +++ b/mods/bed/init.lua @@ -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", diff --git a/mods/book/init.lua b/mods/book/init.lua index be6d479..0e4a161 100644 --- a/mods/book/init.lua +++ b/mods/book/init.lua @@ -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, diff --git a/mods/default/bucket.lua b/mods/default/bucket.lua index 0889a02..606883d 100644 --- a/mods/default/bucket.lua +++ b/mods/default/bucket.lua @@ -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}, diff --git a/mods/default/container.lua b/mods/default/container.lua index 7765079..26da495 100644 --- a/mods/default/container.lua +++ b/mods/default/container.lua @@ -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}, diff --git a/mods/default/fertilizer.lua b/mods/default/fertilizer.lua index 3d03abb..047d8bc 100644 --- a/mods/default/fertilizer.lua +++ b/mods/default/fertilizer.lua @@ -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) diff --git a/mods/default/furnace.lua b/mods/default/furnace.lua index 674e67a..a7429ce 100644 --- a/mods/default/furnace.lua +++ b/mods/default/furnace.lua @@ -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", diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index 24d7e21..9adcee2 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -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", diff --git a/mods/default/sign.lua b/mods/default/sign.lua index dce5e4f..b678bc6 100644 --- a/mods/default/sign.lua +++ b/mods/default/sign.lua @@ -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", diff --git a/mods/default/tools.lua b/mods/default/tools.lua index 68e73fa..33806f1 100644 --- a/mods/default/tools.lua +++ b/mods/default/tools.lua @@ -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) diff --git a/mods/default/torch.lua b/mods/default/torch.lua index 3897661..215ed25 100644 --- a/mods/default/torch.lua +++ b/mods/default/torch.lua @@ -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", diff --git a/mods/farming/craft.lua b/mods/farming/craft.lua index 6e2fd45..39a4ef4 100644 --- a/mods/farming/craft.lua +++ b/mods/farming/craft.lua @@ -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}) diff --git a/mods/farming/nodes.lua b/mods/farming/nodes.lua index fb776b0..abbbb81 100644 --- a/mods/farming/nodes.lua +++ b/mods/farming/nodes.lua @@ -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", diff --git a/mods/gold/init.lua b/mods/gold/init.lua index c7de913..624a4e8 100644 --- a/mods/gold/init.lua +++ b/mods/gold/init.lua @@ -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, }) diff --git a/mods/jewels/init.lua b/mods/jewels/init.lua index b900c0a..dc68bc8 100644 --- a/mods/jewels/init.lua +++ b/mods/jewels/init.lua @@ -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}, diff --git a/mods/locks/init.lua b/mods/locks/init.lua index d2da6f8..04ae013 100644 --- a/mods/locks/init.lua +++ b/mods/locks/init.lua @@ -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", diff --git a/mods/lumien/init.lua b/mods/lumien/init.lua index e1bfd35..53d0552 100644 --- a/mods/lumien/init.lua +++ b/mods/lumien/init.lua @@ -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, diff --git a/mods/mobs/crafts.lua b/mods/mobs/crafts.lua index 32bd893..7f705c6 100644 --- a/mods/mobs/crafts.lua +++ b/mods/mobs/crafts.lua @@ -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", }) diff --git a/mods/mobs/mob_boar.lua b/mods/mobs/mob_boar.lua index 41b27bd..4f9f87a 100644 --- a/mods/mobs/mob_boar.lua +++ b/mods/mobs/mob_boar.lua @@ -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}), diff --git a/mods/music/init.lua b/mods/music/init.lua index 0599528..17c3076 100644 --- a/mods/music/init.lua +++ b/mods/music/init.lua @@ -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"}, diff --git a/mods/nav/compass.lua b/mods/nav/compass.lua index 4d88b14..32c9dc7 100644 --- a/mods/nav/compass.lua +++ b/mods/nav/compass.lua @@ -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", diff --git a/mods/nav/map.lua b/mods/nav/map.lua index 0afc604..6e58e17 100644 --- a/mods/nav/map.lua +++ b/mods/nav/map.lua @@ -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, diff --git a/mods/parachute/init.lua b/mods/parachute/init.lua index 91b2097..8381ff6 100644 --- a/mods/parachute/init.lua +++ b/mods/parachute/init.lua @@ -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, diff --git a/mods/tnt/init.lua b/mods/tnt/init.lua index 6c8a2c1..46ceeb2 100644 --- a/mods/tnt/init.lua +++ b/mods/tnt/init.lua @@ -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}, diff --git a/mods/tt/API.md b/mods/tt/API.md new file mode 100644 index 0000000..9461c1f --- /dev/null +++ b/mods/tt/API.md @@ -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) +``` diff --git a/mods/tt/README.md b/mods/tt/README.md new file mode 100644 index 0000000..cdf4111 --- /dev/null +++ b/mods/tt/README.md @@ -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. diff --git a/mods/tt/init.lua b/mods/tt/init.lua new file mode 100644 index 0000000..576ecca --- /dev/null +++ b/mods/tt/init.lua @@ -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) diff --git a/mods/tt/locale/template.txt b/mods/tt/locale/template.txt new file mode 100644 index 0000000..882d81f --- /dev/null +++ b/mods/tt/locale/template.txt @@ -0,0 +1,8 @@ +# textdomain:tt +Damage: @1= +Damage (@1): @2= +Full punch interval: @1s= +Food item= ++@1 satiation= +@1 satiation= ++@1 food points= diff --git a/mods/tt/locale/tt.de.tr b/mods/tt/locale/tt.de.tr new file mode 100644 index 0000000..a6328e9 --- /dev/null +++ b/mods/tt/locale/tt.de.tr @@ -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 diff --git a/mods/tt/mod.conf b/mods/tt/mod.conf new file mode 100644 index 0000000..aee1572 --- /dev/null +++ b/mods/tt/mod.conf @@ -0,0 +1,2 @@ +name = tt +description = Appends a helpful tooltip to the item description diff --git a/mods/village/mapgen.lua b/mods/village/mapgen.lua index 6faf568..1705b85 100644 --- a/mods/village/mapgen.lua +++ b/mods/village/mapgen.lua @@ -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",