From 8762b46e7c6fa5583a2501bcb314ed8d495b7cc1 Mon Sep 17 00:00:00 2001 From: flux <25628292+fluxionary@users.noreply.github.com> Date: Wed, 3 Jun 2020 23:13:03 +0000 Subject: [PATCH] fix setting names in 5.0+ --- README.md | 2 +- init.lua | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f541994..15084cf 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ minetest CSM which records sent and received messages in the minetest log file. requirements ------------ -tested with minetest 0.4.17 and 5.0. +tested with minetest 0.4.17 and 5.0 through 5.3-dev-ee831ed6e. only basic CSM need be enabled in 5.0, which is the default. diff --git a/init.lua b/init.lua index c96bddc..3f6c71d 100644 --- a/init.lua +++ b/init.lua @@ -31,19 +31,17 @@ local function safe(func) end local set_my_name_tries = 0 -local set_my_name = safe(function() +local function set_my_name() if minetest.localplayer then my_name = minetest.localplayer:get_name() - end - - if set_my_name_tries < 20 then + elseif set_my_name_tries < 20 then set_my_name_tries = set_my_name_tries + 1 + minetest.after(1, set_my_name) else my_name = '' log('warning', 'could not set name!') - return end -end) +end if minetest.register_on_connect then