Add support for intllib

This commit is contained in:
stujones11
2017-03-31 19:54:12 +01:00
parent 7fde7c050d
commit 23e4d5114f
8 changed files with 105 additions and 76 deletions

View File

@ -12,8 +12,6 @@ armor = {
default.gui_bg_img..
default.gui_slots..
default.get_hotbar_bg(0, 4.7)..
"label[5,1;Level: armor_level]"..
"label[5,1.5;Heal: armor_attr_heal]"..
"list[current_player;main;0,4.7;8,1;]"..
"list[current_player;main;0,5.85;8,3;8]",
def = {},

View File

@ -1,10 +1,15 @@
local S = function(s) return s end
if minetest.global_exists("intllib") then
S = intllib.Getter()
end
minetest.register_alias("adminboots","3d_armor:boots_admin")
minetest.register_alias("adminhelmet","3d_armor:helmet_admin")
minetest.register_alias("adminchestplate","3d_armor:chestplate_admin")
minetest.register_alias("adminleggings","3d_armor:leggings_admin")
armor:register_armor("3d_armor:helmet_admin", {
description = "Admin Helmet",
description = S("Admin Helmet"),
inventory_image = "3d_armor_inv_helmet_admin.png",
armor_groups = {fleshy=100},
groups = {armor_head=1, armor_heal=100, armor_use=0, armor_water=1,
@ -15,7 +20,7 @@ armor:register_armor("3d_armor:helmet_admin", {
})
armor:register_armor("3d_armor:chestplate_admin", {
description = "Admin Chestplate",
description = S("Admin Chestplate"),
inventory_image = "3d_armor_inv_chestplate_admin.png",
armor_groups = {fleshy=100},
groups = {armor_torso=1, armor_heal=100, armor_use=0,
@ -26,7 +31,7 @@ armor:register_armor("3d_armor:chestplate_admin", {
})
armor:register_armor("3d_armor:leggings_admin", {
description = "Admin Leggings",
description = S("Admin Leggings"),
inventory_image = "3d_armor_inv_leggings_admin.png",
armor_groups = {fleshy=100},
groups = {armor_legs=1, armor_heal=100, armor_use=0,
@ -37,7 +42,7 @@ armor:register_armor("3d_armor:leggings_admin", {
})
armor:register_armor("3d_armor:boots_admin", {
description = "Admin Boots",
description = S("Admin Boots"),
inventory_image = "3d_armor_inv_boots_admin.png",
armor_groups = {fleshy=100},
groups = {armor_feet=1, armor_heal=100, armor_use=0,
@ -49,25 +54,25 @@ armor:register_armor("3d_armor:boots_admin", {
if armor.materials.wood then
armor:register_armor("3d_armor:helmet_wood", {
description = "Wood Helmet",
description = S("Wood Helmet"),
inventory_image = "3d_armor_inv_helmet_wood.png",
armor_groups = {fleshy=5},
groups = {armor_head=1, armor_heal=0, armor_use=2000},
})
armor:register_armor("3d_armor:chestplate_wood", {
description = "Wood Chestplate",
description = S("Wood Chestplate"),
inventory_image = "3d_armor_inv_chestplate_wood.png",
armor_groups = {fleshy=10},
groups = {armor_torso=1, armor_heal=0, armor_use=2000},
})
armor:register_armor("3d_armor:leggings_wood", {
description = "Wood Leggings",
description = S("Wood Leggings"),
inventory_image = "3d_armor_inv_leggings_wood.png",
armor_groups = {fleshy=5},
groups = {armor_legs=1, armor_heal=0, armor_use=2000},
})
armor:register_armor("3d_armor:boots_wood", {
description = "Wood Boots",
description = S("Wood Boots"),
inventory_image = "3d_armor_inv_boots_wood.png",
armor_groups = {fleshy=5},
groups = {armor_feet=1, armor_heal=0, armor_use=2000},
@ -76,25 +81,25 @@ end
if armor.materials.cactus then
armor:register_armor("3d_armor:helmet_cactus", {
description = "Cactus Helmet",
description = S("Cactus Helmet"),
inventory_image = "3d_armor_inv_helmet_cactus.png",
armor_groups = {fleshy=5},
groups = {armor_head=1, armor_heal=0, armor_use=1000},
})
armor:register_armor("3d_armor:chestplate_cactus", {
description = "Cactus Chestplate",
description = S("Cactus Chestplate"),
inventory_image = "3d_armor_inv_chestplate_cactus.png",
armor_groups = {fleshy=10},
groups = {armor_torso=1, armor_heal=0, armor_use=1000},
})
armor:register_armor("3d_armor:leggings_cactus", {
description = "Cactus Leggings",
description = S("Cactus Leggings"),
inventory_image = "3d_armor_inv_leggings_cactus.png",
armor_groups = {fleshy=5},
groups = {armor_legs=1, armor_heal=0, armor_use=1000},
})
armor:register_armor("3d_armor:boots_cactus", {
description = "Cactus Boots",
description = S("Cactus Boots"),
inventory_image = "3d_armor_inv_boots_cactus.png",
armor_groups = {fleshy=5},
groups = {armor_feet=1, armor_heal=0, armor_use=1000},
@ -103,25 +108,25 @@ end
if armor.materials.steel then
armor:register_armor("3d_armor:helmet_steel", {
description = "Steel Helmet",
description = S("Steel Helmet"),
inventory_image = "3d_armor_inv_helmet_steel.png",
armor_groups = {fleshy=10},
groups = {armor_head=1, armor_heal=0, armor_use=500},
})
armor:register_armor("3d_armor:chestplate_steel", {
description = "Steel Chestplate",
description = S("Steel Chestplate"),
inventory_image = "3d_armor_inv_chestplate_steel.png",
armor_groups = {fleshy=15},
groups = {armor_torso=1, armor_heal=0, armor_use=500},
})
armor:register_armor("3d_armor:leggings_steel", {
description = "Steel Leggings",
description = S("Steel Leggings"),
inventory_image = "3d_armor_inv_leggings_steel.png",
armor_groups = {fleshy=15},
groups = {armor_legs=1, armor_heal=0, armor_use=500},
})
armor:register_armor("3d_armor:boots_steel", {
description = "Steel Boots",
description = S("Steel Boots"),
inventory_image = "3d_armor_inv_boots_steel.png",
armor_groups = {fleshy=10},
groups = {armor_feet=1, armor_heal=0, armor_use=500},
@ -130,25 +135,25 @@ end
if armor.materials.bronze then
armor:register_armor("3d_armor:helmet_bronze", {
description = "Bronze Helmet",
description = S("Bronze Helmet"),
inventory_image = "3d_armor_inv_helmet_bronze.png",
armor_groups = {fleshy=10},
groups = {armor_head=1, armor_heal=6, armor_use=250},
})
armor:register_armor("3d_armor:chestplate_bronze", {
description = "Bronze Chestplate",
description = S("Bronze Chestplate"),
inventory_image = "3d_armor_inv_chestplate_bronze.png",
armor_groups = {fleshy=15},
groups = {armor_torso=1, armor_heal=6, armor_use=250},
})
armor:register_armor("3d_armor:leggings_bronze", {
description = "Bronze Leggings",
description = S("Bronze Leggings"),
inventory_image = "3d_armor_inv_leggings_bronze.png",
armor_groups = {fleshy=15},
groups = {armor_legs=1, armor_heal=6, armor_use=250},
})
armor:register_armor("3d_armor:boots_bronze", {
description = "Bronze Boots",
description = S("Bronze Boots"),
inventory_image = "3d_armor_inv_boots_bronze.png",
armor_groups = {fleshy=10},
groups = {armor_feet=1, armor_heal=6, armor_use=250},
@ -157,25 +162,25 @@ end
if armor.materials.diamond then
armor:register_armor("3d_armor:helmet_diamond", {
description = "Diamond Helmet",
description = S("Diamond Helmet"),
inventory_image = "3d_armor_inv_helmet_diamond.png",
armor_groups = {fleshy=15},
groups = {armor_head=1, armor_heal=12, armor_use=100},
})
armor:register_armor("3d_armor:chestplate_diamond", {
description = "Diamond Chestplate",
description = S("Diamond Chestplate"),
inventory_image = "3d_armor_inv_chestplate_diamond.png",
armor_groups = {fleshy=20},
groups = {armor_torso=1, armor_heal=12, armor_use=100},
})
armor:register_armor("3d_armor:leggings_diamond", {
description = "Diamond Leggings",
description = S("Diamond Leggings"),
inventory_image = "3d_armor_inv_leggings_diamond.png",
armor_groups = {fleshy=20},
groups = {armor_legs=1, armor_heal=12, armor_use=100},
})
armor:register_armor("3d_armor:boots_diamond", {
description = "Diamond Boots",
description = S("Diamond Boots"),
inventory_image = "3d_armor_inv_boots_diamond.png",
armor_groups = {fleshy=15},
groups = {armor_feet=1, armor_heal=12, armor_use=100},
@ -184,25 +189,25 @@ end
if armor.materials.gold then
armor:register_armor("3d_armor:helmet_gold", {
description = "Gold Helmet",
description = S("Gold Helmet"),
inventory_image = "3d_armor_inv_helmet_gold.png",
armor_groups = {fleshy=10},
groups = {armor_head=1, armor_heal=6, armor_use=250},
})
armor:register_armor("3d_armor:chestplate_gold", {
description = "Gold Chestplate",
description = S("Gold Chestplate"),
inventory_image = "3d_armor_inv_chestplate_gold.png",
armor_groups = {fleshy=15},
groups = {armor_torso=1, armor_heal=6, armor_use=250},
})
armor:register_armor("3d_armor:leggings_gold", {
description = "Gold Leggings",
description = S("Gold Leggings"),
inventory_image = "3d_armor_inv_leggings_gold.png",
armor_groups = {fleshy=15},
groups = {armor_legs=1, armor_heal=6, armor_use=250},
})
armor:register_armor("3d_armor:boots_gold", {
description = "Gold Boots",
description = S("Gold Boots"),
inventory_image = "3d_armor_inv_boots_gold.png",
armor_groups = {fleshy=10},
groups = {armor_feet=1, armor_heal=6, armor_use=250},
@ -211,25 +216,25 @@ end
if armor.materials.mithril then
armor:register_armor("3d_armor:helmet_mithril", {
description = "Mithril Helmet",
description = S("Mithril Helmet"),
inventory_image = "3d_armor_inv_helmet_mithril.png",
armor_groups = {fleshy=15},
groups = {armor_head=1, armor_heal=12, armor_use=50},
})
armor:register_armor("3d_armor:chestplate_mithril", {
description = "Mithril Chestplate",
description = S("Mithril Chestplate"),
inventory_image = "3d_armor_inv_chestplate_mithril.png",
armor_groups = {fleshy=20},
groups = {armor_torso=1, armor_heal=12, armor_use=50},
})
armor:register_armor("3d_armor:leggings_mithril", {
description = "Mithril Leggings",
description = S("Mithril Leggings"),
inventory_image = "3d_armor_inv_leggings_mithril.png",
armor_groups = {fleshy=20},
groups = {armor_legs=1, armor_heal=12, armor_use=50},
})
armor:register_armor("3d_armor:boots_mithril", {
description = "Mithril Boots",
description = S("Mithril Boots"),
inventory_image = "3d_armor_inv_boots_mithril.png",
armor_groups = {fleshy=15},
groups = {armor_feet=1, armor_heal=12, armor_use=50},
@ -238,25 +243,25 @@ end
if armor.materials.crystal then
armor:register_armor("3d_armor:helmet_crystal", {
description = "Crystal Helmet",
description = S("Crystal Helmet"),
inventory_image = "3d_armor_inv_helmet_crystal.png",
armor_groups = {fleshy=15},
groups = {armor_head=1, armor_heal=12, armor_use=50, armor_fire=1},
})
armor:register_armor("3d_armor:chestplate_crystal", {
description = "Crystal Chestplate",
description = S("Crystal Chestplate"),
inventory_image = "3d_armor_inv_chestplate_crystal.png",
armor_groups = {fleshy=20},
groups = {armor_torso=1, armor_heal=12, armor_use=50, armor_fire=1},
})
armor:register_armor("3d_armor:leggings_crystal", {
description = "Crystal Leggings",
description = S("Crystal Leggings"),
inventory_image = "3d_armor_inv_leggings_crystal.png",
armor_groups = {fleshy=20},
groups = {armor_legs=1, armor_heal=12, armor_use=50, armor_fire=1},
})
armor:register_armor("3d_armor:boots_crystal", {
description = "Crystal Boots",
description = S("Crystal Boots"),
inventory_image = "3d_armor_inv_boots_crystal.png",
armor_groups = {fleshy=15},
groups = {armor_feet=1, armor_heal=12, armor_use=50, physics_speed=1,

View File

@ -4,3 +4,4 @@ armor_monoid?
fire?
ethereal?
bakedclay?
intllib?

View File

@ -1,3 +1,7 @@
local S = function(s) return s end
if minetest.global_exists("intllib") then
S = intllib.Getter()
end
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local worldpath = minetest.get_worldpath()
@ -50,8 +54,11 @@ for material, _ in pairs(armor.materials) do
armor.materials[material] = nil
end
end
armor.formspec = armor.formspec..
"label[5,1;"..S("Level")..": armor_level]"..
"label[5,1.5;"..S("Heal")..": armor_attr_heal]"
if armor.config.fire_protect then
armor.formspec = armor.formspec.."label[5,2;Fire: armor_fire]"
armor.formspec = armor.formspec.."label[5,2;"..S("Fire")..": armor_fire]"
end
dofile(modpath.."/armor.lua")
@ -59,7 +66,8 @@ dofile(modpath.."/armor.lua")
-- Mod Compatibility
if minetest.get_modpath("technic") then
armor.formspec = armor.formspec.."label[5,2.5;Radiation: armor_group_radiation]"
armor.formspec = armor.formspec..
"label[5,2.5;"..S("Radiation")..": armor_group_radiation]"
armor:register_armor_group("radiation")
end
local skin_mods = {"skins", "u_skins", "simple_skins", "wardrobe"}
@ -282,7 +290,8 @@ minetest.register_on_player_hpchange(function(player, hp_change)
if stack:get_count() == 0 then
local desc = minetest.registered_items[item].description
if desc then
minetest.chat_send_player(name, "Your "..desc.." got destroyed!")
minetest.chat_send_player(name,
S("Your")..desc.." "..S("got destroyed").."!")
end
armor:set_player_armor(player)
armor:run_callbacks("on_unequip", player, stack)