summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2016-11-17 23:57:45 +0100
committerWuzzy <almikes@aol.com>2016-11-17 23:57:45 +0100
commit32b0f7d0a19a3a93f6c3db0dd6bbb472cee25e3a (patch)
treebe80b742744cc4c008276ed618180b5fdbc96012
parentf280d7a3845c5d4d1b8db2c9b84de1895f4d88e0 (diff)
Use new inttlib format strings, fix intllib+security crash
-rw-r--r--helptexts.lua39
-rw-r--r--init.lua13
2 files changed, 25 insertions, 27 deletions
diff --git a/helptexts.lua b/helptexts.lua
index 741d053..7768e72 100644
--- a/helptexts.lua
+++ b/helptexts.lua
@@ -7,10 +7,9 @@
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if minetest.get_modpath("intllib") then
- dofile(minetest.get_modpath("intllib").."/intllib.lua")
- S = intllib.Getter(minetest.get_current_modname())
+ S = intllib.Getter()
else
- S = function(s) return s end
+ S = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end
end
local basicflametext
@@ -79,7 +78,7 @@ if tnt_radius == nil then
tnt_radius = 3
end
-local tntdesc = string.format(S("An explosive device. When it explodes, it will hurt living beings, destroy blocks around it, throw blocks affected by gravity all over the place and set flammable blocks on fire. It has an explosion radius of %d. With a small chance, blocks may drop as an item (as if being mined) rather than being destroyed. TNT can be ignited by explosions and fire. Initially, TNT is not affected by gravity, but as soon it has been ignited, it is."), tnt_radius)
+local tntdesc = S("An explosive device. When it explodes, it will hurt living beings, destroy blocks around it, throw blocks affected by gravity all over the place and set flammable blocks on fire. It has an explosion radius of @1. With a small chance, blocks may drop as an item (as if being mined) rather than being destroyed. TNT can be ignited by explosions and fire. Initially, TNT is not affected by gravity, but as soon it has been ignited, it is.", tnt_radius)
local nyandesc = S("A weird creature with a cat face, cat extremities and a strawberry-flavored pop-tart body. It has been trapped in a block and cannot move and can thus be dug easily by simple tools. Nyan cats are usually followed by nyan cat rainbows. Legends say that in ancient times, long before the creation of our world, there were many of the Nyan Cats which were free and flew through space and sang the \"Nya-nya\" song. Nowadays, nyan cats serve as a fancy collector's item and are traded as souveniers. Apart from that, nyan cats have no intrinsic value.")
local rainbowdesc = S("A rainbow made by a real nyan cat, ancient creatures which once flew through space. It has gone inert and can be dug by simple tools. Like nyan cats, nyan cat rainbows have no intrinsic value.")
@@ -115,7 +114,7 @@ local export_longdesc = {
["default:ice"] = S("Ice is found in arctic regions. It can appear either in huge glacier formations below snow blocks, or above water."),
["default:dirt"] = S("Dirt is found often directly under the surface and very common in many regions of the world. When exposed to sunlight, the surface of dirt may change, depending on its neighbors. It can be turned into soil for farming with a hoe."),
["default:sand"] = S("Sand is found in large quantities at beaches, but it occacionally appears in small chunks around the world."),
- ["default:desert_sand"] = string.format(S("Usually found in huge quantities at the surface of deserts. Members of the %s group will slowly turn into dry shrubs when placed on desert sand. Desert sand can be turned into desert sand soil with a hoe."), groupname_flora),
+ ["default:desert_sand"] = S("Usually found in huge quantities at the surface of deserts. Members of the @1 group will slowly turn into dry shrubs when placed on desert sand. Desert sand can be turned into desert sand soil with a hoe.", groupname_flora),
["default:gravel"] = S("This block consists of a couple of loose stones and can't support itself. It is common only at the beaches of very cold regions, but it can be found in small quantities on the surface and underground."),
["default:clay"] = S("Clay is a rather soft material and it sometimes found in sand beaches."),
["default:sandstone"] = S("A pretty soft kind of stone. It is common below the surface of some grassland biomes."),
@@ -146,8 +145,8 @@ local export_longdesc = {
["default:acacia_leaves"] = S("Acacia leaves are grown from acacia trees found in savannahs."),
["default:aspen_leaves"] = S("Aspen leaves are grown from aspen trees found in deciduous forests."),
["default:pine_needles"] = S("Pine needles are grown from pine trees found in coniferous forests."),
- ["default:cactus"] = string.format(S("A piece of cactus usually found in deserts. Cacti grow on sand, desert sand and other blocks belonging to the “%s” group and can reach a height of up to 4 cactus blocks."), groupname_sand),
- ["default:papyrus"] = string.format(S("A papyrus piece usually found near shallow water. Papyrus grows vertically on dirt and dirt with grass near a water source (or another block belonging to the %s group) and can reach a height of up to 4 blocks. When dug, all papyrus blocks directly connected above it will also be dug."), groupname_water),
+ ["default:cactus"] = S("A piece of cactus usually found in deserts. Cacti grow on sand, desert sand and other blocks belonging to the “@1” group and can reach a height of up to 4 cactus blocks.", groupname_sand),
+ ["default:papyrus"] = S("A papyrus piece usually found near shallow water. Papyrus grows vertically on dirt and dirt with grass near a water source (or another block belonging to the @1 group) and can reach a height of up to 4 blocks. When dug, all papyrus blocks directly connected above it will also be dug.", groupname_water),
["default:bookshelf"] = S("A bookshelf provides 16 inventory slots for books."),
["default:glass"] = S("A decorational and mostly transparent block which is rather easy to break."),
["default:fence_wood"] = fencedesc,
@@ -161,13 +160,13 @@ local export_longdesc = {
["doors:gate_pine_wood_closed"] = fencegatedesc,
["doors:gate_aspen_wood_closed"] = fencegatedesc,
- ["default:dry_shrub"] = string.format(S("An unremarkable dead plant which is common in deserts and snowy biomes. Small plants which are members of the %s group placed on desert sand will sooner or later turn into dry shrubs."), groupname_flora),
+ ["default:dry_shrub"] = S("An unremarkable dead plant which is common in deserts and snowy biomes. Small plants which are members of the @1 group placed on desert sand will sooner or later turn into dry shrubs.", groupname_flora),
["default:rail"] = S("Railroad tracks. Place these on the ground to build your railway, the blocks will automatically connect to each other and will turn into curves, junctions, crossings and slopes as needed."),
["default:ladder_wood"] = ladderdesc,
["default:ladder_steel"] = ladderdesc,
["default:water_source"] = S("Water is abundant in oceans and may also appear in small quantities in underground water pockets. You can swim easily in water, but you need to catch your breath from time to time. Water will turn nearby lava into obsidian or stone."),
["default:river_water_source"] = S("You can swim easily in river water, but you need to catch your breath from time to time. Unlike (normal) water, it appears in rivers only. River water will turn nearby lava into obsidian or stone."),
- ["default:lava_source"] = string.format(S("Lava is found deep underground (%d and below) and rather dangerous. Don't touch it, it will hurt you a lot and once you're in, it is hard to get out. When a lava source meets water or river water (or another block in the %s group), it turns into obsidian. Flowing lava turns into stone instead."), lavaheight, groupname_water),
+ ["default:lava_source"] = S("Lava is found deep underground (@1 and below) and rather dangerous. Don't touch it, it will hurt you a lot and once you're in, it is hard to get out. When a lava source meets water or river water (or another block in the @2 group), it turns into obsidian. Flowing lava turns into stone instead.", lavaheight, groupname_water),
["default:torch"] = S("Provides plenty of light. It can be placed on almost any block facing any direction."),
["default:sign_wall_wood"] = signdesc,
["default:sign_wall_steel"] = signdesc,
@@ -182,7 +181,7 @@ local export_longdesc = {
["default:goldblock"] = deconode,
["default:diamondblock"] = S("A very hard decorational block."),
["default:obsidian_glass"] = S("Obsidian glass is transparent, has a very clean surface and is rather hard to break."),
- ["default:obsidian"] = string.format(S("A hard mineral which is created from a lava source when it meets water (any block in the %s group)."), groupname_water),
+ ["default:obsidian"] = S("A hard mineral which is created from a lava source when it meets water (any block in the @1 group).", groupname_water),
["default:obsidianbrick"] = buildnode,
-- 0.4.14 Nyan Cats (for compability)
@@ -399,23 +398,23 @@ if bonestime2 == nil then bonestime2 = math.floor(bonestime / 4) end
if bonestime == 0 then
bonesstring = S("In this world this can be done without any delay as the bones instantly become old. ")
elseif bonestime % 60 == 0 then
- bonestime_s = string.format(S("%d min"), bonestime/60)
+ bonestime_s = S("@1 min", bonestime/60)
else
- bonestime_s = string.format(S("%d min %d s"), bonestime/60, bonestime%60)
+ bonestime_s = S("@1 min @2 s", bonestime/60, bonestime%60)
end
if bonestime2 == 0 then
bonesstring2 = ""
elseif bonestime2 % 60 == 0 then
- bonestime2_s = string.format(S("%d min"), bonestime2/60)
+ bonestime2_s = S("@1 min", bonestime2/60)
else
- bonestime2_s = string.format(S("%d min %d s"), bonestime2/60, bonestime2 % 60)
+ bonestime2_s = S("@1 min @2 s", bonestime2/60, bonestime2 % 60)
end
if bonestime ~= 0 then
- bonesstring = string.format(S("If these are not your bones, you have to wait %s before you can do this. "), bonestime_s)
+ bonesstring = S("If these are not your bones, you have to wait @1 before you can do this. ", bonestime_s)
end
if bonestime2 ~= 0 then
- bonesstring2 = string.format(S("If the player died in a protected area of someone else, the bones can be dug after %s."), bonestime2_s)
+ bonesstring2 = S("If the player died in a protected area of someone else, the bones can be dug after @1.", bonestime2_s)
end
local export_usagehelp = {
@@ -436,8 +435,8 @@ local export_usagehelp = {
["default:book_written"] = S("Hold the book with text in hand and leftclick to read or change the notes. The text in a book with text can be transferred to a book (without text) by a special crafting recipe: Just place the book with text and a book into the crafting grid."),
["default:sign_wall_wood"] = signuse,
["default:sign_wall_steel"] = signuse,
- ["default:bookshelf"] = string.format(S("Rightclick to open the bookshelf. You can only store books and other items belonging to the %s group into the bookshelf. To collect the bookshelf, you must make sure it does not contain anything."), groupname_book),
- ["vessels:shelf"] = string.format(S("Rightclick to open the vessels shelf. You can only store items which belong to the %s group (glass bottle, drinking glass, heavy steel bottle). To collect the vessels shelf, it must be empty."), groupname_vessel),
+ ["default:bookshelf"] = S("Rightclick to open the bookshelf. You can only store books and other items belonging to the @1 group into the bookshelf. To collect the bookshelf, you must make sure it does not contain anything.", groupname_book),
+ ["vessels:shelf"] = S("Rightclick to open the vessels shelf. You can only store items which belong to the @1 group (glass bottle, drinking glass, heavy steel bottle). To collect the vessels shelf, it must be empty.", groupname_vessel),
["bucket:bucket_empty"] = S("Punch a liquid source to collect the liquid. With the filled bucket, you can rightclick somewhere to empty the bucket which will create a liquid source at the position you've clicked at."),
["bucket:bucket_water"] = S("Rightclick on any block to empty the bucket and put a water source on this spot."),
["bucket:bucket_river_water"] = S("Rightclick on any block to empty the bucket and put a river water source on this spot."),
@@ -458,14 +457,14 @@ local export_usagehelp = {
["screwdriver:screwdriver"] = S("Leftclick on a block to rotate it around its current axis. Rightclick on a block to rotate its axis. Note that not all blocks can be rotated."),
- ["boats:boat"] = string.format(S("Place the boat on water (any block belonging to the %s group) to set it up. Rightclick the boat to enter it. When you are on the boat, use the forward key to speed up, the backward key to slow down and the left and right keys to turn the boat. Rightclick on the boat again to leave it. Leftclick the placed boat to collect it."), groupname_water),
+ ["boats:boat"] = S("Place the boat on water (any block belonging to the @1 group) to set it up. Rightclick the boat to enter it. When you are on the boat, use the forward key to speed up, the backward key to slow down and the left and right keys to turn the boat. Rightclick on the boat again to leave it. Leftclick the placed boat to collect it.", groupname_water),
["beds:bed_bottom"] = beduse,
["beds:fancy_bed_bottom"] = beduse,
["farming:seed_wheat"] = S("Place the wheat seed on soil or wet soil. Use a hoe to create soil. The plant will only grow in sunlight and as long as the soil is wet. Watch the wheat plant grow and mine it at its full size."),
["farming:seed_cotton"] = S("Place the cotton seed on soil, wet soil, desert sand soil or wet desert sand soil. Use a hoe to create soil. The plant will only grow in sunlight and as long as the soil is wet. Watch the cotton plant grow and mine it at its full size."),
["fire:flint_and_steel"] = S("Punch with it on the surface of a flammable block to create a basic flame in front of it. A basic flame can only be created inside air."),
- ["flowers:waterlily"] = string.format(S("Waterlilies can only be placed on water sources (and other members of the %s group)."), groupname_water),
+ ["flowers:waterlily"] = S("Waterlilies can only be placed on water sources (and other members of the @1 group).", groupname_water),
["farming:hoe_wood"] = hoeuse,
["farming:hoe_stone"] = hoeuse,
["farming:hoe_steel"] = hoeuse,
diff --git a/init.lua b/init.lua
index 3a5ea1c..29a01bd 100644
--- a/init.lua
+++ b/init.lua
@@ -1,10 +1,9 @@
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if minetest.get_modpath("intllib") then
- dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
- S = function(s) return s end
+ S = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end
end
local groupdefs = {
@@ -170,7 +169,7 @@ local function f_fire(itemstring, def)
if def.groups.flammable ~= nil or def.groups.puts_out_fire ~= nil then
s = s .. "\n"
end
- s = s .. string.format(S("This block will set flammable blocks within a radius of %d on fire."), def.groups.igniter)
+ s = s .. S("This block will set flammable blocks within a radius of @1 on fire.", def.groups.igniter)
end
return s
end
@@ -179,7 +178,7 @@ end
local function f_flora(itemstring, def)
if def.groups.flora == 1 then
local groupname = doc.sub.items.get_group_name("flora")
- return string.format(S("This block belongs to the %s group. It a living organism which likes to grow and spread on dirt with grass or dirt with dry grass when it is in light. Spreading will stop when the surrounding area is too crammed with %s blocks. On desert sand, it will wither and die and turn into a dry shrub."), groupname, groupname)
+ return S("This block belongs to the @1 group. It a living organism which likes to grow and spread on dirt with grass or dirt with dry grass when it is in light. Spreading will stop when the surrounding area is too crammed with @2 blocks. On desert sand, it will wither and die and turn into a dry shrub.", groupname, groupname)
else
return ""
end
@@ -201,12 +200,12 @@ local function f_leafdecay(itemstring, def)
if def.groups.leafdecay ~= nil then
local groupname = doc.sub.items.get_group_name("tree")
if def.groups.leafdecay_drop ~= nil then
- formstring = string.format(S("This block may drop as an item when no trunk is nearby. This is prevented if any block of the group “%s” is nearby (up to a distance of %d), the block is completely surrounded by blocks which are neither air or a liquid or it has been manually placed by a player."), groupname, def.groups.leafdecay)
+ formstring = S("This block may drop as an item when no trunk is nearby. This is prevented if any block of the group “@1” is nearby (up to a distance of @2), the block is completely surrounded by blocks which are neither air or a liquid or it has been manually placed by a player.", groupname, def.groups.leafdecay)
else
if def.drop ~= "" and def.drop ~= nil and def.drop ~= itemstring then
- formstring = string.format(S("This block may decay when no trunk is nearby. When decaying, it disappears and may drop one of its mining drops (but never itself). Decay is prevented if any block of the group “%s” is nearby (up to a distance of %d), the block is completely surrounded by blocks which are neither air or a liquid or it has been placed by a player."), groupname, def.groups.leafdecay)
+ formstring = S("This block may decay when no trunk is nearby. When decaying, it disappears and may drop one of its mining drops (but never itself). Decay is prevented if any block of the group “@1” is nearby (up to a distance of @2), the block is completely surrounded by blocks which are neither air or a liquid or it has been placed by a player.", groupname, def.groups.leafdecay)
else
- formstring = string.format(S("This block may decay and disappear when no trunk is nearby. Decay is prevented if any block of the group “%s” is nearby (up to a distance of %d), the block is completely surrounded by blocks which are neither air or a liquid or it has been placed by a player."), groupname, def.groups.leafdecay)
+ formstring = S("This block may decay and disappear when no trunk is nearby. Decay is prevented if any block of the group “@1” is nearby (up to a distance of @2), the block is completely surrounded by blocks which are neither air or a liquid or it has been placed by a player.", groupname, def.groups.leafdecay)
end
end
end