1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2025-07-01 16:00:23 +02:00

added intllib support (en/de)

This commit is contained in:
TenPlus1
2016-06-11 09:47:43 +01:00
parent 093b8c9eed
commit db7e02af1a
6 changed files with 131 additions and 29 deletions

53
api.lua
View File

@ -4,8 +4,29 @@
mobs = {}
mobs.mod = "redo"
-- Invisibility mod
-- Intllib
local S
if minetest.get_modpath("intllib") then
S = intllib.Getter()
else
S = function(s, a, ...)
if a == nil then
return s
end
a = {a, ...}
return s:gsub("(@?)@(%(?)(%d+)(%)?)",
function(e, o, n, c)
if e == "" then
return a[tonumber(n)] .. (o == "" and c or "")
else
return "@" .. o .. n .. c
end
end)
end
end
mobs.intllib = S
-- Invisibility mod
local invisibility = invisibility or {}
-- Load settings
@ -1769,7 +1790,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
-- error checking when mod profiling is enabled
if not tool_capabilities then
print ("[MOBS] mod profiling enabled, damage not enabled")
print (S("[MOBS] mod profiling enabled, damage not enabled"))
return
end
@ -2079,7 +2100,7 @@ local mob_step = function(self, dtime)
end
minetest.log("action",
"lifetimer expired, removed " .. self.name)
S("lifetimer expired, removed @1", self.name))
effect(pos, 15, "tnt_smoke.png")
@ -2336,13 +2357,13 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
if new_chance ~= nil then
if new_chance == 0 then
print("[Mobs Redo] " .. name .. " has spawning disabled")
print(S("[Mobs Redo] @1 has spawning disabled", name))
return
end
chance = new_chance
print ("[Mobs Redo] Chance setting for " .. name .. " changed to " .. chance)
print (S("[Mobs Redo] Chance setting for @1 changed to @2", name, chance))
end
@ -2430,8 +2451,8 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
-- .. minetest.pos_to_string(pos) .. " on "
-- .. node.name .. " near " .. neighbors[1])
else
print ("[mobs]" .. name .. " failed to spawn at "
.. minetest.pos_to_string(pos))
print (S("[mobs] @1 failed to spawn at @2",
name, minetest.pos_to_string(pos)))
end
end
@ -2711,7 +2732,7 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
if self.tamed == false
and force_take == false then
minetest.chat_send_player(name, "Not tamed!")
minetest.chat_send_player(name, S("Not tamed!"))
return
end
@ -2720,7 +2741,7 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
if self.owner ~= name
and force_take == false then
minetest.chat_send_player(name, self.owner.." is owner!")
minetest.chat_send_player(name, S("@1 is owner!", self.owner))
return
end
@ -2761,7 +2782,7 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
self.object:remove()
else
minetest.chat_send_player(name, "Missed!")
minetest.chat_send_player(name, S("Missed!"))
end
end
end
@ -2800,8 +2821,8 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
if self.htimer < 1 then
minetest.chat_send_player(clicker:get_player_name(),
self.name:split(":")[2]
.. " at full health (" .. tostring(self.health) .. ")")
S("@1 at full health (@2)",
self.name:split(":")[2], tostring(self.health)))
self.htimer = 5
end
@ -2835,8 +2856,8 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
if self.tamed == false then
minetest.chat_send_player(clicker:get_player_name(),
self.name:split(":")[2]
.. " has been tamed!")
S("@1 has been tamed!",
self.name:split(":")[2]))
end
self.tamed = true
@ -2876,8 +2897,8 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
minetest.show_formspec(name, "mobs_nametag", "size[8,4]"
.. default.gui_bg
.. default.gui_bg_img
.. "field[0.5,1;7.5,0;name;Enter name:;" .. tag .. "]"
.. "button_exit[2.5,3.5;3,1;mob_rename;Rename]")
.. "field[0.5,1;7.5,0;name;" .. S("Enter name:") .. ";" .. tag .. "]"
.. "button_exit[2.5,3.5;3,1;mob_rename;" .. S("Rename") .. "]")
end