Add pronounceability setting and disable pronounceability check by default

This commit is contained in:
ShadowNinja 2014-10-14 14:39:24 -04:00
parent f44f45d36e
commit 0b74461327

View File

@ -153,7 +153,7 @@ end)
---------------------- ----------------------
-- Original implementation (in Python) by sfan5 -- Original implementation (in Python) by sfan5
local function pronounceable(text) local function pronounceable(pronounceability, text)
local pronounceable = 0 local pronounceable = 0
local nonpronounceable = 0 local nonpronounceable = 0
local cn = 0 local cn = 0
@ -191,16 +191,24 @@ local function pronounceable(text)
if cn > 0 then if cn > 0 then
nonpronounceable = nonpronounceable + 1 nonpronounceable = nonpronounceable + 1
end end
return (pronounceable >= nonpronounceable) return pronounceable * pronounceability >= nonpronounceable
end end
-- Pronounceability factor:
minetest.register_on_prejoinplayer(function(name, ip) -- nil = Checking disabled.
-- 0 = Everything's unpronounceable.
-- 0.5 = Strict checking.
-- 1 = Normal checking.
-- 2 = Relaxed checking.
local pronounceability = tonumber(minetest.setting_get("name_restrictions.pronounceability"))
if pronounceability then
minetest.register_on_prejoinplayer(function(name, ip)
if exemptions[name] then return end if exemptions[name] then return end
if not pronounceable(name) then if not pronounceable(pronounceability, name) then
return "Your player name does not seem to be pronounceable." return "Your player name does not seem to be pronounceable."
.." Please choose a more pronounceable name." .." Please choose a more pronounceable name."
end end
end) end)
end