commit a4e8d5dfadb6118251a4eaaa8edf084f541f3136 Author: VanessaE Date: Wed May 6 05:34:39 2020 -0400 Initial commit diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..0180621 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +notice diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..8b4aa61 --- /dev/null +++ b/init.lua @@ -0,0 +1,26 @@ +-- Simple reboot warning mod + +local ie = minetest.request_insecure_environment() + +local timer = 0 +local warning_file = minetest.get_worldpath().."/reboot_warning" + +minetest.register_globalstep(function(dtime) + if timer > 600 then -- 600 tenths = 1 minute + timer = 0 + local f = io.open(warning_file, "r") + if f then + io.close(f) + ie.os.remove(warning_file) + for _, player in ipairs(minetest.get_connected_players()) do + local playername = player:get_player_name() + if playername then + notice.send(playername, + "*** IMPORTANT NOTICE: | The server will be | rebooting for its nightly | backup in a few minutes!") + minetest.log("Issued reboot warning to "..playername) + end + end + end + end + timer = timer + 1 +end)