2015-03-09 11:49:55 +01:00
|
|
|
local time_interval = 1.0
|
2015-03-09 15:01:05 +01:00
|
|
|
local fifo_path = "/tmp/mt_players_fifo"
|
2015-03-09 11:49:55 +01:00
|
|
|
|
2015-03-09 12:49:55 +01:00
|
|
|
function players_data()
|
|
|
|
ps = {}
|
2015-03-09 12:51:39 +01:00
|
|
|
for _, player in ipairs(minetest.get_connected_players()) do
|
2015-03-09 12:49:55 +01:00
|
|
|
local pos = player:getpos()
|
2015-03-09 15:01:05 +01:00
|
|
|
local pname = player:get_player_name()
|
2015-03-09 12:49:55 +01:00
|
|
|
local data = {
|
|
|
|
name = pname,
|
|
|
|
x = pos.x,
|
|
|
|
y = pos.y,
|
|
|
|
z = pos.z }
|
|
|
|
table.insert(ps, data)
|
|
|
|
end
|
|
|
|
return minetest.write_json(ps) .. '\n'
|
|
|
|
end
|
|
|
|
|
|
|
|
function time_interval_func()
|
|
|
|
local players = players_data()
|
|
|
|
local fifo = io.open(fifo_path, 'w')
|
2015-03-09 12:54:04 +01:00
|
|
|
if (fifo ~= nil) then
|
2015-03-09 15:01:05 +01:00
|
|
|
fifo:write(players)
|
2015-03-09 12:49:55 +01:00
|
|
|
fifo:close()
|
2015-03-09 11:49:55 +01:00
|
|
|
end
|
|
|
|
minetest.after(time_interval, time_interval_func)
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.after(time_interval, time_interval_func)
|