mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-11 09:20:17 +01:00
Write better mod which write data to a fifo.
This commit is contained in:
parent
cec833eb43
commit
7c5fa86b27
@ -1,9 +1,27 @@
|
|||||||
local time_interval = 1.0
|
local time_interval = 1.0
|
||||||
|
local fifo_path "/tmp/mt_players_fifo"
|
||||||
|
|
||||||
|
function players_data()
|
||||||
|
ps = {}
|
||||||
|
for i, 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()
|
function time_interval_func()
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
local players = players_data()
|
||||||
local name = player:get_player_name()
|
local fifo = io.open(fifo_path, 'w')
|
||||||
minetest.chat_send_player(name, "Hello " .. name)
|
if (fifo != nil) then
|
||||||
|
fifo.write(players)
|
||||||
|
fifo:close()
|
||||||
end
|
end
|
||||||
minetest.after(time_interval, time_interval_func)
|
minetest.after(time_interval, time_interval_func)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user