player infos in bridge

This commit is contained in:
NatureFreshMilk 2019-01-29 18:00:00 +01:00
parent 13b3b144c3
commit 20613101b5
3 changed files with 6889 additions and 1 deletions

6855
doc/lua_api.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,43 @@
-- mapserver http bridge
local function explode(sep, input)
local t={}
local i=0
for k in string.gmatch(input,"([^"..sep.."]+)") do
t[i]=k
i=i+1
end
return t
end
local function get_max_lag()
local arrayoutput = explode(", ",minetest.get_server_status())
local arrayoutput = explode("=",arrayoutput[4])
return arrayoutput[1]
end
local http, url, key
function send_stats()
local data = {}
local data = {
time = minetest.get_timeofday() * 24000,
uptime = minetest.get_server_uptime(),
max_lag = get_max_lag(),
players = {}
}
for _, player in ipairs(minetest.get_connected_players()) do
local info = {
name = player:get_player_name(),
pos = player:get_pos(),
hp = player:get_hp(),
breath = player:get_breath(),
velocity = player:get_player_velocity()
}
table.insert(data.players, player)
end
http.fetch({
url = url,