summaryrefslogtreecommitdiff
path: root/init.lua
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 /init.lua
parentf280d7a3845c5d4d1b8db2c9b84de1895f4d88e0 (diff)
Use new inttlib format strings, fix intllib+security crash
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua13
1 files changed, 6 insertions, 7 deletions
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