From 42624f02fe4dbca6d42d24bf3dc5fadea4d3bdfb Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Thu, 24 Feb 2022 14:13:05 -0400 Subject: [PATCH] configurable send notificaicon about spawn point privatelly --- init.lua | 18 ++++++++++++++---- settingtypes.txt | 2 ++ 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 settingtypes.txt diff --git a/init.lua b/init.lua index bd36190..40288b9 100644 --- a/init.lua +++ b/init.lua @@ -13,6 +13,8 @@ if beds == nil then bed_respawn = false end +local notice_pos = minetest.settings:get_bool("spawnrand.notification_position") or true + -- spawnrand function invocation, it uses internat "find_ground" to fid valid position from initial one function spawnrand(player) local elevation = 20 @@ -51,7 +53,9 @@ function find_ground(pos, player) finished = true name = player:get_player_name() pos = player:getpos() - minetest.chat_send_player(name, "spawnrand: "..pos.x..","..pos.y..","..pos.z ) + if notice_pos then + minetest.chat_send_player(name, "spawnrand: "..pos.x..","..pos.y..","..pos.z ) + end minetest.log("action", "[spawnrand] position for "..name.. ", "..pos.x..","..pos.y..","..pos.z) return true end @@ -74,7 +78,9 @@ function find_ground(pos, player) i = 25 name = player:get_player_name() pos = player:getpos() - minetest.chat_send_player(name, "spawnrand: "..pos.x..","..pos.y..","..pos.z ) + if notice_pos then + minetest.chat_send_player(name, "spawnrand: "..pos.x..","..pos.y..","..pos.z ) + end minetest.log("action", "[spawnrand] position for "..name.. ", "..pos.x..","..pos.y..","..pos.z) return true end @@ -103,7 +109,9 @@ minetest.register_on_newplayer(function(player) local pos if player ~= nil then pos = player:getpos() - minetest.chat_send_player(player:get_player_name( ), "...awaiting new spawn from : ".. pos.x ..","..pos.y..","..pos.z ) + if notice_pos then + minetest.chat_send_player(player:get_player_name( ), "...awaiting new spawn from : ".. pos.x ..","..pos.y..","..pos.z ) + end spawnrand(player) end @@ -117,7 +125,9 @@ minetest.register_on_respawnplayer(function(player) if player ~= nil then name = player:get_player_name() pos = player:getpos() - minetest.chat_send_player(player:get_player_name( ), "...awaiting new spawn from : ".. pos.x ..","..pos.y..","..pos.z ) + if notice_pos then + minetest.chat_send_player(player:get_player_name( ), "...awaiting new spawn from : ".. pos.x ..","..pos.y..","..pos.z ) + end if bed_respawn then pos = beds.spawn[name] if pos then diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..ea00ae1 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,2 @@ +# will send a chat notificatin private message to the player about new spawn position +spawnrand.notification_position (Send a private notification about new pos to player) bool true