fix setting own name in 5.0+

master
flux 2020-06-03 23:19:01 +00:00
parent 783b82985c
commit 1a96196cdb
2 changed files with 8 additions and 7 deletions

View File

@ -3,9 +3,9 @@ minetest CSM which makes busy public chat easier to parse by coloring certain th
requirements
------------
tested with minetest 0.4.17 and 5.0.
tested with minetest 0.4.17 and 5.0 through through 5.3-dev-ee831ed6e.
only basic CSM need be enabled in 5.0, which is the default.
only basic CSM need be enabled on the 5.0+ server, which is the default.
installation
------------

View File

@ -225,22 +225,23 @@ end
-- END mod_storage access --
-- initalization --
local set_my_name = safe(function()
local set_my_name_tries = 0
local function set_my_name()
local name
if minetest.localplayer then
name = minetest.localplayer:get_name()
end
if name then
log('action', ('you are %s'):format(name))
set_name_status(name, 'self')
if AUTO_ALERT_ON_NAME then
add_alert_pattern(name)
end
elseif set_my_name_tries < 20 then
set_my_name_tries = set_my_name_tries + 1
minetest.after(1, set_my_name)
else
log('warning', 'could not determine name!')
end
end)
end
if minetest.register_on_connect then
minetest.register_on_connect(set_my_name)