Jump to content

Recommended Posts

Posted (edited)

I'm not Lua script,

Copy Export.lua to Saved Games\DCS\Scripts, after editing,

TCP or UDP does not receive data

This is my Export.lua

-------

我不会 lua 脚本,

复制Export.lua到Saved Games\DCS\Scripts,编辑后,

TCP or UDP没有收到数据

这是我的Export.lua

 

local default_output_file = nil
function LuaExportStart()
package.path  = package.path..";.\\LuaSocket\\?.lua"
package.cpath = package.cpath..";.\\LuaSocket\\?.dll"
socket = require("socket")
host = host or "localhost"
port = port or 8811
c = socket.try(socket.connect(host, port)) 
c:setoption("tcp-nodelay",true) 
local version = LoGetVersionInfo() 
	default_output_file:write("ProductName: "..version.ProductName..'\n')
	default_output_file:write(string.format("FileVersion: %d.%d.%d.%d\n",
											version.FileVersion[1],
											version.FileVersion[2],
											version.FileVersion[3],
											version.FileVersion[4]))
	default_output_file:write(string.format("ProductVersion: %d.%d.%d.%d\n",
											version.ProductVersion[1],
											version.ProductVersion[2],
											version.ProductVersion[3], 
											version.ProductVersion[4]))
  end
end
function LuaExportBeforeNextFrame()
end
function LuaExportAfterNextFrame()
local t = LoGetModelTime()
local name = LoGetPilotName()
local altBar = LoGetAltitudeAboveSeaLevel()
local altRad = LoGetAltitudeAboveGroundLevel()
local pitch, bank, yaw = LoGetADIPitchBankYaw()
local engine = LoGetEngineInfo()
local HSI    = LoGetControlPanel_HSI()
socket.try(c:send(string.format("t = %.2f, name = %s, altBar = %.2f, alrRad = %.2f, pitch = %.2f, bank = %.2f, yaw = %.2f\n", t, name, altRad, altBar, pitch, bank, yaw)))
en
function LuaExportStop()
socket.try(c:send("quit")) 
c:close()
end
function LuaExportActivityNextEvent(t)
local tNext = t
local o = LoGetWorldObjects()
for k,v in pairs(o) do
   socket.try(c:send(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.x, v.LatLongAlt.Long, v.LatLongAlt.Alt, v.Heading)))
end
tNext = tNext + 1.0
return tNext
end

 

it's TCP or UDP?

Edited by qq515616480
  • Recently Browsing   0 members

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