mirror of
https://github.com/ShadowNinja/name_restrictions.git
synced 2024-12-23 09:00:20 +01:00
Add pronounceability setting and disable pronounceability check by default
This commit is contained in:
parent
f44f45d36e
commit
0b74461327
20
init.lua
20
init.lua
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user