From c5437a4b3d13ec9e66564874b02e078a817c6255 Mon Sep 17 00:00:00 2001 From: Crabman77 Date: Sun, 24 Jul 2022 03:59:18 +0200 Subject: [PATCH 1/2] translate many nalc_* mods and use function to register toolranks --- nalc_awards/init.lua | 32 +++++++++-------- nalc_awards/locale/nalc_awards.fr.tr | 16 +++++++++ nalc_awards/locale/template.txt | 18 ++++++++++ nalc_beds/init.lua | 6 ++-- nalc_beds/locale/nalc_beds.fr.tr | 8 +++++ nalc_beds/locale/template.txt | 10 ++++++ nalc_boats/init.lua | 11 +++--- nalc_boats/locale/nalc_boats.fr.tr | 7 ++++ nalc_boats/locale/template.txt | 7 ++++ nalc_bucket/init.lua | 6 ++-- nalc_bucket/locale/nalc_bucket.fr.tr | 4 +++ nalc_bucket/locale/template.txt | 4 +++ nalc_default/fences.lua | 10 +++--- nalc_default/init.lua | 4 +++ nalc_default/locale/nalc_default.fr.tr | 31 ++++++++++++++++ nalc_default/locale/template.txt | 31 ++++++++++++++++ nalc_default/nodes.lua | 24 +++++++------ nalc_default/tools.lua | 36 ++++++------------- nalc_doors/init.lua | 26 +++++++------- nalc_doors/locale/nalc_doors.fr.tr | 15 ++++++++ nalc_doors/locale/template.txt | 15 ++++++++ nalc_flowers/init.lua | 6 ++-- nalc_flowers/locale/nalc_flowers.fr.tr | 4 +++ nalc_flowers/locale/template.txt | 4 +++ nalc_mediterranean/init.lua | 18 +++++----- .../locale/nalc_mediterranean.fr.tr | 10 ++++++ nalc_mediterranean/locale/template.txt | 10 ++++++ nalc_mobs/init.lua | 14 +++----- nalc_mobs/locale/nalc_mobs.fr.tr | 4 +++ nalc_mobs/locale/template.txt | 4 +++ nalc_moognu/init.lua | 35 ++++++------------ nalc_moognu/locale/nalc_moognu.fr.tr | 6 ++++ nalc_moognu/locale/template.txt | 6 ++++ 33 files changed, 321 insertions(+), 121 deletions(-) create mode 100644 nalc_awards/locale/nalc_awards.fr.tr create mode 100644 nalc_awards/locale/template.txt create mode 100644 nalc_beds/locale/nalc_beds.fr.tr create mode 100644 nalc_beds/locale/template.txt create mode 100644 nalc_boats/locale/nalc_boats.fr.tr create mode 100644 nalc_boats/locale/template.txt create mode 100644 nalc_bucket/locale/nalc_bucket.fr.tr create mode 100644 nalc_bucket/locale/template.txt create mode 100644 nalc_default/locale/nalc_default.fr.tr create mode 100644 nalc_default/locale/template.txt create mode 100644 nalc_doors/locale/nalc_doors.fr.tr create mode 100644 nalc_doors/locale/template.txt create mode 100644 nalc_flowers/locale/nalc_flowers.fr.tr create mode 100644 nalc_flowers/locale/template.txt create mode 100644 nalc_mediterranean/locale/nalc_mediterranean.fr.tr create mode 100644 nalc_mediterranean/locale/template.txt create mode 100644 nalc_mobs/locale/nalc_mobs.fr.tr create mode 100644 nalc_mobs/locale/template.txt create mode 100644 nalc_moognu/locale/nalc_moognu.fr.tr create mode 100644 nalc_moognu/locale/template.txt diff --git a/nalc_awards/init.lua b/nalc_awards/init.lua index ff0fd76..e06dc18 100644 --- a/nalc_awards/init.lua +++ b/nalc_awards/init.lua @@ -13,6 +13,8 @@ *award_gold_master (Gold Master - dig 1000 default:stone_with_gold)--> 1 Super Quarry ]]-- +local S = minetest.get_translator("nalc_awards") + if minetest.get_modpath("awards") then -- Check if a player object is valid for awards. @@ -22,20 +24,20 @@ if minetest.get_modpath("awards") then -- Redéfinition de la description d'awards existant local award = awards.registered_awards["award_mine3"] - award.description = award.description.." (Unlock the craft of 1 Quarry)" + award.description = award.description.. S(" (Unlock the craft of 1 Quarry)") award = awards.registered_awards["award_mine4"] - award.description = award.description.." (Unlock the craft of 1 Super Quarry)" + award.description = award.description.. S(" (Unlock the craft of 1 Super Quarry)") award = awards.registered_awards["award_youre_a_copper"] - award.description = award.description.." (Unlock the craft of 1 Super Quarry)" + award.description = award.description.. S(" (Unlock the craft of 1 Super Quarry)") -- Définitions de nouveaux awards -- -- Iron Lady awards.register_award( "award_iron_miner", { - title = "The Iron Lady", - description = "Dig 100 iron ores. (Unlock the craft of 2 Quarry)", + title = S("The Iron Lady"), + description = S("Dig 100 iron ores. (Unlock the craft of 2 Quarry)"), icon = "default_iron_lump.png^awards_level1.png", background = "awards_bg_mining.png", difficulty = 0.03, @@ -49,8 +51,8 @@ if minetest.get_modpath("awards") then -- Iron Man awards.register_award( "award_iron_master", { - title = "The Iron Man", - description = "Dig 1,000 iron ores. (Unlock the craft of 1 Super Quarry)", + title = S("The Iron Man"), + description = S("Dig 1,000 iron ores. (Unlock the craft of 1 Super Quarry)"), icon = "default_iron_lump.png^awards_level2.png", background = "awards_bg_mining.png", difficulty = 0.04, @@ -64,8 +66,8 @@ if minetest.get_modpath("awards") then -- Copper Trooper awards.register_award( "award_copper_miner", { - title = "Copper Trooper", - description = "Dig 100 copper ores. (Unlock the craft of 4 Quarry)", + title = S("Copper Trooper"), + description = S("Dig 100 copper ores. (Unlock the craft of 4 Quarry)"), icon = "default_copper_lump.png^awards_level1.png", background = "awards_bg_mining.png", difficulty = 0.19, @@ -79,8 +81,8 @@ if minetest.get_modpath("awards") then -- Gold Digger awards.register_award( "award_gold_miner", { - title = "Gold Digger", - description = "Dig 100 gold ores. (Unlock the craft of 5 Quarry)", + title = S("Gold Digger"), + description = S("Dig 100 gold ores. (Unlock the craft of 5 Quarry)"), icon = "default_gold_lump.png^awards_level3.png", background = "awards_bg_mining.png", difficulty = 0.91, @@ -94,8 +96,8 @@ if minetest.get_modpath("awards") then -- The Golden Age awards.register_award( "award_gold_master", { - title = "The Golden Age", - description = "Dig 1,000 gold ores. (Unlock the craft of 1 Super Quarry)", + title = S("The Golden Age"), + description = S("Dig 1,000 gold ores. (Unlock the craft of 1 Super Quarry)"), icon = "default_gold_lump.png^awards_level4.png", background = "awards_bg_mining.png", difficulty = 0.92, @@ -110,7 +112,7 @@ if minetest.get_modpath("awards") then minetest.register_node( ":nalc:waste", { - description = "Waste", + description = S("Waste"), tiles = {"waste.png"}, is_ground_content = false, groups = {crumbly=2, flammable=2}, @@ -165,7 +167,7 @@ if minetest.get_modpath("awards") then if levels then local items_crafted = data.craft[itemname] or 0 if not authorized_craft(items_crafted, levels, data.unlocked) then - minetest.chat_send_player(playern, "Vous n'avez pas assez d'expérience pour fabriquer cet article ! À la place, vous obtenez un bloc de déchets. / You don't have enough experience to make this item! Instead, you get a block of waste.") + minetest.chat_send_player(playern, S("You don't have enough experience to make this item! Instead, you get a block of waste.")) return ItemStack("nalc:waste") end end diff --git a/nalc_awards/locale/nalc_awards.fr.tr b/nalc_awards/locale/nalc_awards.fr.tr new file mode 100644 index 0000000..1db4f77 --- /dev/null +++ b/nalc_awards/locale/nalc_awards.fr.tr @@ -0,0 +1,16 @@ +# textdomain: nalc_awards + + (Unlock the craft of 1 Quarry)= (Débloque la fabrication de 1 Quarry) + (Unlock the craft of 1 Super Quarry)= (Débloque la fabrication de 1 Super Quarry) +The Iron Lady=La Dame de Fer +Dig 100 iron ores. (Unlock the craft of 2 Quarry)=Creusez 100 minerais de fer. (Débloque la fabrication de 2 Quarry) +The Iron Man=L'Homme de Fer +Dig 1,000 iron ores. (Unlock the craft of 1 Super Quarry)=Creusez 1 000 minerais de fer. (Débloque la fabrication de 1 Super Quarry) +Copper Trooper=Soldat de cuivre +Dig 100 copper ores. (Unlock the craft of 4 Quarry)=Creusez 100 minerais de cuivre. (Débloque la fabrication de 4 Quarry) +Gold Digger=Chercheur d'or +Dig 100 gold ores. (Unlock the craft of 5 Quarry)=Creusez 100 minerais d'or. (Débloque la fabrication de 5 Quarry) +The Golden Age=L'âge d'or +Dig 1,000 gold ores. (Unlock the craft of 1 Super Quarry)=Creusez 1 000 minerais d'or. (Débloque la fabrication de 1 Super Quarry) +Waste=Déchets +You don't have enough experience to make this item! Instead, you get a block of waste.=Vous n'avez pas assez d'expérience pour fabriquer cet article ! À la place, vous obtenez un bloc de déchets. diff --git a/nalc_awards/locale/template.txt b/nalc_awards/locale/template.txt new file mode 100644 index 0000000..651fa88 --- /dev/null +++ b/nalc_awards/locale/template.txt @@ -0,0 +1,18 @@ +# textdomain: awards + + (Unlock the craft of 1 Quarry)= + (Unlock the craft of 1 Super Quarry)= +The Iron Lady= +Dig 100 iron ores. (Unlock the craft of 2 Quarry)= +The Iron Man= +Dig 1,000 iron ores. (Unlock the craft of 1 Super Quarry)= +Copper Trooper= +Dig 100 copper ores. (Unlock the craft of 4 Quarry)= +Gold Digger= +Dig 100 gold ores. (Unlock the craft of 5 Quarry)= +The Golden Age= +Dig 1,000 gold ores. (Unlock the craft of 1 Super Quarry)= +Waste= +You don't have enough experience to make this item! Instead, you get a block of waste.= + + diff --git a/nalc_beds/init.lua b/nalc_beds/init.lua index eefa51a..6e3bc32 100644 --- a/nalc_beds/init.lua +++ b/nalc_beds/init.lua @@ -1,3 +1,5 @@ + +local S = minetest.get_translator("nalc_beds") --overidde craft recipe of the default beds minetest.clear_craft({ output = "beds:bed_bottom" }) minetest.clear_craft({ output = "beds:fancy_bed_bottom" }) @@ -23,7 +25,7 @@ for _, colour in pairs({"white", "black", "blue", "green"}) do beds.register_bed( "nalc_beds:fancy_bed_" .. colour, { - description = "Fancy Bed (" .. colour .. ")", + description = S("Fancy Bed (@1)", S(colour)), inventory_image = "beds_bed_fancy_" .. colour .. ".png", wield_image = "beds_bed_fancy_" .. colour .. ".png", tiles = { @@ -80,7 +82,7 @@ for _, colour in pairs({"white", "black", "blue", "green"}) do beds.register_bed( "nalc_beds:bed_" .. colour, { - description = "Simple Bed (" .. colour .. ")", + description = S("Simple Bed (@1)", S(colour)), inventory_image = "beds_bed_" .. colour .. ".png", wield_image = "beds_bed_" .. colour .. ".png", tiles = { diff --git a/nalc_beds/locale/nalc_beds.fr.tr b/nalc_beds/locale/nalc_beds.fr.tr new file mode 100644 index 0000000..ede6c24 --- /dev/null +++ b/nalc_beds/locale/nalc_beds.fr.tr @@ -0,0 +1,8 @@ +# textdomain: nalc_beds + +Fancy Bed (@1)=Lit chic (@1) +Simple Bed (@1)=Lit simple (@1) +white=blanc +black=noir +blue=bleu +green=vert diff --git a/nalc_beds/locale/template.txt b/nalc_beds/locale/template.txt new file mode 100644 index 0000000..451086b --- /dev/null +++ b/nalc_beds/locale/template.txt @@ -0,0 +1,10 @@ +# textdomain: nalc_beds + +Fancy Bed (@1)= +Simple Bed (@1)= +white= +black= +blue= +green= + + diff --git a/nalc_boats/init.lua b/nalc_boats/init.lua index 0bb106b..c718516 100644 --- a/nalc_boats/init.lua +++ b/nalc_boats/init.lua @@ -1,3 +1,4 @@ +local S = minetest.get_translator("nalc_boats") -- -- Helper functions -- @@ -232,7 +233,7 @@ local register_boat = function(parameters) minetest.register_craftitem( "nalc_boats:"..parameters.name, { - description = parameters.description or "Boat", + description = parameters.description or S("Boat"), inventory_image = "boats_"..parameters.name .. "_inventory.png", wield_image = "boats_"..parameters.name.."_wield.png", wield_scale = {x = 2, y = 2, z = 1}, @@ -281,7 +282,7 @@ register_boat( down = 0.18, rotate = 1 }, - description = "Race boat" + description = S("Race boat") }) register_boat( @@ -292,7 +293,7 @@ register_boat( down = 0.25, rotate = 4 }, - description = "Expert race boat" + description = S("Expert race boat") }) register_boat( @@ -303,7 +304,7 @@ register_boat( down = 0.24, rotate = 4 }, - description = "Water boat" + description = S("Water boat") }) register_boat( @@ -314,7 +315,7 @@ register_boat( down = 0.1, rotate = 8 }, - description = "Moon boat" + description = S("Moon boat") }) minetest.register_craft( diff --git a/nalc_boats/locale/nalc_boats.fr.tr b/nalc_boats/locale/nalc_boats.fr.tr new file mode 100644 index 0000000..f8c11c6 --- /dev/null +++ b/nalc_boats/locale/nalc_boats.fr.tr @@ -0,0 +1,7 @@ +# textdomain: nalc_boats + +Boat=Bateau +Race boat=Bateau de course +Expert race boat=Bateau de course expert +Water boat=Bateau à eau +Moon boat=Bateau lunaire diff --git a/nalc_boats/locale/template.txt b/nalc_boats/locale/template.txt new file mode 100644 index 0000000..b328f9e --- /dev/null +++ b/nalc_boats/locale/template.txt @@ -0,0 +1,7 @@ +# textdomain: nalc_boats + +Boat= +Race boat= +Expert race boat= +Water boat= +Moon boat= diff --git a/nalc_bucket/init.lua b/nalc_bucket/init.lua index 91cc8ec..cb0096f 100644 --- a/nalc_bucket/init.lua +++ b/nalc_bucket/init.lua @@ -1,9 +1,11 @@ +local S = minetest.get_translator("nalc_bucket") + bucket.register_liquid( "nalc:acid_source", "nalc:acid_flowing", "nalc_bucket:bucket_acid", "bucket_acid.png", - "Acid Bucket", + S("Acid Bucket"), {not_in_creative_inventory = 1} ) @@ -12,7 +14,7 @@ bucket.register_liquid( "nalc:sand_flowing", "nalc_bucket:bucket_sand", "bucket_sand.png", - "Sand Bucket", + S("Sand Bucket"), {not_in_creative_inventory = 1} ) diff --git a/nalc_bucket/locale/nalc_bucket.fr.tr b/nalc_bucket/locale/nalc_bucket.fr.tr new file mode 100644 index 0000000..d9f7d5b --- /dev/null +++ b/nalc_bucket/locale/nalc_bucket.fr.tr @@ -0,0 +1,4 @@ +# textdomain: nalc_bucket + +Acid Bucket=Seau d'acide +Sand Bucket=Seau de sable diff --git a/nalc_bucket/locale/template.txt b/nalc_bucket/locale/template.txt new file mode 100644 index 0000000..3eeaf59 --- /dev/null +++ b/nalc_bucket/locale/template.txt @@ -0,0 +1,4 @@ +# textdomain: nalc_bucket + +Acid Bucket= +Sand Bucket= diff --git a/nalc_default/fences.lua b/nalc_default/fences.lua index e8b370b..bc653ed 100644 --- a/nalc_default/fences.lua +++ b/nalc_default/fences.lua @@ -1,7 +1,9 @@ +local S = nalc_default.get_translator + default.register_fence( ":nalc:fence_cobble", { - description = "Cobble Fence", + description = S("Cobble Fence"), texture = "default_fence_cobble.png", material = "default:cobble", groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, @@ -11,7 +13,7 @@ default.register_fence( default.register_fence( ":nalc:fence_desert_cobble", { - description = "Desert Cobble Fence", + description = S("Desert Cobble Fence"), texture = "default_fence_desert_cobble.png", material = "default:desert_cobble", groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, @@ -21,7 +23,7 @@ default.register_fence( default.register_fence( ":nalc:fence_steelblock", { - description = "Steel Block Fence", + description = S("Steel Block Fence"), texture = "default_fence_steelblock.png", material = "default:steelblock", groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, @@ -31,7 +33,7 @@ default.register_fence( default.register_fence( ":nalc:fence_brick", { - description = "Brick Fence", + description = S("Brick Fence"), texture = "default_fence_brick.png", material = "default:brick", groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, diff --git a/nalc_default/init.lua b/nalc_default/init.lua index 03d745b..dc2a935 100644 --- a/nalc_default/init.lua +++ b/nalc_default/init.lua @@ -1,5 +1,9 @@ local modpath = minetest.get_modpath(minetest.get_current_modname()) +local S = minetest.get_translator("nalc_default") +nalc_default = {} +nalc_default.get_translator = S + -- Functions dofile(modpath.."/functions.lua") diff --git a/nalc_default/locale/nalc_default.fr.tr b/nalc_default/locale/nalc_default.fr.tr new file mode 100644 index 0000000..89db789 --- /dev/null +++ b/nalc_default/locale/nalc_default.fr.tr @@ -0,0 +1,31 @@ +# textdomain: nalc_default + +## nodes.lua ## + +Coal Ore=Minerai de charbon +Iron Ore=Minerai de fer +Copper Ore=Minerai de cuivre +Tin Ore=Minerai d'étain +Meze Block=Bloc de meze +Spiky Cactus=Cactus piquant +Acid Source=Source d'acide +Flowing Acid=Écoulement d'acide +Sand Source=Source de sable +Flowing Sand=Écoulement de sable +Obsidian Ladder=Échelle en obsidienne + + +## fences.lua ## + +Cobble Fence=Clôture en pavé +Desert Cobble Fence=Clôture en pavé du désert +Steel Block Fence=Clôture en blocs d'acier +Brick Fence=Clôture en brique + + +## mapgen.lua ## + +Golden Pickaxe=Pioche en or +Golden Shovel=Pelle en or +Golden Axe=Hache en or +Golden Sword=Épée en or diff --git a/nalc_default/locale/template.txt b/nalc_default/locale/template.txt new file mode 100644 index 0000000..10ba053 --- /dev/null +++ b/nalc_default/locale/template.txt @@ -0,0 +1,31 @@ +# textdomain: nalc_default + +## nodes.lua ## + +Coal Ore= +Iron Ore= +Copper Ore= +Tin Ore= +Meze Block= +Spiky Cactus= +Acid Source= +Flowing Acid= +Sand Source= +Flowing Sand= +Obsidian Ladder= + + +## fences.lua ## + +Cobble Fence= +Desert Cobble Fence= +Steel Block Fence= +Brick Fence= + + +## mapgen.lua ## + +Golden Pickaxe= +Golden Shovel= +Golden Axe= +Golden Sword= diff --git a/nalc_default/nodes.lua b/nalc_default/nodes.lua index 1cec72b..3b26072 100644 --- a/nalc_default/nodes.lua +++ b/nalc_default/nodes.lua @@ -1,3 +1,5 @@ +local S = nalc_default.get_translator + local function die_later(digger) digger:set_hp(0) end @@ -5,7 +7,7 @@ end minetest.register_node( ":nalc:desert_stone_with_coal", { - description = "Coal Ore", + description = S("Coal Ore"), tiles = {"default_desert_stone.png^default_mineral_coal.png"}, is_ground_content = true, groups = {crumbly = 1, cracky = 3}, @@ -20,7 +22,7 @@ minetest.register_node( minetest.register_node( ":nalc:desert_stone_with_iron", { - description = "Iron Ore", + description = S("Iron Ore"), tiles = {"default_desert_stone.png^default_mineral_iron.png"}, is_ground_content = true, groups = {cracky = 2}, @@ -35,7 +37,7 @@ minetest.register_node( minetest.register_node( ":nalc:desert_stone_with_copper", { - description = "Copper Ore", + description = S("Copper Ore"), tiles = {"default_desert_stone.png^default_mineral_copper.png"}, is_ground_content = true, groups = {cracky = 2}, @@ -50,7 +52,7 @@ minetest.register_node( minetest.register_node( ":nalc:desert_stone_with_tin", { - description = "Tin Ore", + description = S("Tin Ore"), tiles = {"default_desert_stone.png^default_mineral_tin.png"}, is_ground_content = true, groups = {cracky = 2}, @@ -65,7 +67,7 @@ minetest.register_node( minetest.register_node( ":nalc:meze", { - description = "Meze Block", + description = S("Meze Block"), tiles = {"default_meze_block.png"}, is_ground_content = true, drop = "", @@ -98,7 +100,7 @@ minetest.override_item( minetest.register_node( ":nalc:cactus_spiky", { - description = "Spiky Cactus", + description = S("Spiky Cactus"), tiles = {"default_cactus_top.png", "default_cactus_top.png", "default_cactus_spiky.png"}, paramtype2 = "facedir", @@ -119,7 +121,7 @@ minetest.register_node( minetest.register_node( ":nalc:acid_source", { - description = "Acid Source", + description = S("Acid Source"), inventory_image = minetest.inventorycube("default_acid.png"), drawtype = "liquid", tiles = { @@ -154,7 +156,7 @@ minetest.register_node( minetest.register_node( ":nalc:acid_flowing", { - description = "Flowing Acid", + description = S("Flowing Acid"), inventory_image = minetest.inventorycube("default_acid.png"), drawtype = "flowingliquid", tiles = {"default_acid.png"}, @@ -192,7 +194,7 @@ minetest.register_node( minetest.register_node( ":nalc:sand_source", { - description = "Sand Source", + description = S("Sand Source"), inventory_image = minetest.inventorycube("default_sand.png"), drawtype = "liquid", tiles = {"default_sand.png"}, @@ -215,7 +217,7 @@ minetest.register_node( minetest.register_node( ":nalc:sand_flowing", { - description = "Flowing Sand", + description = S("Flowing Sand"), inventory_image = minetest.inventorycube("default_sand.png"), drawtype = "flowingliquid", tiles = {"default_sand.png"}, @@ -254,7 +256,7 @@ minetest.register_node( minetest.register_node( ":nalc:ladder_obsidian", { - description = "Obsidian Ladder", + description = S("Obsidian Ladder"), drawtype = "signlike", tiles = {"default_ladder_obsidian.png"}, inventory_image = "default_ladder_obsidian.png", diff --git a/nalc_default/tools.lua b/nalc_default/tools.lua index ba6b1c0..016b113 100644 --- a/nalc_default/tools.lua +++ b/nalc_default/tools.lua @@ -1,3 +1,5 @@ +local S = nalc_default.get_translator + minetest.register_craft( { output = 'nalc:pick_gold', recipe = { @@ -44,7 +46,7 @@ minetest.register_craft( minetest.register_tool( ":nalc:pick_gold", { - description = "Golden Pickaxe", + description = S("Golden Pickaxe"), inventory_image = "default_tool_goldpick.png", tool_capabilities = { full_punch_interval = 1.2, @@ -60,7 +62,7 @@ minetest.register_tool( minetest.register_tool( ":nalc:shovel_gold", { - description = "Golden Shovel", + description = S("Golden Shovel"), inventory_image = "default_tool_goldshovel.png", wield_image = "default_tool_goldshovel.png^[transformR90", tool_capabilities = { @@ -76,7 +78,7 @@ minetest.register_tool( minetest.register_tool( ":nalc:axe_gold", { - description = "Golden Axe", + description = S("Golden Axe"), inventory_image = "default_tool_goldaxe.png", tool_capabilities = { full_punch_interval = 1.2, @@ -92,7 +94,7 @@ minetest.register_tool( minetest.register_tool( ":nalc:sword_gold", { - description = "Golden Sword", + description = S("Golden Sword"), inventory_image = "default_tool_goldsword.png", tool_capabilities = { full_punch_interval = 1, @@ -106,28 +108,10 @@ minetest.register_tool( -- Toolranks if minetest.get_modpath("toolranks") then - - minetest.override_item( - "nalc:pick_gold", - { - original_description = "Golden Pickaxe", - description = toolranks.create_description("Golden Pickaxe", 0, 1), - after_use = toolranks.new_afteruse - }) - minetest.override_item( - "nalc:axe_gold", - { - original_description = "Golden Axe", - description = toolranks.create_description("Golden Axe", 0, 1), - after_use = toolranks.new_afteruse - }) - minetest.override_item( - "nalc:shovel_gold", - { - original_description = "Golden Shovel", - description = toolranks.create_description("Golden Shovel", 0, 1), - after_use = toolranks.new_afteruse - }) + toolranks.add_tool("nalc:pick_gold") + toolranks.add_tool("nalc:shovel_gold") + toolranks.add_tool("nalc:axe_gold") + toolranks.add_tool("nalc:sword_gold") end -- Aliases diff --git a/nalc_doors/init.lua b/nalc_doors/init.lua index 48e4198..46cdadc 100644 --- a/nalc_doors/init.lua +++ b/nalc_doors/init.lua @@ -1,3 +1,5 @@ +local S = minetest.get_translator("nalc_doors") + -- Register MFF doors -- doors tin MFF @@ -5,7 +7,7 @@ doors.register( "door_tin", { tiles = { "doors_door_tin.png" }, - description = "Tin Door", + description = S("Tin Door"), inventory_image = "doors_item_tin.png", groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2,door=1}, protected = true, @@ -24,7 +26,7 @@ if minetest.get_modpath("darkage") then "door_prison", { tiles = { "doors_door_prison.png" }, - description = "Prison Door", + description = S("Prison Door"), inventory_image = "doors_item_prison.png", groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2,door=1}, protected = true, @@ -43,7 +45,7 @@ if minetest.get_modpath("dye") then "doors:door_gardengate_white", { tiles = { "doors_door_gardengate_white.png" }, - description = "Garden Gate White Door", + description = S("Garden Gate White Door"), inventory_image = "doors_item_gardengate_white.png", groups = {choppy=2,oddly_breakable_by_hand=2,flammable=2,door=1}, sounds = default.node_sound_wood_defaults(), @@ -408,7 +410,7 @@ function doors.register3(name, def) if def.protected then meta:set_string("owner", pn) - meta:set_string("infotext", "Owned by " .. pn) + meta:set_string("infotext", S("Owned by @1", pn)) end if not (creative and creative.is_enabled_for and creative.is_enabled_for(pn)) then @@ -480,7 +482,7 @@ function doors.register3(name, def) -- verify placer is owner of lockable door if owner ~= pname then minetest.record_protection_violation(pos, pname) - minetest.chat_send_player(pname, "You do not own this locked door.") + minetest.chat_send_player(pname, S("You do not own this locked door.")) return nil end @@ -490,7 +492,7 @@ function doors.register3(name, def) meta:set_string("key_lock_secret", secret) end - return secret, "a locked door", owner + return secret, S("a locked door"), owner end else def.on_blast = function(pos, intensity) @@ -531,7 +533,7 @@ doors.register3( "door3_wood", { tiles = {{ name = "doors_door3_wood.png", backface_culling = true }}, - description = "Wooden Door 3 Nodes", + description = S("Wooden Door 3 Nodes"), inventory_image = "doors3_item_wood.png", groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2 }, recipe = { @@ -551,7 +553,7 @@ doors.register3( "door3_steel", { tiles = {{ name = "doors_door3_steel.png", backface_culling = true }}, - description = "Steel Door 3 Nodes", + description = S("Steel Door 3 Nodes"), inventory_image = "doors3_item_steel.png", protected = true, groups = {cracky = 1, level = 2}, @@ -575,7 +577,7 @@ doors.register3( "door3_glass", { tiles = { "doors_door3_glass.png"}, - description = "Glass Door 3 Nodes", + description = S("Glass Door 3 Nodes"), inventory_image = "doors3_item_glass.png", groups = {cracky=3, oddly_breakable_by_hand=3}, sounds = default.node_sound_glass_defaults(), @@ -598,7 +600,7 @@ doors.register3( "door3_obsidian_glass", { tiles = { "doors_door3_obsidian_glass.png" }, - description = "Obsidian Glass Door 3 Nodes", + description = S("Obsidian Glass Door 3 Nodes"), inventory_image = "doors3_item_obsidian_glass.png", groups = {cracky=3}, sounds = default.node_sound_glass_defaults(), @@ -623,7 +625,7 @@ if minetest.get_modpath("cherry_tree") then "door3_cherry", { tiles = { "doors_door3_cherry.png" }, - description = "Cherry Door 3 Nodes", + description = S("Cherry Door 3 Nodes"), inventory_image = "doors3_item_cherry.png", groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2, door=1}, sounds = default.node_sound_wood_defaults(), @@ -655,7 +657,7 @@ if minetest.get_modpath("darkage") then "door3_prison", { tiles = { "doors_door3_prison.png" }, - description = "Prison Door 3 Nodes", + description = S("Prison Door 3 Nodes"), inventory_image = "doors3_item_prison.png", protected = true, groups = {cracky = 1, level = 2}, diff --git a/nalc_doors/locale/nalc_doors.fr.tr b/nalc_doors/locale/nalc_doors.fr.tr new file mode 100644 index 0000000..dcad2ca --- /dev/null +++ b/nalc_doors/locale/nalc_doors.fr.tr @@ -0,0 +1,15 @@ +# textdomain: nalc_doors + + +Tin Door=Porte en étain +Prison Door=Porte de prison +Garden Gate White Door=Porte de jardin blanche +Owned by @1=Possédé par @1 +You do not own this locked door.=Vous n'êtes pas propriétaire de cette porte verrouillée. +a locked door=une porte verrouillée +Wooden Door 3 Nodes=Porte en bois 3 nodes +Steel Door 3 Nodes=Porte en acier 3 nodes +Glass Door 3 Nodes=Porte vitrée 3 nodes +Obsidian Glass Door 3 Nodes=Porte vitrée en obsidienne 3 nodes +Cherry Door 3 Nodes=Porte en cerisier 3 nodes +Prison Door 3 Nodes=Porte de prison 3 nodes diff --git a/nalc_doors/locale/template.txt b/nalc_doors/locale/template.txt new file mode 100644 index 0000000..3c79353 --- /dev/null +++ b/nalc_doors/locale/template.txt @@ -0,0 +1,15 @@ +# textdomain: nalc_doors + + +Tin Door= +Prison Door= +Garden Gate White Door= +Owned by @1= +You do not own this locked door.= +a locked door= +Wooden Door 3 Nodes= +Steel Door 3 Nodes= +Glass Door 3 Nodes= +Obsidian Glass Door 3 Nodes= +Cherry Door 3 Nodes= +Prison Door 3 Nodes= diff --git a/nalc_flowers/init.lua b/nalc_flowers/init.lua index 3d5f990..52f0651 100644 --- a/nalc_flowers/init.lua +++ b/nalc_flowers/init.lua @@ -1,5 +1,7 @@ +local S = minetest.get_translator("nalc_flowers") + local lilypad_def = table.copy(minetest.registered_nodes["flowers:waterlily"]) -lilypad_def.description = "Lily Pad" +lilypad_def.description = S("Lily Pad") lilypad_def.tiles = {"flowers_lily_pad.png"} lilypad_def.inventory_image = "flowers_lily_pad.png" lilypad_def.wield_image = "flowers_lily_pad.png" @@ -25,7 +27,7 @@ lilypad_def.on_place = function(itemstack, placer, pointed_thing) itemstack:take_item() end else - minetest.chat_send_player(player_name, "Node is protected") + minetest.chat_send_player(player_name, S("Node is protected")) minetest.record_protection_violation(pos, player_name) end end diff --git a/nalc_flowers/locale/nalc_flowers.fr.tr b/nalc_flowers/locale/nalc_flowers.fr.tr new file mode 100644 index 0000000..e595c4c --- /dev/null +++ b/nalc_flowers/locale/nalc_flowers.fr.tr @@ -0,0 +1,4 @@ +# textdomain: nalc_flowers + +Lily Pad=Nénuphar +Node is protected=Node protégé diff --git a/nalc_flowers/locale/template.txt b/nalc_flowers/locale/template.txt new file mode 100644 index 0000000..c631623 --- /dev/null +++ b/nalc_flowers/locale/template.txt @@ -0,0 +1,4 @@ +# textdomain: nalc_flowers + +Lily Pad= +Node is protected= diff --git a/nalc_mediterranean/init.lua b/nalc_mediterranean/init.lua index cc08376..9cc70d7 100644 --- a/nalc_mediterranean/init.lua +++ b/nalc_mediterranean/init.lua @@ -1,3 +1,5 @@ +local S = minetest.get_translator("nalc_mediterranean") + -- Load tree's schematics --local schems_pin_parasol = assert(loadfile(minetest.get_modpath("nalc_mediterranean").."/schematics/pin_parasol.lua"))() -- @@ -10,7 +12,7 @@ -- Mediterranean Dirt definition local dirt_data = table.copy(minetest.registered_nodes["default:dirt_with_dry_grass"]) -dirt_data.description = "Dirt with Mediterranean Grass" +dirt_data.description = S("Dirt with Mediterranean Grass") dirt_data.tiles = {"default_dry_grass.png^[multiply:#8ACA00", "default_dirt.png", {name = "default_dirt.png^(default_dry_grass_side.png^[multiply:#8ACA00)", @@ -22,7 +24,7 @@ minetest.register_node("nalc_mediterranean:dirt_with_mediterranean_grass", dirt_ -- Mediterranean pine needles -- Pine Needles local needles_data = table.copy(minetest.registered_nodes["default:pine_needles"]) -needles_data.description = "Mediterranean Pine Needles" +needles_data.description = S("Mediterranean Pine Needles") needles_data.drop = { max_items = 1, items = { @@ -48,14 +50,14 @@ minetest.register_node("nalc_mediterranean:needles", needles_data) -- Olive tree definition local tree_data = table.copy(minetest.registered_nodes["default:tree"]) -tree_data.description = "Olive tree trunk" +tree_data.description = S("Olive tree trunk") tree_data.tiles = {"default_tree_top.png", "default_tree_top.png", "default_pine_tree.png^[colorize:#8F8F8F6F"} minetest.register_node("nalc_mediterranean:olive_tree", tree_data) -- Mediterranean Olive leaves local leaves_data = table.copy(minetest.registered_nodes["default:leaves"]) -leaves_data.description = "Olive Leaves" +leaves_data.description = S("Olive Leaves") leaves_data.tiles = {"feuilles_olivier.png"} leaves_data.special_tiles = {"feuilles_olivier.png"} leaves_data.drop = { @@ -128,25 +130,25 @@ minetest.register_lbm({ local sapling_data = table.copy(minetest.registered_nodes["default:pine_sapling"]) local trees = { - { description = "Umbrella Pine Sapling", + { description = S("Umbrella Pine Sapling"), sapling = "nalc_mediterranean:sapling_umbrella_pine", minp = {x = -10, y = 1, z = -10}, maxp = {x = 10, y = 16, z = 10}, texture = "default_pine_sapling.png", }, - { description = "Maritime Pine Sapling", + { description = S("Maritime Pine Sapling"), sapling = "nalc_mediterranean:sapling_maritime_pine", minp = {x = -3, y = 1, z = -3}, maxp = {x = 3, y = 14, z = 3}, texture = "default_pine_sapling.png", }, - { description = "Cypress Sapling", + { description = S("Cypress Sapling"), sapling = "nalc_mediterranean:sapling_cypress", minp = {x = -3, y = 1, z = -3}, maxp = {x = 3, y = 19, z = 3}, texture = "default_pine_sapling.png", }, - { description = "Olive Sapling", + { description = S("Olive Sapling"), sapling = "nalc_mediterranean:sapling_olive", minp = {x = -3, y = 1, z = -3}, maxp = {x = 3, y = 9, z = 3}, diff --git a/nalc_mediterranean/locale/nalc_mediterranean.fr.tr b/nalc_mediterranean/locale/nalc_mediterranean.fr.tr new file mode 100644 index 0000000..c52bcfc --- /dev/null +++ b/nalc_mediterranean/locale/nalc_mediterranean.fr.tr @@ -0,0 +1,10 @@ +# textdomain: nalc_mediterranean + +Dirt with Mediterranean Grass=Terre avec de l'herbe méditerranéenne +Mediterranean Pine Needles=Aiguilles de pin méditerranéen +Olive tree trunk=Tronc d'olivier +Olive Leaves=Feuilles d'olivier +Umbrella Pine Sapling=Pousse de pin parasol +Maritime Pine Sapling=Pousse de pin maritime +Cypress Sapling=Pousse de cyprès +Olive Sapling=Pousse d'olivier diff --git a/nalc_mediterranean/locale/template.txt b/nalc_mediterranean/locale/template.txt new file mode 100644 index 0000000..dbc8877 --- /dev/null +++ b/nalc_mediterranean/locale/template.txt @@ -0,0 +1,10 @@ +# textdomain: nalc_mediterranean + +Dirt with Mediterranean Grass= +Mediterranean Pine Needles= +Olive tree trunk= +Olive Leaves= +Umbrella Pine Sapling= +Maritime Pine Sapling= +Cypress Sapling= +Olive Sapling= diff --git a/nalc_mobs/init.lua b/nalc_mobs/init.lua index 4382cc9..d9aa1fc 100644 --- a/nalc_mobs/init.lua +++ b/nalc_mobs/init.lua @@ -1,8 +1,10 @@ +local S = minetest.get_translator("nalc_mobs") + -- scorched stuff minetest.register_craftitem( ":mobs:scorched_stuff", { - description = "Scorched Stuff", + description = S("Scorched Stuff"), inventory_image = "default_scorched_stuff.png", }) @@ -31,7 +33,7 @@ minetest.register_alias("default:scorched_stuff", "mobs:scorched_stuff") minetest.register_tool( ":mobs:dungeon_master_sword", { - description = "Dungeon Master's Blood Sword (Warrior)", + description = S("Dungeon Master's Blood Sword (Warrior)"), inventory_image = "default_tool_dungeon_master_s_blood_sword.png", tool_capabilities = { full_punch_interval = 0.5, @@ -54,13 +56,7 @@ minetest.register_craft( }) if minetest.get_modpath("toolranks") then - minetest.override_item( - "mobs:dungeon_master_sword", - { - original_description = "Dungeon Master's Blood Sword", - description = toolranks.create_description("Dungeon Master's Blood Sword", 0, 1), - after_use = toolranks.new_afteruse - }) + toolranks.add_tool("mobs:dungeon_master_sword") end minetest.register_alias("nalc:dungeon_master_s_blood_sword", "mobs:dungeon_master_sword") diff --git a/nalc_mobs/locale/nalc_mobs.fr.tr b/nalc_mobs/locale/nalc_mobs.fr.tr new file mode 100644 index 0000000..459221b --- /dev/null +++ b/nalc_mobs/locale/nalc_mobs.fr.tr @@ -0,0 +1,4 @@ +# textdomain: nalc_mobs + +Scorched Stuff=Chose brûlée +Dungeon Master's Blood Sword (Warrior)=Épée de sang du maître du donjon (Guerrier) diff --git a/nalc_mobs/locale/template.txt b/nalc_mobs/locale/template.txt new file mode 100644 index 0000000..cda34d8 --- /dev/null +++ b/nalc_mobs/locale/template.txt @@ -0,0 +1,4 @@ +# textdomain: nalc_mobs + +Scorched Stuff= +Dungeon Master's Blood Sword (Warrior)= diff --git a/nalc_moognu/init.lua b/nalc_moognu/init.lua index fbf7df6..d57a8dc 100644 --- a/nalc_moognu/init.lua +++ b/nalc_moognu/init.lua @@ -1,3 +1,5 @@ +local S = minetest.get_translator("nalc_moognu") + minetest.register_craft({ type = "fuel", recipe = "nyancat:nyancat", @@ -56,7 +58,7 @@ minetest.register_craft( minetest.register_tool( ":nalc:pick_nyan", { - description = "Nyan Pickaxe", + description = S("Nyan Pickaxe"), inventory_image = "default_tool_nyanpick.png", tool_capabilities = { full_punch_interval = 0.9, @@ -72,7 +74,7 @@ minetest.register_tool( minetest.register_tool( ":nalc:shovel_nyan", { - description = "Nyan Shovel", + description = S("Nyan Shovel"), inventory_image = "default_tool_nyanshovel.png", wield_image = "default_tool_nyanshovel.png^[transformR90", tool_capabilities = { @@ -88,7 +90,7 @@ minetest.register_tool( minetest.register_tool( ":nalc:axe_nyan", { - description = "Nyan Axe", + description = S("Nyan Axe"), inventory_image = "default_tool_nyanaxe.png", tool_capabilities = { full_punch_interval = 1.2, @@ -104,7 +106,7 @@ minetest.register_tool( minetest.register_tool( ":nalc:sword_nyan", { - description = "Nyan Sword", + description = S("Nyan Sword"), inventory_image = "default_tool_nyansword.png", tool_capabilities = { full_punch_interval = 0.65, @@ -123,27 +125,10 @@ minetest.register_alias("default:sword_nyan", "nalc:sword_nyan") -- Toolranks if minetest.get_modpath("toolranks") then - minetest.override_item( - "nalc:pick_nyan", - { - original_description = "Nyan Pickaxe", - description = toolranks.create_description("Nyan Pickaxe", 0, 1), - after_use = toolranks.new_afteruse - }) - minetest.override_item( - "nalc:axe_nyan", - { - original_description = "Nyan Axe", - description = toolranks.create_description("Nyan Axe", 0, 1), - after_use = toolranks.new_afteruse - }) - minetest.override_item( - "nalc:shovel_nyan", - { - original_description = "Nyan Shovel", - description = toolranks.create_description("Nyan Shovel", 0, 1), - after_use = toolranks.new_afteruse - }) + toolranks.add_tool("nalc:pick_nyan") + toolranks.add_tool("nalc:axe_nyan") + toolranks.add_tool("nalc:shovel_nyan") + toolranks.add_tool("nalc:sword_nyan") end minetest.log("action", "[nalc_moognu] loaded.") diff --git a/nalc_moognu/locale/nalc_moognu.fr.tr b/nalc_moognu/locale/nalc_moognu.fr.tr new file mode 100644 index 0000000..7deb118 --- /dev/null +++ b/nalc_moognu/locale/nalc_moognu.fr.tr @@ -0,0 +1,6 @@ +# textdomain: nalc_moognu + +Nyan Pickaxe=Pioche en Nyan +Nyan Shovel=Pelle en Nyan +Nyan Axe=Hache en Nyan +Nyan Sword=Épée en Nyan diff --git a/nalc_moognu/locale/template.txt b/nalc_moognu/locale/template.txt new file mode 100644 index 0000000..9ba65e4 --- /dev/null +++ b/nalc_moognu/locale/template.txt @@ -0,0 +1,6 @@ +# textdomain: nalc_moognu + +Nyan Pickaxe= +Nyan Shovel= +Nyan Axe= +Nyan Sword= From e83afa9961733a7c5e4227b91208fa5118d20adb Mon Sep 17 00:00:00 2001 From: Crabman77 Date: Fri, 29 Jul 2022 00:59:17 +0200 Subject: [PATCH 2/2] update 3 nodes doors code with 2 nodes doors changes from default doors. replace function doors.door_toggle() with door_toggle() from nalc_doors(double doors gestion) replace function doors.on_skeleton_key_use() with new copied function in nalc_doors(double doors gestion) --- nalc_doors/init.lua | 452 ++++++++++++++++++++++++++------------------ 1 file changed, 265 insertions(+), 187 deletions(-) diff --git a/nalc_doors/init.lua b/nalc_doors/init.lua index 46cdadc..67be1cf 100644 --- a/nalc_doors/init.lua +++ b/nalc_doors/init.lua @@ -9,7 +9,7 @@ doors.register( tiles = { "doors_door_tin.png" }, description = S("Tin Door"), inventory_image = "doors_item_tin.png", - groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2,door=1}, + groups = {node=1,snappy=1,bendy=2,cracky=1,melty=2,level=2,door=1}, protected = true, sounds = default.node_sound_stone_defaults(), sunlight = false, @@ -28,9 +28,11 @@ if minetest.get_modpath("darkage") then tiles = { "doors_door_prison.png" }, description = S("Prison Door"), inventory_image = "doors_item_prison.png", - groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2,door=1}, + groups = {node=1,snappy=1,bendy=2,cracky=1,melty=2,level=2,door=1}, protected = true, sounds = default.node_sound_stone_defaults(), + sound_open = "doors_steel_door_open", + sound_close = "doors_steel_door_close", recipe = { {"darkage:iron_stick", "darkage:iron_stick"}, {"darkage:iron_stick", "darkage:iron_stick"}, @@ -47,7 +49,7 @@ if minetest.get_modpath("dye") then tiles = { "doors_door_gardengate_white.png" }, description = S("Garden Gate White Door"), inventory_image = "doors_item_gardengate_white.png", - groups = {choppy=2,oddly_breakable_by_hand=2,flammable=2,door=1}, + groups = {node=1,choppy=2,oddly_breakable_by_hand=2,flammable=2,door=1}, sounds = default.node_sound_wood_defaults(), recipe = { {"dye:white", "group:stick", ""}, @@ -213,12 +215,18 @@ function _doors.door_toggle(pos, node, clicker) end local dir = node.param2 - minetest.swap_node( - pos, - { - name = name .. transform[state + 1][dir+1].v, - param2 = transform[state + 1][dir+1].param2 - }) + + -- It's possible param2 is messed up, so, validate before using + -- the input data. This indicates something may have rotated + -- the door, even though that is not supported. + if not transform[state + 1] or not transform[state + 1][dir + 1] then + return false + end + + minetest.swap_node(pos, { + name = name .. transform[state + 1][dir+1].v, + param2 = transform[state + 1][dir+1].param2 + }) meta:set_int("state", state) --MFF double porte @@ -239,14 +247,20 @@ function _doors.door_toggle(pos, node, clicker) -- /double porte if state % 2 == 0 then - minetest.sound_play(def.door.sounds[1], {pos = pos, gain = 0.3, max_hear_distance = 10}) + minetest.sound_play(def.door.sounds[1], + {pos = pos, gain = def.door.gains[1], max_hear_distance = 10}, true) else - minetest.sound_play(def.door.sounds[2], {pos = pos, gain = 0.3, max_hear_distance = 10}) + minetest.sound_play(def.door.sounds[2], + {pos = pos, gain = def.door.gains[2], max_hear_distance = 10}, true) end return true end + +local old_doors_toggle = doors.door_toggle -- unused now +doors.door_toggle = _doors.door_toggle + local function on_place_node(place_to, newnode, placer, oldnode, itemstack, pointed_thing) -- Run script hook for _, callback in ipairs(minetest.registered_on_placenodes) do @@ -276,6 +290,70 @@ local function can_dig_door(pos, digger) end end + +local function on_skeleton_key_use(pos, player, newsecret) + replace_old_owner_information(pos) + local meta = minetest.get_meta(pos) + local owner = meta:get_string("owner") + local pname = player:get_player_name() + + -- verify placer is owner of lockable door + if owner ~= pname then + minetest.record_protection_violation(pos, pname) + minetest.chat_send_player(pname, S("You do not own this locked door.")) + return nil + end + + local secret = meta:get_string("key_lock_secret") + if secret == "" then + secret = newsecret + meta:set_string("key_lock_secret", secret) + + --MFF double porte + local node = minetest.get_node(pos) + local def = minetest.registered_nodes[node.name] + local b = string.sub(node.name, -1) + local dir = node.param2 + local state = meta:get_string("state") + if state == "" then + if node.name:sub(-2) == "_b" then + state = 2 + else + state = 0 + end + else + state = tonumber(state) + end + local pos2 = get_double_doors(pos, dir, state, b) + if pos2 then + local node2 = minetest.get_node_or_nil(pos2) + if node2 and string.sub(node2.name, 0, -3) == string.sub(node.name, 0, -3) then + if b ~= string.sub(node2.name, -1) then + local state2 = minetest.get_meta(pos2):get_int("state") + if (state % 2) == (state2 % 2) then + local meta2 = minetest.get_meta(pos2) + meta2:set_string("key_lock_secret", secret) + end + end + end + end + -- /double porte + end + + return secret, S("a locked door"), owner +end + + +-- / rewrite function of default protected doors, keys open double doors +minetest.register_on_mods_loaded(function() + for n in pairs(doors.registered_doors) do + local def = minetest.registered_nodes[n] + if def and def.on_skeleton_key_use then + def.on_skeleton_key_use = on_skeleton_key_use + end + end +end) + -- door 3 nodes function doors.register3(name, def) if not name:find(":") then @@ -283,155 +361,150 @@ function doors.register3(name, def) end -- replace old doors of this type automatically - minetest.register_lbm( - { - name = ":doors:replace_" .. name:gsub(":", "_"), - nodenames = {name.."_b_1", name.."_b_2"}, - action = function(pos, node) - local l = tonumber(node.name:sub(-1)) - local meta = minetest.get_meta(pos) - local h = meta:get_int("right") + 1 - local p2 = node.param2 - local replace = { - {{type = "a", state = 0}, {type = "a", state = 3}}, - {{type = "b", state = 1}, {type = "b", state = 2}} - } - local new = replace[l][h] - -- retain infotext and doors_owner fields - minetest.swap_node(pos, {name = name .. "_" .. new.type, param2 = p2}) - meta:set_int("state", new.state) - -- properly place doors:hidden at the right spot - local p3 = p2 + minetest.register_lbm({ + name = ":doors:replace_" .. name:gsub(":", "_"), + nodenames = {name.."_b_1", name.."_b_2"}, + action = function(pos, node) + local l = tonumber(node.name:sub(-1)) + local meta = minetest.get_meta(pos) + local h = meta:get_int("right") + 1 + local p2 = node.param2 + local replace = { + {{type = "a", state = 0}, {type = "a", state = 3}}, + {{type = "b", state = 1}, {type = "b", state = 2}} + } + local new = replace[l][h] + -- retain infotext and doors_owner fields + minetest.swap_node(pos, {name = name .. "_" .. new.type, param2 = p2}) + meta:set_int("state", new.state) + -- properly place doors:hidden at the right spot + local p3 = p2 + if new.state >= 2 then + p3 = (p3 + 3) % 4 + end + if new.state % 2 == 1 then if new.state >= 2 then + p3 = (p3 + 1) % 4 + else p3 = (p3 + 3) % 4 end - if new.state % 2 == 1 then - if new.state >= 2 then - p3 = (p3 + 1) % 4 - else - p3 = (p3 + 3) % 4 - end - end - -- wipe meta on top node as it's unused - minetest.set_node( - {x = pos.x, y = pos.y + 1, z = pos.z}, - {name = "doors:hidden", param2 = p3} - ) - minetest.set_node( - {x = pos.x, y = pos.y + 2, z = pos.z}, - {name = "doors:hidden", param2 = p3} - ) end - }) - - minetest.register_craftitem( - ":" .. name, - { - description = def.description, - inventory_image = def.inventory_image, - groups = table.copy(def.groups), - - on_place = function(itemstack, placer, pointed_thing) - local pos - - if not pointed_thing.type == "node" then - return itemstack - end - - local node = minetest.get_node(pointed_thing.under) - local pdef = minetest.registered_nodes[node.name] - if pdef and pdef.on_rightclick and - not placer:get_player_control().sneak then - return pdef.on_rightclick(pointed_thing.under, - node, placer, itemstack, pointed_thing) - end - - if pdef and pdef.buildable_to then - pos = pointed_thing.under - else - pos = pointed_thing.above - node = minetest.get_node(pos) - pdef = minetest.registered_nodes[node.name] - if not pdef or not pdef.buildable_to then - return itemstack - end - end - - local above = {x = pos.x, y = pos.y + 1, z = pos.z} - local top_node = minetest.get_node_or_nil(above) - local topdef = top_node and minetest.registered_nodes[top_node.name] - - if not topdef or not topdef.buildable_to then - return itemstack - end - - local above2 = { x = pos.x, y = pos.y + 2, z = pos.z } - local top_node2 = minetest.get_node_or_nil(above2) - local topdef2 = top_node2 and minetest.registered_nodes[top_node2.name] - - if not topdef2 or not topdef2.buildable_to then - return itemstack - end - - local pn = placer:get_player_name() - if minetest.is_protected(pos, pn) or minetest.is_protected(above, pn) or minetest.is_protected(above2, pn) then - return itemstack - end - - local dir = minetest.dir_to_facedir(placer:get_look_dir()) - - local ref = { - {x = -1, y = 0, z = 0}, - {x = 0, y = 0, z = 1}, - {x = 1, y = 0, z = 0}, - {x = 0, y = 0, z = -1}, - } - - local aside = { - x = pos.x + ref[dir + 1].x, - y = pos.y + ref[dir + 1].y, - z = pos.z + ref[dir + 1].z, - } - - local state = 0 - if minetest.get_item_group(minetest.get_node(aside).name, "door") == 1 then - state = state + 2 - minetest.set_node(pos, {name = name .. "_b", param2 = dir}) - minetest.set_node(above, {name = "doors:hidden", param2 = (dir + 3) % 4}) - minetest.set_node(above2, {name = "doors:hidden", param2 = (dir + 3) % 4}) - else - minetest.set_node(pos, {name = name .. "_a", param2 = dir}) - minetest.set_node(above, {name = "doors:hidden", param2 = dir}) - minetest.set_node(above2, {name = "doors:hidden", param2 = dir}) - end - - local meta = minetest.get_meta(pos) - meta:set_int("state", state) - - if def.protected then - meta:set_string("owner", pn) - meta:set_string("infotext", S("Owned by @1", pn)) - end - - if not (creative and creative.is_enabled_for and creative.is_enabled_for(pn)) then - itemstack:take_item() - end - - minetest.sound_play(def.sounds.place, {pos = pos}) - - on_place_node(pos, minetest.get_node(pos), placer, node, itemstack, pointed_thing) - + -- wipe meta on top node as it's unused + minetest.set_node({x = pos.x, y = pos.y + 1, z = pos.z}, + {name = "doors:hidden", param2 = p3}) + minetest.set_node({x = pos.x, y = pos.y + 2, z = pos.z}, + {name = "doors:hidden", param2 = p3}) + end + }) + + minetest.register_craftitem(":" .. name, { + description = def.description, + inventory_image = def.inventory_image, + groups = table.copy(def.groups), + + on_place = function(itemstack, placer, pointed_thing) + local pos + + if pointed_thing.type ~= "node" then return itemstack end - }) + + local doorname = itemstack:get_name() + local node = minetest.get_node(pointed_thing.under) + local pdef = minetest.registered_nodes[node.name] + if pdef and pdef.on_rightclick and + not (placer and placer:is_player() and + placer:get_player_control().sneak) then + return pdef.on_rightclick(pointed_thing.under, + node, placer, itemstack, pointed_thing) + end + + if pdef and pdef.buildable_to then + pos = pointed_thing.under + else + pos = pointed_thing.above + node = minetest.get_node(pos) + pdef = minetest.registered_nodes[node.name] + if not pdef or not pdef.buildable_to then + return itemstack + end + end + + local above = {x = pos.x, y = pos.y + 1, z = pos.z} + local top_node = minetest.get_node_or_nil(above) + local topdef = top_node and minetest.registered_nodes[top_node.name] + + if not topdef or not topdef.buildable_to then + return itemstack + end + + local above2 = { x = pos.x, y = pos.y + 2, z = pos.z } + local top_node2 = minetest.get_node_or_nil(above2) + local topdef2 = top_node2 and minetest.registered_nodes[top_node2.name] + + if not topdef2 or not topdef2.buildable_to then + return itemstack + end + + local pn = placer and placer:get_player_name() or "" + if minetest.is_protected(pos, pn) or minetest.is_protected(above, pn) or minetest.is_protected(above2, pn) then + return itemstack + end + + local dir = placer and minetest.dir_to_facedir(placer:get_look_dir()) or 0 + + local ref = { + {x = -1, y = 0, z = 0}, + {x = 0, y = 0, z = 1}, + {x = 1, y = 0, z = 0}, + {x = 0, y = 0, z = -1}, + } + + local aside = { + x = pos.x + ref[dir + 1].x, + y = pos.y + ref[dir + 1].y, + z = pos.z + ref[dir + 1].z, + } + + local state = 0 + if minetest.get_item_group(minetest.get_node(aside).name, "door") == 1 then + state = state + 2 + minetest.set_node(pos, {name = doorname .. "_b", param2 = dir}) + minetest.set_node(above, {name = "doors:hidden", param2 = (dir + 3) % 4}) + minetest.set_node(above2, {name = "doors:hidden", param2 = (dir + 3) % 4}) + else + minetest.set_node(pos, {name = name .. "_a", param2 = dir}) + minetest.set_node(above, {name = "doors:hidden", param2 = dir}) + minetest.set_node(above2, {name = "doors:hidden", param2 = dir}) + end + + local meta = minetest.get_meta(pos) + meta:set_int("state", state) + + if def.protected then + meta:set_string("owner", pn) + meta:set_string("infotext", def.description .. "\n" .. S("Owned by @1", pn)) + end + + if not (creative and creative.is_enabled_for and creative.is_enabled_for(pn)) then + itemstack:take_item() + end + + minetest.sound_play(def.sounds.place, {pos = pos}, true) + + on_place_node(pos, minetest.get_node(pos), + placer, node, itemstack, pointed_thing) + + return itemstack + end + }) def.inventory_image = nil - + if def.recipe then - minetest.register_craft( - { - output = name, - recipe = def.recipe, - }) + minetest.register_craft({ + output = name, + recipe = def.recipe, + }) end def.recipe = nil @@ -447,24 +520,36 @@ function doors.register3(name, def) def.sound_close = "doors_door_close" end + if not def.gain_open then + def.gain_open = 0.3 + end + + if not def.gain_close then + def.gain_close = 0.3 + end + def.groups.not_in_creative_inventory = 1 def.groups.door = 1 def.drop = name def.door = { name = name, - sounds = { def.sound_close, def.sound_open }, + sounds = {def.sound_close, def.sound_open}, + gains = {def.gain_close, def.gain_open}, } - - def.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) - _doors.door_toggle(pos, node, clicker) - return itemstack + if not def.on_rightclick then + def.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + _doors.door_toggle(pos, node, clicker) + return itemstack + end end def.after_dig_node = function(pos, node, meta, digger) minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) minetest.remove_node({x = pos.x, y = pos.y + 2, z = pos.z}) minetest.check_for_falling({x = pos.x, y = pos.y + 2, z = pos.z}) end - def.on_rotate = false + def.on_rotate = function(pos, node, user, mode, new_param2) + return false + end if def.protected then def.can_dig = can_dig_door @@ -473,27 +558,9 @@ function doors.register3(name, def) local door = doors.get(pos) door:toggle(player) end - def.on_skeleton_key_use = function(pos, player, newsecret) - replace_old_owner_information(pos) - local meta = minetest.get_meta(pos) - local owner = meta:get_string("owner") - local pname = player:get_player_name() - - -- verify placer is owner of lockable door - if owner ~= pname then - minetest.record_protection_violation(pos, pname) - minetest.chat_send_player(pname, S("You do not own this locked door.")) - return nil - end - - local secret = meta:get_string("key_lock_secret") - if secret == "" then - secret = newsecret - meta:set_string("key_lock_secret", secret) - end - - return secret, S("a locked door"), owner - end + def.on_skeleton_key_use = on_skeleton_key_use + + def.node_dig_prediction = "" else def.on_blast = function(pos, intensity) minetest.remove_node(pos) @@ -518,15 +585,24 @@ function doors.register3(name, def) def.buildable_to = false def.selection_box = {type = "fixed", fixed = {-1/2,-1/2,-1/2,1/2,2.5,-6/16}} def.collision_box = {type = "fixed", fixed = {-1/2,-1/2,-1/2,1/2,2.5,-6/16}} + def.use_texture_alpha = def.use_texture_alpha or "clip" def.mesh = "door3_a.obj" - minetest.register_node(":" .. name .. "_a", def) + minetest.register_node(":" .. name .. "_a", table.copy(def)) def.mesh = "door3_b.obj" - minetest.register_node(":" .. name .. "_b", def) + minetest.register_node(":" .. name .. "_b", table.copy(def)) + + def.mesh = "door3_b.obj" + minetest.register_node(":" .. name .. "_c", table.copy(def)) + + def.mesh = "door3_a.obj" + minetest.register_node(":" .. name .. "_d", table.copy(def)) _doors.registered_doors3[name .. "_a"] = true _doors.registered_doors3[name .. "_b"] = true + _doors.registered_doors3[name .. "_c"] = true + _doors.registered_doors3[name .. "_d"] = true end doors.register3( @@ -535,7 +611,9 @@ doors.register3( tiles = {{ name = "doors_door3_wood.png", backface_culling = true }}, description = S("Wooden Door 3 Nodes"), inventory_image = "doors3_item_wood.png", - groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2 }, + groups = {node = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 2 }, + gain_open = 0.06, + gain_close = 0.13, recipe = { {"", "", ""}, {"", "doors:door_wood", ""}, @@ -556,7 +634,7 @@ doors.register3( description = S("Steel Door 3 Nodes"), inventory_image = "doors3_item_steel.png", protected = true, - groups = {cracky = 1, level = 2}, + groups = {node = 1, cracky = 1, level = 2}, sounds = default.node_sound_metal_defaults(), sound_open = "doors_steel_door_open", sound_close = "doors_steel_door_close", @@ -579,7 +657,7 @@ doors.register3( tiles = { "doors_door3_glass.png"}, description = S("Glass Door 3 Nodes"), inventory_image = "doors3_item_glass.png", - groups = {cracky=3, oddly_breakable_by_hand=3}, + groups = {node=1, cracky=3, oddly_breakable_by_hand=3}, sounds = default.node_sound_glass_defaults(), sound_open = "doors_glass_door_open", sound_close = "doors_glass_door_close", @@ -602,7 +680,7 @@ doors.register3( tiles = { "doors_door3_obsidian_glass.png" }, description = S("Obsidian Glass Door 3 Nodes"), inventory_image = "doors3_item_obsidian_glass.png", - groups = {cracky=3}, + groups = {node=1,cracky=3}, sounds = default.node_sound_glass_defaults(), sound_open = "doors_glass_door_open", sound_close = "doors_glass_door_close", @@ -627,7 +705,7 @@ if minetest.get_modpath("cherry_tree") then tiles = { "doors_door3_cherry.png" }, description = S("Cherry Door 3 Nodes"), inventory_image = "doors3_item_cherry.png", - groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2, door=1}, + groups = {node=1, choppy=2, oddly_breakable_by_hand=2, flammable=2, door=1}, sounds = default.node_sound_wood_defaults(), recipe = { {"", "", ""}, @@ -660,7 +738,7 @@ if minetest.get_modpath("darkage") then description = S("Prison Door 3 Nodes"), inventory_image = "doors3_item_prison.png", protected = true, - groups = {cracky = 1, level = 2}, + groups = {node = 1, cracky = 1, level = 2}, sounds = default.node_sound_metal_defaults(), sound_open = "doors_steel_door_open", sound_close = "doors_steel_door_close",