mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-11-08 19:20:25 +01:00
30 lines
753 B
Lua
30 lines
753 B
Lua
local time_interval = 1.0
|
|
local fifo_path "/tmp/mt_players_fifo"
|
|
|
|
function players_data()
|
|
ps = {}
|
|
for _, player in ipairs(minetest.get_connected_players()) do
|
|
local pos = player:getpos()
|
|
local name = player:get_player_name()
|
|
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')
|
|
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)
|