From e9e5bb7bef61a320660f6c281c3ef4d88809e3bb Mon Sep 17 00:00:00 2001 From: Isidor Zeuner Date: Fri, 29 Sep 2017 21:53:57 +0200 Subject: [PATCH 1/4] add mod.conf --- mod.conf | 1 + 1 file changed, 1 insertion(+) create mode 100644 mod.conf diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..42e14dd --- /dev/null +++ b/mod.conf @@ -0,0 +1 @@ +name = random_messages From 24974e109b132602797d683bc8eaf51a3398dd92 Mon Sep 17 00:00:00 2001 From: Isidor Zeuner Date: Fri, 6 Oct 2017 02:36:51 +0200 Subject: [PATCH 2/4] api compatibility --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 78773ac..c3844e7 100644 --- a/init.lua +++ b/init.lua @@ -34,7 +34,7 @@ end function random_messages.initialize() --Set the interval in minetest.conf. minetest.settings:set("random_messages_interval",120) - minetest.settings:save(); + minetest.settings:write(); return 120 end From 17d2fd9f75c0f87787a08fe673e3e33bfd72a7da Mon Sep 17 00:00:00 2001 From: Isidor Zeuner Date: Fri, 6 Oct 2017 02:56:20 +0200 Subject: [PATCH 3/4] avoid error on closing null file handle --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index 78773ac..46b39fc 100644 --- a/init.lua +++ b/init.lua @@ -64,6 +64,7 @@ function random_messages.read_messages() -- 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")) + return else -- or write default_input content in worldpath message file local content = default_input:read("*all") From 7db0c9c50b5e2d4477660681135ae1bba45be009 Mon Sep 17 00:00:00 2001 From: Isidor Zeuner Date: Fri, 6 Oct 2017 03:14:45 +0200 Subject: [PATCH 4/4] avoid crash on missing messages file --- init.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index 46b39fc..22c7f26 100644 --- a/init.lua +++ b/init.lua @@ -124,13 +124,15 @@ random_messages.set_interval() random_messages.read_messages() local TIMER = 0 -minetest.register_globalstep(function(dtime) - TIMER = TIMER + dtime; - if TIMER > MESSAGE_INTERVAL then - random_messages.show_message() - TIMER = 0 - end -end) +if random_messages.messages[1] then + minetest.register_globalstep(function(dtime) + TIMER = TIMER + dtime; + if TIMER > MESSAGE_INTERVAL then + random_messages.show_message() + TIMER = 0 + end + end) +end local register_chatcommand_table = { params = "viewmessages | removemessage | addmessage ",