1
0
forked from MTSR/mapserver

train/wagon info on the mod bridge

This commit is contained in:
NatureFreshMilk 2019-02-15 10:51:56 +01:00
parent 7a65be2c57
commit 70ade4e437
2 changed files with 37 additions and 26 deletions

View File

@ -42,36 +42,31 @@ function send_stats()
if has_advtrains then
-- send trains if 'advtrains' mod installed
--print(dump(advtrains))--XXX
data.trains = {}
for _, train in pairs(advtrains.trains) do
--print(dump(train))--XXX
local t = {
pos = train.last_pos,
velocity = train.velocity,
off_track = train.off_track,
id = train.id
id = train.id,
wagons = {}
}
for _, wagon in pairs(advtrains.wagons) do
if wagon.train_id == train.id then
table.insert(t.wagons, {
id = wagon.id,
type = wagon.type,
pos_in_train = wagon.pos_in_train,
})
end
end
table.insert(data.trains, t)
end
data.wagons = {}
for _, wagon in pairs(advtrains.wagons) do
--print(dump(wagon))--XXX
local w = {
train_id = wagon.train_id,
id = wagon.id,
type = wagon.type,
pos_in_train = wagon.pos_in_train,
}
table.insert(data.wagons, w)
end
end
for _, player in ipairs(minetest.get_connected_players()) do

View File

@ -6,25 +6,41 @@ import (
"net/http"
)
type PlayerPos struct {
type GenericPos struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Z float64 `json:"z"`
}
type Wagon struct {
Id int `json:"id"`
PosInTrain int `json:"pos_in_train"`
Type string `json:"type"`
}
type Train struct {
Pos GenericPos `json:"pos"`
Id int `json:"id"`
Wagons []*Wagon `json:"wagons"`
OffTrack bool `json:"off_track"`
Velocity int `json:"velocity"`
}
type Player struct {
Pos PlayerPos `json:"pos"`
Name string `json:"name"`
HP int `json:"hp"`
Breath int `json:"breath"`
Pos GenericPos `json:"pos"`
Velocity GenericPos `json:"velocity"`
Name string `json:"name"`
HP int `json:"hp"`
Breath int `json:"breath"`
//TODO: stamina, skin, etc
}
type MinetestInfo struct {
MaxLag float64 `json:"max_lag"`
Players []Player `json:"players"`
Time float64 `json:"time"`
Uptime float64 `json:"uptime"`
MaxLag float64 `json:"max_lag"`
Players []*Player `json:"players"`
Trains []*Train `json:"trains"`
Time float64 `json:"time"`
Uptime float64 `json:"uptime"`
}
type Minetest struct {