mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-24 01:30:38 +01:00
Add the [track_players] mod for
show nthe players position on the minetestmapper
This commit is contained in:
parent
3b4037aefb
commit
cc06c4c783
32
mods/track_players/init.lua
Normal file
32
mods/track_players/init.lua
Normal file
@ -0,0 +1,32 @@
|
||||
local time_interval = 1.0
|
||||
local fifo_path = "/tmp/mt_players_fifo"
|
||||
|
||||
function players_data()
|
||||
local ps = {}
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
local pos = player:getpos()
|
||||
local pname = player:get_player_name()
|
||||
local data = {
|
||||
name = pname,
|
||||
x = pos.x,
|
||||
y = pos.y,
|
||||
z = pos.z }
|
||||
table.insert(ps, data)
|
||||
end
|
||||
if table.getn(ps) == 0 then
|
||||
return '[]\n'
|
||||
end
|
||||
return minetest.write_json(ps) .. '\n'
|
||||
end
|
||||
|
||||
function time_interval_func()
|
||||
local players = players_data()
|
||||
local fifo = io.open(fifo_path, 'w')
|
||||
if (fifo ~= nil) then
|
||||
fifo:write(players)
|
||||
fifo:close()
|
||||
end
|
||||
minetest.after(time_interval, time_interval_func)
|
||||
end
|
||||
|
||||
minetest.after(time_interval, time_interval_func)
|
@ -181,6 +181,7 @@ load_mod_notice = true
|
||||
load_mod_name_restrictions = true
|
||||
load_mod_whoison = true
|
||||
load_mod_player_inactive = true
|
||||
load_mod_track_players = true
|
||||
load_mod_spawn = true
|
||||
load_mod__misc = true
|
||||
load_mod_interact = true
|
||||
|
Loading…
Reference in New Issue
Block a user