Mod refresh and remove intllib support to Minetest translator

- Remove depends.txt
- Update mod.conf
- Add settingtypes.txt for interval between two subsequent messages
This commit is contained in:
2022-06-25 21:22:38 +02:00
parent bb61f68038
commit 0895cf7ce4
9 changed files with 35 additions and 152 deletions

View File

@ -13,9 +13,18 @@ math.randomseed(os.time())
random_messages = {}
random_messages.messages = {} --This table contains all messages.
-- Load support for intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
local S
if minetest.get_translator ~= nil then
S = minetest.get_translator("random_messages")
else
S = function(str, ...)
local args={...}
return str:gsub(
"@%d+",
function(match) return args[tonumber(match:sub(2))] end
)
end
end
function table.count( t )
local i = 0
@ -32,14 +41,8 @@ function table.random( t )
end
end
function random_messages.initialize() --Set the interval in minetest.conf.
minetest.settings:set("random_messages_interval",120)
minetest.settings:write();
return 120
end
function random_messages.set_interval() --Read the interval from minetest.conf(set it if it doesn'st exist)
MESSAGE_INTERVAL = tonumber(minetest.settings:get("random_messages_interval")) or random_messages.initialize()
MESSAGE_INTERVAL = tonumber(minetest.settings:get("random_messages_interval") or 120)
end
function random_messages.check_params(name,func,params)
@ -62,8 +65,8 @@ function random_messages.read_messages()
local output = io.open(minetest.get_worldpath().."/random_messages","w")
if not default_input then
-- blame the admin if not found
output:write(S("Blame the server admin! He/She has probably not edited the random messages yet.\n"))
output:write(S("Tell your dumb admin that this line is in (worldpath)/random_messages\n"))
output:write(S("Blame the server admin! He/She has probably not edited the random messages yet.").."\n")
output:write(S("Tell your dumb admin that this line is in (worldpath)/random_messages").."\n")
return
else
-- or write default_input content in worldpath message file