proximity

This commit is contained in:
Tai @ Flex 2017-02-28 20:32:50 +00:00
parent 26a84d1309
commit f93d86be61

36
proximity_mode.lua Normal file
View File

@ -0,0 +1,36 @@
-- Proximity mode
local playerproximitypref = {}
local maxproximity = int(minetest.setting_get("chat_modes.maxproximity") ) or 100
chat_modes.register("proximity", {
help = "Send messages to players within a certain distance",
register = function(playername, params)
local proxpref = int(params[1]) or maxproximity
if proxpref > maxproximity then
proxpref = maxproximity
end
playerpxoimitypref[playername] = proxpref
end,
deregister = function(playername)
playerpxoimitypref[playername] = nil
end,
getPlayers = function(playername, message)
local targetplayers = {}
local thisplayer = minetest.get_player_by_name(playername)
for _,player in pairs(minetest.get_connected_players() ) do
if vector.distance(player:getpos(), thisplayer:getpos() ) <= playerpxoimitypref[playername] then
targetplayers[#targetplayers] = player
end
end
return targetplayers
end
})