Add Italian locale
[minetest_doc_minetest_game.git] / init.lua
blob45315d62a86e342ba364da9ceca5832668e4ddf5
1 -- Boilerplate to support localized strings if intllib mod is installed.
2 local S
3 if minetest.get_modpath("intllib") then
4 S = intllib.Getter(minetest.get_current_modname())
5 else
6 S = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end
7 end
9 local groupdefs = {
10 ["book"] = S("Books"),
11 ["vessel"] = S("Vessels"),
12 ["dye"] = S("Dyes"),
13 ["stick"] = S("Sticks"),
14 ["wool"] = S("Wool"),
15 ["sand"] = S("Sand"),
16 ["wood"] = S("Wood"),
17 ["stone"] = S("Stones"),
18 ["metal"] = S("Metal"),
19 ["tree"] = S("Tree Trunks"),
20 ["fence"] = S("Fences"),
21 ["wall"] = S("Walls"),
22 ["leaves"] = S("Leaves and Needles"),
23 ["flower"] = S("Flowers"),
24 ["sapling"] = S("Saplings"),
25 ["water"] = S("Water"),
26 ["lava"] = S("Lava"),
27 ["coal"] = S("Coal"),
28 ["water_bucket"] = S("Water buckets"),
29 ["flora"] = S("Flora"),
30 ["snowy"] = S("Snowy"),
32 ["cracky"] = S("Cracky"),
33 ["crumbly"] = S("Crumbly"),
34 ["choppy"] = S("Choppy"),
35 ["snappy"] = S("Snappy"),
36 ["oddly_breakable_by_hand"] = S("Hand-breakable"),
38 ["fleshy"] = S("Flesh"),
41 local miscgroups = {
42 "book", -- for placing in bookshelf
43 "vessel", -- for placing in vessels shelf
44 "sand", -- for cactus growth ABM
45 "flora", -- for the plant spreading ABM
46 "sapling", -- for the sapling growth ABM
47 "water", -- for the obsidian and farming ABMs
50 local forced_items = {
51 "fire:basic_flame",
52 "farming:wheat_8",
53 "farming:cotton_8",
56 local suppressed_items = {
57 "default:water_flowing",
58 "default:river_water_flowing",
59 "default:lava_flowing",
60 "default:dry_grass_2",
61 "default:dry_grass_3",
62 "default:dry_grass_4",
63 "default:dry_grass_5",
64 "default:grass_2",
65 "default:grass_3",
66 "default:grass_4",
67 "default:grass_5",
68 "default:furnace_active",
69 "doors:door_wood",
70 "doors:door_steel",
71 "doors:door_glass",
72 "doors:door_obsidian_glass",
73 "doors:door_wood_a",
74 "doors:door_steel_a",
75 "doors:door_glass_a",
76 "doors:door_obsidian_glass_a",
77 "doors:door_wood_b",
78 "doors:door_steel_b",
79 "doors:door_glass_b",
80 "doors:door_obsidian_glass_b",
81 "doors:gate_wood_open",
82 "doors:gate_junglewood_open",
83 "doors:gate_acacia_wood_open",
84 "doors:gate_aspen_wood_open",
85 "doors:gate_pine_wood_open",
86 "doors:trapdoor_steel_open",
87 "doors:trapdoor_open",
88 "doors:hidden",
89 "xpanes:pane",
90 "xpanes:obsidian_pane",
91 "xpanes:bar",
92 "default:chest_open",
93 "default:chest_locked_open",
96 local hidden_items = {
97 "default:cloud",
98 "default:dirt_with_grass_footsteps",
101 local item_name_overrides = {
102 ["screwdriver:screwdriver"] = S("Screwdriver"),
103 ["map:mapping_kit"] = S("Mapping Kit"),
104 ["binoculars:binoculars"] = S("Binoculars"),
105 ["carts:cart"] = S("Cart"),
106 ["fire:basic_flame"] = S("Basic Flame"),
107 ["farming:wheat_8"] = S("Wheat Plant"),
108 ["farming:cotton_8"] = S("Cotton Plant"),
109 ["default:lava_source"] = S("Lava"),
110 ["default:water_source"] = S("Water"),
111 ["default:river_water_source"] = S("River Water"),
112 ["doors:door_wood_a"] = minetest.registered_items["doors:door_wood"].description,
113 ["doors:door_steel_a"] = minetest.registered_items["doors:door_steel"].description,
114 ["doors:door_glass_a"] = minetest.registered_items["doors:door_glass"].description,
115 ["doors:door_obsidian_glass_a"] = minetest.registered_items["doors:door_obsidian_glass"].description,
118 local image_overrides = {
119 ["doors:door_wood_a"] = minetest.registered_items["doors:door_wood"].inventory_image,
120 ["doors:door_steel_a"] = minetest.registered_items["doors:door_steel"].inventory_image,
121 ["doors:door_glass_a"] = minetest.registered_items["doors:door_glass"].inventory_image,
122 ["doors:door_obsidian_glass_a"] = minetest.registered_items["doors:door_obsidian_glass"].inventory_image,
125 doc.sub.items.add_friendly_group_names(groupdefs)
126 doc.sub.items.add_notable_groups(miscgroups)
128 for i=1, #hidden_items do
129 local item = minetest.registered_items[hidden_items[i]]
130 if item then
131 minetest.override_item(hidden_items[i], { _doc_items_hidden = true } )
134 for i=1, #forced_items do
135 local item = minetest.registered_items[forced_items[i]]
136 if item then
137 minetest.override_item(forced_items[i], { _doc_items_create_entry = true} )
140 for i=1, #suppressed_items do
141 local item = minetest.registered_items[suppressed_items[i]]
142 if item then
143 minetest.override_item(suppressed_items[i], { _doc_items_create_entry = false} )
146 for itemstring, data in pairs(item_name_overrides) do
147 if minetest.registered_items[itemstring] ~= nil then
148 minetest.override_item(itemstring, { _doc_items_entry_name = data} )
151 for itemstring, data in pairs(image_overrides) do
152 if minetest.registered_items[itemstring] ~= nil then
153 minetest.override_item(itemstring, { _doc_items_image = data} )
157 -- Minetest Game Factoids
159 -- Lava cooling
160 local function f_cools_lava(itemstring, def)
161 if def.groups.cools_lava ~= nil or def.groups.water ~= nil then
162 return S("This block turns adjacent lava sources into obsidian and adjacent flowing lava into stone.")
163 else
164 return ""
168 -- Groups flammable, puts_out_fire
169 local function f_fire(itemstring, def)
170 local s = ""
171 -- Fire
172 if def.groups.flammable ~= nil then
173 s = s .. S("This block is flammable.")
176 if def.groups.puts_out_fire ~= nil then
177 if def.groups.flammable ~= nil then
178 s = s .. "\n"
180 s = s .. S("This block will extinguish nearby fire.")
183 if def.groups.igniter ~= nil then
184 if def.groups.flammable ~= nil or def.groups.puts_out_fire ~= nil then
185 s = s .. "\n"
187 s = s .. S("This block will set flammable blocks within a radius of @1 on fire.", def.groups.igniter)
188 if def.walkable == false then
189 s = s .. S(" It also destroys flammable items which have been dropped inside.")
192 return s
195 -- flora group
196 local function f_flora(itemstring, def)
197 if def.groups.flora == 1 then
198 local groupname = doc.sub.items.get_group_name("flora")
199 -- Dry shrub rule not complete; flora dies on group:sand except default:sand. But that's okay.
200 -- The missing nodes will be covered on their own entries by the f_and_dry_shrub factoid.
201 return S("This block belongs to the @1 group. It a living organism which likes to grow and spread on dirt with grass and similar “soil”-type blocks when it is in light. Spreading will stop when the surrounding area is too crammed with @2 blocks. On silver sand and desert sand, it will wither and die and turn into a dry shrub.", groupname, groupname)
202 else
203 return ""
207 -- sand nodes which turn flora blocks into dry shrub (e.g. silver sand, desert sand)
208 local function f_sand_dry_shrub(itemstring, def)
209 if def.groups.sand == 1 and itemstring ~= "default:sand" then
211 return S("Flowers and other blocks in the @1 group will slowly turn into dry shrubs when placed on this block.", doc.sub.items.get_group_name("flora"))
212 else
213 return ""
217 -- soil group
218 local function f_soil(itemstring, def)
219 if def.groups.soil == 1 then
220 return S("This block serves as a soil for saplings and small plants. Blocks in the “@1” group will grow into trees. Blocks in the “@2” group will spread slowly.", doc.sub.items.get_group_name("sapling"), doc.sub.items.get_group_name("flora"))
221 elseif def.groups.soil == 2 or def.groups.soil == 3 then
222 return S("This block serves as a soil for saplings and other small plants as well as plants grown from seeds. It supports their growth.")
223 else
224 return ""
228 local function f_leafdecay(itemstring, def)
229 local formstring = ""
230 if def.groups.leafdecay ~= nil then
231 if def.groups.leafdecay_drop ~= nil then
232 formstring = S("This block may drop as an item when there is no trunk or stem of its species within a distance of @1. Leaf decay does not occour when the block has been manually placed by a player.", def.groups.leafdecay)
233 else
234 if def.drop ~= "" and def.drop ~= nil and def.drop ~= itemstring then
235 formstring = S("This block quickly decays when there is no trunk or stem block of its species within a distance of @1. When decaying, it disappears and may drop one of its mining drops (but not itself). The block does not decay when the block has been placed by a player.", def.groups.leafdecay)
236 else
237 formstring = S("This block quickly decays and disappears when there is no trunk or stem block of its species within a distance of @1. The block does not decay when the block has been placed by a player.", def.groups.leafdecay)
241 return formstring
244 local function f_spreading_dirt_type(itemstring, def)
245 if def.groups.spreading_dirt_type then
246 return S("Under sunlight, this block slowly spreads its dirt cover towards nearby dirt blocks. In the shadows, this block eventually loses its dirt cover and turns into plain dirt.")
247 else
248 return ""
252 local function f_hoe_soil(itemstring, def)
253 if def.soil then
254 local name, node
255 nodedef = minetest.registered_nodes[def.soil.dry]
256 if nodedef then
257 name = nodedef.description
259 if name then
260 return S("This block can be turned into @1 with a hoe.", name)
261 else
262 return S("This block can be cultivated by a hoe.")
264 else
265 return ""
269 --[[ Node defines skeleton key and key callbacks which probably implies that
270 it can be unlocked by keys ]]
271 local function f_key(itemstring, def)
272 if def.on_key_use and def.on_skeleton_key_use then
273 return S("This block is compatible with keys.")
274 else
275 return ""
279 doc.sub.items.register_factoid("nodes", "use", f_key)
280 doc.sub.items.register_factoid("nodes", "use", f_hoe_soil)
281 doc.sub.items.register_factoid("nodes", "groups", f_cools_lava)
282 doc.sub.items.register_factoid("nodes", "groups", f_fire)
283 doc.sub.items.register_factoid("nodes", "groups", f_flora)
284 doc.sub.items.register_factoid("nodes", "groups", f_sand_dry_shrub)
285 doc.sub.items.register_factoid("nodes", "groups", f_leafdecay)
286 doc.sub.items.register_factoid("nodes", "groups", f_soil)
287 doc.sub.items.register_factoid("nodes", "groups", f_spreading_dirt_type)
289 -- Add node aliases
290 for i=2,5 do
291 doc.add_entry_alias("nodes", "default:grass_1", "nodes", "default:grass_"..i)
292 doc.add_entry_alias("nodes", "default:dry_grass_1", "nodes", "default:dry_grass_"..i)
294 for i=1,7 do
295 doc.add_entry_alias("nodes", "farming:wheat_8", "nodes", "farming:wheat_"..i)
296 doc.add_entry_alias("nodes", "farming:cotton_8", "nodes", "farming:cotton_"..i)
298 doc.add_entry_alias("nodes", "default:lava_source", "nodes", "default:lava_flowing")
299 doc.add_entry_alias("nodes", "default:water_source", "nodes", "default:water_flowing")
300 doc.add_entry_alias("nodes", "default:river_water_source", "nodes", "default:river_water_flowing")
301 doc.add_entry_alias("nodes", "default:furnace", "nodes", "default:furnace_active")
302 doc.add_entry_alias("nodes", "default:torch", "nodes", "default:torch_wall")
303 doc.add_entry_alias("nodes", "default:torch", "nodes", "default:torch_ceiling")
304 doc.add_entry_alias("nodes", "doors:door_wood_fake", "craftitems", "doors:door_wood")
305 doc.add_entry_alias("nodes", "doors:door_steel_fake", "craftitems", "doors:door_steel")
306 doc.add_entry_alias("nodes", "doors:door_glass_fake", "craftitems", "doors:door_glass")
307 doc.add_entry_alias("nodes", "doors:door_obsidian_glass_fake", "craftitems", "doors:door_obsidian_glass")
308 doc.add_entry_alias("nodes", "doors:door_wood_fake", "nodes", "doors:door_wood_a")
309 doc.add_entry_alias("nodes", "doors:door_steel_fake", "nodes", "doors:door_steel_a")
310 doc.add_entry_alias("nodes", "doors:door_glass_fake", "nodes", "doors:door_glass_a")
311 doc.add_entry_alias("nodes", "doors:door_obsidian_glass_fake", "nodes", "doors:door_obsidian_glass_a")
312 doc.add_entry_alias("nodes", "doors:door_wood_fake", "nodes", "doors:door_wood_b")
313 doc.add_entry_alias("nodes", "doors:door_steel_fake", "nodes", "doors:door_steel_b")
314 doc.add_entry_alias("nodes", "doors:door_glass_fake", "nodes", "doors:door_glass_b")
315 doc.add_entry_alias("nodes", "doors:door_obsidian_glass_fake", "nodes", "doors:door_obsidian_glass_b")
316 doc.add_entry_alias("nodes", "doors:gate_wood_closed", "nodes", "doors:gate_wood_open")
317 doc.add_entry_alias("nodes", "doors:gate_junglewood_closed", "nodes", "doors:gate_junglewood_open")
318 doc.add_entry_alias("nodes", "doors:gate_acacia_wood_closed", "nodes", "doors:gate_acacia_wood_open")
319 doc.add_entry_alias("nodes", "doors:gate_aspen_wood_closed", "nodes", "doors:gate_aspen_wood_open")
320 doc.add_entry_alias("nodes", "doors:gate_pine_wood_closed", "nodes", "doors:gate_pine_wood_open")
321 doc.add_entry_alias("nodes", "doors:trapdoor", "nodes", "doors:trapdoor_open")
322 doc.add_entry_alias("nodes", "doors:trapdoor_steel", "nodes", "doors:trapdoor_steel_open")
323 doc.add_entry_alias("nodes", "tnt:tnt", "nodes", "tnt:tnt_burning")
324 doc.add_entry_alias("nodes", "tnt:gunpowder", "nodes", "tnt:gunpowder_burning")
325 doc.add_entry_alias("nodes", "xpanes:pane_flat", "nodes", "xpanes:pane")
326 doc.add_entry_alias("nodes", "xpanes:obsidian_pane_flat", "nodes", "xpanes:obsidian_pane")
327 doc.add_entry_alias("nodes", "xpanes:bar_flat", "nodes", "xpanes:bar")
328 doc.add_entry_alias("nodes", "default:chest", "nodes", "default:chest_open")
329 doc.add_entry_alias("nodes", "default:chest_locked", "nodes", "default:chest_locked_open")
331 -- Gather help texts
332 dofile(minetest.get_modpath("doc_minetest_game") .. "/helptexts.lua")
334 -- Register boat object for doc_identifier
335 if minetest.get_modpath("doc_identifier") ~= nil then
336 doc.sub.identifier.register_object("boats:boat", "craftitems", "boats:boat")
337 doc.sub.identifier.register_object("carts:cart", "craftitems", "carts:cart")
341 --[[ Completely create door entries from scratch. We suppressed all normal door entries
342 before. This is quite a hack, but required because of the weird way how door items are
343 implemented in Minetest Game.
344 CHECKME: As doors are sensitive, check this entire section after each Minetest Game release.
347 local doors = { "doors:door_wood", "doors:door_steel", "doors:door_glass", "doors:door_obsidian_glass" }
349 for d=1, #doors do
350 local door = doors[d]
351 local def1 = table.copy(minetest.registered_items[door])
352 local def2 = table.copy(minetest.registered_items[door.."_a"])
354 def2._doc_items_image = def1.inventory_image
355 def2.drop = nil
356 def2.stack_max = def1.stack_max or minetest.nodedef_default.stack_max
357 def2.liquidtype = "none"
358 def2._doc_items_longdesc = def1._doc_items_longdesc
359 def2._doc_items_usagehelp = def1._doc_items_usagehelp
361 doc.add_entry("nodes", door.."_fake", {
362 name = def2.description,
363 hidden = def2._doc_items_hidden == true,
364 data = {
365 itemstring = door,
366 longdesc = def2._doc_items_longdesc,
367 usagehelp = def2._doc_items_usagehelp,
368 def = def2
373 -- Remove the superficial “help” comment from screwdriver and cart description as redundant
374 minetest.override_item("screwdriver:screwdriver", {description = item_name_overrides["screwdriver:screwdriver"]})
375 minetest.override_item("carts:cart", {description = item_name_overrides["carts:cart"]})