Jump to content

Exporting self coordinates (export.lua)


Recommended Posts

Posted

Hi Everyone,

 

I'm trying to export my own coordinates in the Export.lua but can't find any variable names.

most tutorials about export lua talk about exporting a cockpit light mfd panels, but I'm trying to export the gps coordinates of the plane I'm using.

 

Or can someone point me a link, or forum where I could get a list of all that can be exported ? (not only cockpit lights and switches)

L'important n'est pas de tuer, mais de survivre.

[sIGPIC][/sIGPIC]

 

 

 

if you read this you are too curious

 

 

Posted (edited)

Ok sorry, I had it working. The LoGetSelfData () returning is a table.

And table values can be adressed by the value "table.value"

 

Here's working code from my export.lua for anyone interested

 

-- Please, set EnableExportScript = true in the Config/Export/Config.lua file
-- to activate this script!

local default_output_file = nil

function LuaExportStart()
--text file
--default_output_file = io.open(lfs.writedir().."/Logs/Export.log", "w")
--default_output_file:write("DEBUT EXPORT\n")

package.path = package.path..";.\\LuaSocket\\?.lua"
package.cpath = package.cpath..";.\\LuaSocket\\?.dll"
socket = require("socket")
host = "localhost"
port = 1234
c = socket.try(socket.connect(host, port)) -- connect to the listener socket
c:setoption("tcp-nodelay",true) -- set immediate transmission mode
end

function LuaExportAfterNextFrame()

local Thatsme = LoGetSelfData()
local Thatsmename = Thatsme.Name
-- LatLongAlt = { Lat = , Long = , Alt = }
local ThatsmeLat = Thatsme.LatLongAlt.Lat
local ThatsmeLong = Thatsme.LatLongAlt.Long
local ThatsmeAlt = Thatsme.LatLongAlt.Alt

local name = LoGetPilotName()
local t = LoGetModelTime()

if default_output_file then
if Thatsmename then
--default_output_file:write(string.format("Time = %.2f, PlayerName = %s, planetype = %s, Lat = %.2f, Long = %.2f, Alt = %.2f,", t, name, Thatsmename, ThatsmeLat, ThatsmeLong, ThatsmeAlt))
--default_output_file:write(string.format("thatsmename = %s, ", Thatsmename))
end
end


if Thatsmename then
socket.try(c:send(string.format("time = %.2f, PlayerName = %s, planetype = %s, Lat = %.2f, Long = %.2f, Alt = %.2f,", t, name, Thatsmename, ThatsmeLat, ThatsmeLong, ThatsmeAlt)))
end

end

function LuaExportStop()
--file
if default_output_file then
default_output_file:write("FIN EXPORT\n")
default_output_file:close()
default_output_file = nil
end
socket.try(c:send("FIN EXPORT"))
socket.try(c:send("quit")) -- to close the listener socket
c:close()
end

Edited by xjiks

L'important n'est pas de tuer, mais de survivre.

[sIGPIC][/sIGPIC]

 

 

 

if you read this you are too curious

 

 

  • 4 years later...
  • 2 years later...
Posted (edited)

Hello,
Thanks for this code:

local Thatsme = LoGetSelfData()
local Thatsmename = Thatsme.Name
-- LatLongAlt = { Lat = , Long = , Alt = }
local ThatsmeLat = Thatsme.LatLongAlt.Lat
local ThatsmeLong = Thatsme.LatLongAlt.Long
local ThatsmeAlt = Thatsme.LatLongAlt.Alt
local name = LoGetPilotName()
local t = LoGetModelTime()
if default_output_file then
if Thatsmename then
--default_output_file:write(string.format("Time = %.2f, PlayerName = %s, planetype = %s, Lat = %.2f, Long = %.2f, Alt = %.2f,", t, name , Thatsmename, ThatsmeLat, ThatsmeLong, ThatsmeAlt))
--default_output_file:write(string.format("thatsmename = %s, ", Thatsmename))
end
end

There is something very surprising about me.

It works when the aircraft is set in "player" mode (in the mission editor), and it doesn't work when the aircraft is set in ''client'' mode.

How is it possible ?
An idea ?

 

Edited by Fasu
Posted

Syria and Caucasus are in the East longitude scale, between 30 and 50 degrees East.

The Marianas are over near 139 East.

Maybe the numbers are too big?

  • Like 1
Posted (edited)
23 hours ago, No1sonuk said:

Syria and Caucasus are in the East longitude scale, between 30 and 50 degrees East.

The Marianas are over near 139 East.

Maybe the numbers are too big?

thank you very much for your answer.
However, I made an erratum in my question. The problem does not seem to be related to the map, but rather to the player vs client aircraft mode. I keep doing tests to understand....

 

EDIT

Ultimately, using the (commented) code provided in the export.lua which is in the DCS installation folders, it works, even in multiplayer.
Here is the code:

 

function LuaExportActivityNextEvent(t)
local tNext = t
if default_output_file then
local o = LoGetWorldObjects()
for k,v in pairs(o) do
default_output_file:write(string.format("t = %.2f, ID = %d, name = %s, country = %s(%s), LatLongAlt = (%f, %f, %f), heading = % f\n", t, k, v.Name, v.Country, v.Coalition, v.LatLongAlt.Lat, v.LatLongAlt.Long, v.LatLongAlt.Alt, v.Heading))
end
end
tNext = tNext + 5.0
return tNext
end

 

...but I'm still interested in an explanation, because when I test other data exports (for example: LoGetADIPitchBankYaw() ), I encounter the same problem: it doesn't work in ''client'' mode.

 

EDIT 2 : 

OK, finally by multiplying the tests, I understood: I had to launch my mission on a server (and not launch it locally mono-player). When the mission is really on a server, the data export works. (Except perhaps if the mission editor has forbidden it...)

 

Edited by Fasu
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...