mirror of
https://github.com/minetest-mods/technic.git
synced 2024-12-22 05:42:33 +01:00
Add translation support to technic_chests
This commit is contained in:
parent
5dd09aeff4
commit
179364ff8f
@ -2,4 +2,5 @@ default
|
|||||||
technic
|
technic
|
||||||
moreores
|
moreores
|
||||||
pipeworks
|
pipeworks
|
||||||
|
intllib?
|
||||||
|
|
||||||
|
@ -1,20 +1,3 @@
|
|||||||
local chest_mark_colors = {
|
|
||||||
'Black',
|
|
||||||
'Blue',
|
|
||||||
'Brown',
|
|
||||||
'Cyan',
|
|
||||||
'Dark Green',
|
|
||||||
'Dark Grey',
|
|
||||||
'Green',
|
|
||||||
'Grey',
|
|
||||||
'Magenta',
|
|
||||||
'Orange',
|
|
||||||
'Pink',
|
|
||||||
'Red',
|
|
||||||
'Violet',
|
|
||||||
'White',
|
|
||||||
'Yellow',
|
|
||||||
}
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'technic:gold_chest',
|
output = 'technic:gold_chest',
|
||||||
|
33
technic_chests/locale/template.txt
Normal file
33
technic_chests/locale/template.txt
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# technic_chests translation template
|
||||||
|
|
||||||
|
%s Chest =
|
||||||
|
%s Locked Chest =
|
||||||
|
%s Locked Chest (owned by %s) =
|
||||||
|
Color Filter: %s =
|
||||||
|
Edit chest description: =
|
||||||
|
|
||||||
|
# Colors
|
||||||
|
Black =
|
||||||
|
Blue =
|
||||||
|
Brown =
|
||||||
|
Byan =
|
||||||
|
Dark Green =
|
||||||
|
Dark Grey =
|
||||||
|
Green =
|
||||||
|
Grey =
|
||||||
|
Magenta =
|
||||||
|
Orange =
|
||||||
|
Pink =
|
||||||
|
Red =
|
||||||
|
Violet =
|
||||||
|
White =
|
||||||
|
Yellow =
|
||||||
|
None =
|
||||||
|
|
||||||
|
# Materials
|
||||||
|
Copper =
|
||||||
|
Gold =
|
||||||
|
Iron =
|
||||||
|
Mithril =
|
||||||
|
Silver =
|
||||||
|
|
@ -1,25 +1,33 @@
|
|||||||
|
|
||||||
|
|
||||||
|
local S
|
||||||
|
if intllib then
|
||||||
|
S = intllib.Getter()
|
||||||
|
else
|
||||||
|
S = function(s) return s end
|
||||||
|
end
|
||||||
|
|
||||||
local chest_mark_colors = {
|
local chest_mark_colors = {
|
||||||
'Black',
|
{"black", S("Black")},
|
||||||
'Blue',
|
{"blue", S("Blue")},
|
||||||
'Brown',
|
{"brown", S("Brown")},
|
||||||
'Cyan',
|
{"cyan", S("Byan")},
|
||||||
'Dark Green',
|
{"dark_green", S("Dark Green")},
|
||||||
'Dark Grey',
|
{"dark_grey", S("Dark Grey")},
|
||||||
'Green',
|
{"green", S("Green")},
|
||||||
'Grey',
|
{"grey", S("Grey")},
|
||||||
'Magenta',
|
{"magenta", S("Magenta")},
|
||||||
'Orange',
|
{"orange", S("Orange")},
|
||||||
'Pink',
|
{"pink", S("Pink")},
|
||||||
'Red',
|
{"red", S("Red")},
|
||||||
'Violet',
|
{"violet", S("Violet")},
|
||||||
'White',
|
{"white", S("White")},
|
||||||
'Yellow',
|
{"yellow", S("Yellow")},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
local function colorid_to_postfix(id)
|
local function colorid_to_postfix(id)
|
||||||
return (chest_mark_colors[id] and "_"..chest_mark_colors[id] or ""):lower():gsub(" ", "_")
|
return chest_mark_colors[id] and "_"..chest_mark_colors[id][1] or ""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -42,7 +50,7 @@ local function check_color_buttons(pos, meta, chest_name, fields)
|
|||||||
for i = 1, 16 do
|
for i = 1, 16 do
|
||||||
if fields["color_button"..i] then
|
if fields["color_button"..i] then
|
||||||
technic.swap_node(pos, chest_name..colorid_to_postfix(i))
|
technic.swap_node(pos, chest_name..colorid_to_postfix(i))
|
||||||
meta:set_string("color", chest_mark_colors[i])
|
meta:set_string("color", i)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -75,15 +83,21 @@ local function get_receive_fields(name, data)
|
|||||||
formspec = formspec.."image_button[2.1,0.1;0.8,0.8;"
|
formspec = formspec.."image_button[2.1,0.1;0.8,0.8;"
|
||||||
.."technic_checkmark_icon.png;save_infotext;]"
|
.."technic_checkmark_icon.png;save_infotext;]"
|
||||||
.."field[3.3,0.2;4.8,1;"
|
.."field[3.3,0.2;4.8,1;"
|
||||||
.."infotext_box;Edit chest description:;"
|
.."infotext_box;"..S("Edit chest description:")..";"
|
||||||
..formspec_infotext.."]"
|
..formspec_infotext.."]"
|
||||||
end
|
end
|
||||||
if data.color then
|
if data.color then
|
||||||
-- This sets the node
|
-- This sets the node
|
||||||
local nn = "technic:"..lname..(data.locked and "_locked" or "").."_chest"
|
local nn = "technic:"..lname..(data.locked and "_locked" or "").."_chest"
|
||||||
check_color_buttons(pos, meta, nn, fields)
|
check_color_buttons(pos, meta, nn, fields)
|
||||||
local color = meta:get_string("color")
|
local colorID = meta:get_int("color")
|
||||||
formspec = formspec.."label[8.2,9;Color Filter: "..color.."]"
|
local colorName
|
||||||
|
if chest_mark_colors[colorID] then
|
||||||
|
colorName = chest_mark_colors[colorID][2]
|
||||||
|
else
|
||||||
|
colorName = S("None")
|
||||||
|
end
|
||||||
|
formspec = formspec.."label[8.2,9;"..S("Color Filter: %s"):format(colorName).."]"
|
||||||
end
|
end
|
||||||
meta:set_string("formspec", formspec)
|
meta:set_string("formspec", formspec)
|
||||||
end
|
end
|
||||||
@ -92,6 +106,7 @@ end
|
|||||||
|
|
||||||
function technic.chests:register(name, data)
|
function technic.chests:register(name, data)
|
||||||
local lname = name:lower()
|
local lname = name:lower()
|
||||||
|
name = S(name)
|
||||||
|
|
||||||
local width = math.max(data.color and 11 or 8, data.width)
|
local width = math.max(data.color and 11 or 8, data.width)
|
||||||
|
|
||||||
@ -112,14 +127,22 @@ function technic.chests:register(name, data)
|
|||||||
locked_after_place = function(pos, placer)
|
locked_after_place = function(pos, placer)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("owner", placer:get_player_name() or "")
|
meta:set_string("owner", placer:get_player_name() or "")
|
||||||
meta:set_string("infotext", name.." Locked Chest (owned by "..
|
meta:set_string("infotext",
|
||||||
meta:get_string("owner")..")")
|
S("%s Locked Chest (owned by %s)")
|
||||||
|
:format(name, meta:get_string("owner")))
|
||||||
end
|
end
|
||||||
table.insert(front, "technic_"..lname.."_chest_lock_overlay.png")
|
table.insert(front, "technic_"..lname.."_chest_lock_overlay.png")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local desc
|
||||||
|
if data.locked then
|
||||||
|
desc = S("%s Locked Chest"):format(name)
|
||||||
|
else
|
||||||
|
desc = S("%s Chest"):format(name)
|
||||||
|
end
|
||||||
|
|
||||||
local def = {
|
local def = {
|
||||||
description = name..(data.locked and " Locked" or "").." Chest",
|
description = desc,
|
||||||
tiles = {"technic_"..lname.."_chest_top.png", "technic_"..lname.."_chest_top.png",
|
tiles = {"technic_"..lname.."_chest_top.png", "technic_"..lname.."_chest_top.png",
|
||||||
"technic_"..lname.."_chest_side.png", "technic_"..lname.."_chest_side.png",
|
"technic_"..lname.."_chest_side.png", "technic_"..lname.."_chest_side.png",
|
||||||
"technic_"..lname.."_chest_side.png", table.concat(front, "^")},
|
"technic_"..lname.."_chest_side.png", table.concat(front, "^")},
|
||||||
@ -135,7 +158,7 @@ function technic.chests:register(name, data)
|
|||||||
..(data.color and "label[8.2,9;Color Filter: None" or "")
|
..(data.color and "label[8.2,9;Color Filter: None" or "")
|
||||||
..(data.infotext and "image_button[2.1,0.1;0.8,0.8;"
|
..(data.infotext and "image_button[2.1,0.1;0.8,0.8;"
|
||||||
.."technic_pencil_icon.png;edit_infotext;]" or ""))
|
.."technic_pencil_icon.png;edit_infotext;]" or ""))
|
||||||
meta:set_string("infotext", name.." Chest")
|
meta:set_string("infotext", S("%s Chest"):format(name))
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("main", data.width * 4)
|
inv:set_size("main", data.width * 4)
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user