Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AviationSFO committed Apr 28, 2022
0 parents commit bf7748b
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
/Resources/.DS_Store
/Resources/plugins/.DS_Store
/Resources/plugins/FlyWithLua/.DS_Store
/Resources/plugins/FlyWithLua/Scripts/.DS_Store
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Export XP

## What is Export XP?

Export XP is a plugin for [FlyWithLua](https://github.com/X-Friese/FlyWithLua) that exports data taken from the [X-Plane 11](https://x-plane.com/) API and sends it to a log file for other programs to read. The difference between Export XP and other exporting plugins is that Export XP does not require network access as it writes to files on your disk. Unfortunately, this means that data from Export XP can not be used on a different system without writing your own script to export the data over network. The plugin is written in Lua X-Plane 11 built in API.

## How to use Export XP

Export XP exports its data when run to a log file in your FlyWithLua scripts directory called `ExportXP.txt`. You can write another program to retrieve the data from this file for however you like.

### Format of the log file

```
longitude,
latitude,
altitude(in meters),
heading(true),
groundspeed(meters/second),
vertical speed(fpm),
pitch(degrees),
bank(degrees),
```

# Installation

## Requirements

- X-Plane 11.50 or later
- [FlyWithLua NG](https://github.com/X-Friese/FlyWithLua)

## Download

### GitHub:

1. Download and install the pre-requisites listed in the requirments section above.
2. Go to the [GitHub repository](https://github.com/AviationSFO/ExportXP) and click on releases.
3. Click on the latest release.
4. Click on the `source code zip` download button.
5. Extract the contents of the zip file to your X-Plane root directory.
59 changes: 59 additions & 0 deletions Resources/plugins/FlyWithLua/Scripts/ExportXP.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
-- ExportXP is a lightweight FlyWithLua script for X-Plane 11 that
-- exports main flight model characteristics out over a file
-- to be used by other programs
-- Author: Steven Weinstein (AviationSFO)
-- Tested X-Plane and FWL versions: 11.55r2, 2.7.32

local data = {}

-- this function retrieves the current aircraft's data and stores it in a table
-- from X-Plane's API for later export
function getData(data)
-- get the data from the flight model
dataref("lat", "sim/flightmodel/position/latitude")
dataref("lon", "sim/flightmodel/position/longitude")
dataref("alt", "sim/flightmodel/position/elevation")
dataref("hdg", "sim/flightmodel/position/true_psi")
dataref("gs", "sim/flightmodel/position/groundspeed")
dataref("vs", "sim/flightmodel/position/vh_ind_fpm")
dataref("pitch", "sim/flightmodel/position/true_theta")
dataref("roll", "sim/flightmodel/position/phi")
-- Applying to data array
data.lat = lat
data.lon = lon
data.alt = alt
data.hdg = hdg
data.gs = gs
data.vs = vs
data.pitch = pitch
data.roll = roll
return data
end

-- this function exports data to output file
function exportData(data)
-- export the data to a file
-- clearing file
local file = io.open("ExportXP.txt", "w")
file:write("")
file:close()
-- adding data
file = io.open("ExportXP.txt", "a")
file:write(data.lat, ",\n")
file:write(data.lon, ",\n")
file:write(data.alt, ",\n")
file:write(data.hdg, ",\n")
file:write(data.gs, ",\n")
file:write(data.vs, ",\n")
file:write(data.pitch, ",\n")
file:write(data.roll, ",\n")
file:close()
end

function main()
data = {}
data = getData(data)
exportData(data)
end

doEveryDraw("main()")

0 comments on commit bf7748b

Please sign in to comment.