Diff
checker
テキスト
テキスト
画像
ドキュメント
Excel
フォルダ
Legal
Enterprise
デスクトップ
料金
ログイン
Diffchecker デスクトップのダウンロード
テキスト比較
2 つのテキスト ファイルの違いを見つける
ツール
履歴
ライブエディター
未変更行を折りたたむ
折り返しなし
レイアウト
分割
統合
比較精度
スマート
単語
文字
シンタックスハイライト
構文を選択
無視
テキスト変換
最初の差分へ移動
入力を編集
Diffchecker Desktop
Diffcheckerを実行する最も安全な方法。Diffchecker Desktopアプリを入手:あなたの差分はコンピューターから出ることはありません!
Desktopを入手
wwtExport diff
作成日
2 年前
差分は期限切れになりません
クリア
エクスポート
共有
説明
1 削除
行
合計
削除
文字
合計
削除
この機能を引き続き使用するには、アップグレードしてください
Diff
checker
Pro
価格を見る
272 行
すべてコピー
10 追加
行
合計
追加
文字
合計
追加
この機能を引き続き使用するには、アップグレードしてください
Diff
checker
Pro
価格を見る
277 行
すべてコピー
-- 新增外部库地址
-- 新增外部库地址
g_lfs=require('lfs')
g_lfs=require('lfs')
package.path = package.path..";"..g_lfs.writedir().."Scripts\\wwt\\?.lua"
package.path = package.path..";"..g_lfs.writedir().."Scripts\\wwt\\?.lua"
package.cpath = package.cpath..";"..g_lfs.writedir().."Scripts\\wwt\\?.dll"
package.cpath = package.cpath..";"..g_lfs.writedir().."Scripts\\wwt\\?.dll"
-- 定义dcs export函数
-- 定义dcs export函数
do
do
--初始化
--初始化
if g_winwingInit==nil then
if g_winwingInit==nil then
g_winwingInit=true
g_winwingInit=true
-- 声明
-- 声明
local _winwing={}
local _winwing={}
_winwing.selfData={}
_winwing.selfData={}
_winwing.mission=nil
_winwing.mission=nil
_winwing.mod=nil
_winwing.mod=nil
_winwing.output={}
_winwing.output={}
_winwing.common={}
_winwing.common={}
_winwing.clock=0
_winwing.clock=0
_winwing.delay=1.0
_winwing.delay=1.0
_winwing.interval=0.03
_winwing.interval=0.03
_winwing.json=loadfile("Scripts\\JSON.lua")()
_winwing.json=loadfile("Scripts\\JSON.lua")()
local _dev=nil
local _dev=nil
local _devVal=nil
local _devVal=nil
local _key=nil
local _key=nil
local _val=nil
local _val=nil
--加载网络库
--加载网络库
_winwing.net=require("wwtNetwork")
_winwing.net=require("wwtNetwork")
--启动网络
--启动网络
_winwing.net.start()
_winwing.net.start()
--网络就绪
--网络就绪
local _send={}
local _send={}
_send["func"]="net"
_send["func"]="net"
_send["msg"]="ready"
_send["msg"]="ready"
_winwing.net.send(_send)
_winwing.net.send(_send)
do
do
--定义函数
--定义函数
_winwing.LuaExportStart=function()
_winwing.LuaExportStart=function()
--记录日志
--记录日志
log.write("WWT",log.INFO,"Export start!")
log.write("WWT",log.INFO,"Export start!")
--任务就绪
--任务就绪
local _send={}
local _send={}
_send["func"]="mission"
_send["func"]="mission"
_send["msg"]="ready"
_send["msg"]="ready"
_winwing.net.send(_send)
_winwing.net.send(_send)
end
end
_winwing.LuaExportBeforeNextFrame=function()
_winwing.LuaExportBeforeNextFrame=function()
end
end
_winwing.getNet=function(t)
_winwing.getNet=function(t)
--任务开始(仅一次)
--任务开始(仅一次)
if _winwing.mission==nil then
if _winwing.mission==nil then
_winwing.mission=true
_winwing.mission=true
local _send={}
local _send={}
_send["func"]="mission"
_send["func"]="mission"
_send["msg"]="start"
_send["msg"]="start"
_winwing.net.send(_send)
_winwing.net.send(_send)
end
end
--获取机型
--获取机型
local _self=LoGetSelfData()
local _self=LoGetSelfData()
if _self~=nil then
if _self~=nil then
if _winwing.mod~=_self.Name then
if _winwing.mod~=_self.Name then
--记录机型
--记录机型
log.write("WWT",log.INFO,_self.Name)
log.write("WWT",log.INFO,_self.Name)
_winwing.mod=_self.Name
_winwing.mod=_self.Name
local _send={}
local _send={}
_send["func"]="mod"
_send["func"]="mod"
_send["msg"]=_self.Name
_send["msg"]=_self.Name
_winwing.net.send(_send)
_winwing.net.send(_send)
end
end
end
end
--接受网络数据并处理
--接受网络数据并处理
local _get=_winwing.net.get()
local _get=_winwing.net.get()
if type(_get)=="table" and _winwing.mod~=nil then
if type(_get)=="table" and _winwing.mod~=nil then
if _get["func"]=="addOutput" then--添加输出(变化输出)
if _get["func"]=="addOutput" then--添加输出(变化输出)
--遍历数据并添加
--遍历数据并添加
for _dev,_devVal in pairs(_get["args"]) do
for _dev,_devVal in pairs(_get["args"]) do
for _key,_valOld in pairs(_devVal) do
for _key,_valOld in pairs(_devVal) do
if type(_winwing.output[_dev])~="table" then
if type(_winwing.output[_dev])~="table" then
_winwing.output[_dev]={}
_winwing.output[_dev]={}
end
end
_winwing.output[_dev][_key]=_valOld
_winwing.output[_dev][_key]=_valOld
end
end
end
end
elseif _get["func"]=="getOutput" then--获取输出(仅一次)
elseif _get["func"]=="getOutput" then--获取输出(仅一次)
--遍历数据并回应
--遍历数据并回应
local _send={}
local _send={}
_send["func"]=_get["func"]
_send["func"]=_get["func"]
for _dev,_devVal in pairs(_get["args"]) do
for _dev,_devVal in pairs(_get["args"]) do
コピー
コピー済み
コピー
コピー済み
if _dev == nil or type(GetDevice(_dev))~='table' then
break
end
GetDevice(_dev):update_arguments()
GetDevice(_dev):update_arguments()
for _key,_valOld in pairs(_devVal) do
for _key,_valOld in pairs(_devVal) do
local _valNew=GetDevice(_dev):get_argument_value(_key)
local _valNew=GetDevice(_dev):get_argument_value(_key)
if type(_send["args"])~='table' then
if type(_send["args"])~='table' then
_send["args"]={}
_send["args"]={}
end
end
if type(_send["args"][_dev])~='table' then
if type(_send["args"][_dev])~='table' then
_send["args"][_dev]={}
_send["args"][_dev]={}
end
end
_send["args"][_dev][_key]=_valNew
_send["args"][_dev][_key]=_valNew
end
end
end
end
_winwing.net.send(_send)
_winwing.net.send(_send)
elseif _get["func"]=="clearOutput" then--清空输出
elseif _get["func"]=="clearOutput" then--清空输出
_winwing.output={}
_winwing.output={}
elseif _get["func"]=="addCommon" then--添加公共接口(变化输出)
elseif _get["func"]=="addCommon" then--添加公共接口(变化输出)
--遍历数据并添加
--遍历数据并添加
for _key,_arg in pairs(_get["args"]) do
for _key,_arg in pairs(_get["args"]) do
_winwing.common[_key]={}
_winwing.common[_key]={}
_winwing.common[_key]["identifyMethod"]=_arg
_winwing.common[_key]["identifyMethod"]=_arg
_winwing.common[_key]["value"]=nil
_winwing.common[_key]["value"]=nil
end
end
elseif _get["func"]=="getCommon" then--获取公共接口(仅一次)
elseif _get["func"]=="getCommon" then--获取公共接口(仅一次)
--遍历数据并回应
--遍历数据并回应
local _send={}
local _send={}
_send["func"]=_get["func"]
_send["func"]=_get["func"]
for _key,_msg in pairs(_get["args"]) do
for _key,_msg in pairs(_get["args"]) do
local _func,_err=loadstring(_msg)
local _func,_err=loadstring(_msg)
if _func then
if _func then
local _status,_result = pcall(_func)
local _status,_result = pcall(_func)
local _send={}
local _send={}
_send["args"][_key]=_result
_send["args"][_key]=_result
else
else
local _send={}
local _send={}
_send["args"][_key]=tostring(_err)
_send["args"][_key]=tostring(_err)
end
end
end
end
_winwing.net.send(_send)
_winwing.net.send(_send)
elseif _get["func"]=="clearCommon" then--清空公共接口
elseif _get["func"]=="clearCommon" then--清空公共接口
_winwing.common={}
_winwing.common={}
elseif _get["func"]=="original" then--原始接口
elseif _get["func"]=="original" then--原始接口
local _func,_err=loadstring(_get["msg"])
local _func,_err=loadstring(_get["msg"])
if _func then
if _func then
local _status,_result = pcall(_func)
local _status,_result = pcall(_func)
local _send={}
local _send={}
_send["func"]=_get["func"]
_send["func"]=_get["func"]
_send["status"]=_status
_send["status"]=_status
_send["msg"]=_result
_send["msg"]=_result
_winwing.net.send(_send)
_winwing.net.send(_send)
else
else
local _send={}
local _send={}
_send["func"]=_get["func"]
_send["func"]=_get["func"]
_send["status"]=false
_send["status"]=false
_send["msg"]=tostring(_err)
_send["msg"]=tostring(_err)
_winwing.net.send(_send)
_winwing.net.send(_send)
end
end
elseif _get["func"]=="setInput" then--设置输入
elseif _get["func"]=="setInput" then--设置输入
--遍历数据并触发
--遍历数据并触发
for _dev,_devVal in pairs(_get["args"]) do
for _dev,_devVal in pairs(_get["args"]) do
for _key,_val in pairs(_devVal) do
for _key,_val in pairs(_devVal) do
コピー
コピー済み
コピー
コピー済み
local dev=GetDevice(_dev)
if (_dev ~= nil) then
if dev
.performClickableAction~= nil then
local dev=GetDevice(_dev)
dev:performClickableAction(_key,_val)
if dev
~= nil and dev
.performClickableAction~= nil then
dev:performClickableAction(_key,_val)
end
end
end
end
end
end
end
end
end
end
end
end
end
_winwing.sendNet=function(t)
_winwing.sendNet=function(t)
--发送之前添加的输出数据(变化发送)
--发送之前添加的输出数据(变化发送)
local _sendOutput={}
local _sendOutput={}
_sendOutput["func"]="addOutput"
_sendOutput["func"]="addOutput"
_sendOutput["timestamp"]=t
_sendOutput["timestamp"]=t
for _dev,_devVal in pairs(_winwing.output) do
for _dev,_devVal in pairs(_winwing.output) do
コピー
コピー済み
コピー
コピー済み
if GetDevice(_dev)==nil
l
or type(GetDevice(_dev))~='table' then
if GetDevice(_dev)==nil
or type(GetDevice(_dev))~='table' then
break
break
end
end
GetDevice(_dev):update_arguments()
GetDevice(_dev):update_arguments()
for _key,_valOld in pairs(_devVal) do
for _key,_valOld in pairs(_devVal) do
local _valNew=GetDevice(_dev):get_argument_value(_key)
local _valNew=GetDevice(_dev):get_argument_value(_key)
if _valNew~=_valOld then
if _valNew~=_valOld then
_winwing.output[_dev][_key]=_valNew
_winwing.output[_dev][_key]=_valNew
if type(_sendOutput["args"])~='table' then
if type(_sendOutput["args"])~='table' then
_sendOutput["args"]={}
_sendOutput["args"]={}
end
end
if type(_sendOutput["args"][_dev])~='table' then
if type(_sendOutput["args"][_dev])~='table' then
_sendOutput["args"][_dev]={}
_sendOutput["args"][_dev]={}
end
end
_sendOutput["args"][_dev][_key]=_valNew
_sendOutput["args"][_dev][_key]=_valNew
end
end
end
end
end
end
if _sendOutput["args"]~=nil then
if _sendOutput["args"]~=nil then
_winwing.net.send(_sendOutput)
_winwing.net.send(_sendOutput)
end
end
--发送之前添加的公共接口(变化发送)
--发送之前添加的公共接口(变化发送)
local _sendCommon={}
local _sendCommon={}
_sendCommon["func"]="addCommon"
_sendCommon["func"]="addCommon"
_sendCommon["timestamp"]=t
_sendCommon["timestamp"]=t
for _key,_arg in pairs(_winwing.common) do
for _key,_arg in pairs(_winwing.common) do
local _func,_err=loadstring(_arg.identifyMethod)
local _func,_err=loadstring(_arg.identifyMethod)
if _func then
if _func then
local _status,_result = pcall(_func)
local _status,_result = pcall(_func)
if _winwing.json:encode(_result)~=_winwing.json:encode(_arg.value) then
if _winwing.json:encode(_result)~=_winwing.json:encode(_arg.value) then
if type(_sendCommon["args"])~='table' then
if type(_sendCommon["args"])~='table' then
_sendCommon["args"]={}
_sendCommon["args"]={}
end
end
_sendCommon["args"][_key]=_result
_sendCommon["args"][_key]=_result
_arg.value=_result
_arg.value=_result
end
end
else
else
if type(_sendCommon["args"])~='table' then
if type(_sendCommon["args"])~='table' then
_sendCommon["args"]={}
_sendCommon["args"]={}
end
end
_sendCommon["args"][_key]=tostring(_err)
_sendCommon["args"][_key]=tostring(_err)
end
end
end
end
if _sendCommon["args"]~=nil then
if _sendCommon["args"]~=nil then
_winwing.net.send(_sendCommon)
_winwing.net.send(_sendCommon)
end
end
end
end
_winwing.LuaExportActivityNextEvent=function(t)
_winwing.LuaExportActivityNextEvent=function(t)
_winwing.clock=t+_winwing.interval
_winwing.clock=t+_winwing.interval
--接收数据
--接收数据
_winwing.getNet(_winwing.clock)
_winwing.getNet(_winwing.clock)
--发送数据
--发送数据
_winwing.sendNet(_winwing.clock)
_winwing.sendNet(_winwing.clock)
return _winwing.clock
return _winwing.clock
end
end
_winwing.LuaExportStop=function()
_winwing.LuaExportStop=function()
--任务结束,关闭网络
--任务结束,关闭网络
local _send={}
local _send={}
_send["func"]="mission"
_send["func"]="mission"
_send["msg"]="stop"
_send["msg"]="stop"
_winwing.net.send(_send)
_winwing.net.send(_send)
--清空缓存
--清空缓存
_winwing.output=nil
_winwing.output=nil
_winwing.common=nil
_winwing.common=nil
--记录日志
--记录日志
log.write("WWT",log.INFO,"Export stop!")
log.write("WWT",log.INFO,"Export stop!")
end
end
--记录其他的(第三方)export函数,方便之后在执行我们的函数后,执行第三方函数。
--记录其他的(第三方)export函数,方便之后在执行我们的函数后,执行第三方函数。
_winwing.OtherLuaExportStart=LuaExportStart --开始函数
_winwing.OtherLuaExportStart=LuaExportStart --开始函数
_winwing.OtherLuaExportBeforeNextFrame=LuaExportBeforeNextFrame --输入数据到DCS内部,比如控制飞机的横滚
_winwing.OtherLuaExportBeforeNextFrame=LuaExportBeforeNextFrame --输入数据到DCS内部,比如控制飞机的横滚
_winwing.OtherLuaExportActivityNextEvent=LuaExportActivityNextEvent --输出数据到DCS外部,比如获取飞机的高度
_winwing.OtherLuaExportActivityNextEvent=LuaExportActivityNextEvent --输出数据到DCS外部,比如获取飞机的高度
_winwing.OtherLuaExportStop=LuaExportStop --结束函数
_winwing.OtherLuaExportStop=LuaExportStop --结束函数
--定义dcs export函数
--定义dcs export函数
LuaExportStart=function()
LuaExportStart=function()
_winwing.LuaExportStart()
_winwing.LuaExportStart()
if _winwing.OtherLuaExportStart then
if _winwing.OtherLuaExportStart then
_winwing.OtherLuaExportStart()
_winwing.OtherLuaExportStart()
end
end
end
end
LuaExportBeforeNextFrame=function()
LuaExportBeforeNextFrame=function()
_winwing.LuaExportBeforeNextFrame()
_winwing.LuaExportBeforeNextFrame()
if _winwing.OtherLuaExportBeforeNextFrame then
if _winwing.OtherLuaExportBeforeNextFrame then
_winwing.OtherLuaExportBeforeNextFrame()
_winwing.OtherLuaExportBeforeNextFrame()
end
end
end
end
LuaExportActivityNextEvent=function(t)
LuaExportActivityNextEvent=function(t)
t=_winwing.LuaExportActivityNextEvent(t)
t=_winwing.LuaExportActivityNextEvent(t)
if _winwing.OtherLuaExportActivityNextEvent then
if _winwing.OtherLuaExportActivityNextEvent then
t=_winwing.OtherLuaExportActivityNextEvent(t)
t=_winwing.OtherLuaExportActivityNextEvent(t)
end
end
return t
return t
end
end
LuaExportStop=function()
LuaExportStop=function()
_winwing.LuaExportStop()
_winwing.LuaExportStop()
if _winwing.OtherLuaExportStop then
if _winwing.OtherLuaExportStop then
_winwing.OtherLuaExportStop()
_winwing.OtherLuaExportStop()
end
end
end
end
log.write("WWT",log.INFO,"Winwing export installed!")
log.write("WWT",log.INFO,"Winwing export installed!")
end
end
end
end
end
end
保存された差分
原文
ファイルを開く
-- 新增外部库地址 g_lfs=require('lfs') package.path = package.path..";"..g_lfs.writedir().."Scripts\\wwt\\?.lua" package.cpath = package.cpath..";"..g_lfs.writedir().."Scripts\\wwt\\?.dll" -- 定义dcs export函数 do --初始化 if g_winwingInit==nil then g_winwingInit=true -- 声明 local _winwing={} _winwing.selfData={} _winwing.mission=nil _winwing.mod=nil _winwing.output={} _winwing.common={} _winwing.clock=0 _winwing.delay=1.0 _winwing.interval=0.03 _winwing.json=loadfile("Scripts\\JSON.lua")() local _dev=nil local _devVal=nil local _key=nil local _val=nil --加载网络库 _winwing.net=require("wwtNetwork") --启动网络 _winwing.net.start() --网络就绪 local _send={} _send["func"]="net" _send["msg"]="ready" _winwing.net.send(_send) do --定义函数 _winwing.LuaExportStart=function() --记录日志 log.write("WWT",log.INFO,"Export start!") --任务就绪 local _send={} _send["func"]="mission" _send["msg"]="ready" _winwing.net.send(_send) end _winwing.LuaExportBeforeNextFrame=function() end _winwing.getNet=function(t) --任务开始(仅一次) if _winwing.mission==nil then _winwing.mission=true local _send={} _send["func"]="mission" _send["msg"]="start" _winwing.net.send(_send) end --获取机型 local _self=LoGetSelfData() if _self~=nil then if _winwing.mod~=_self.Name then --记录机型 log.write("WWT",log.INFO,_self.Name) _winwing.mod=_self.Name local _send={} _send["func"]="mod" _send["msg"]=_self.Name _winwing.net.send(_send) end end --接受网络数据并处理 local _get=_winwing.net.get() if type(_get)=="table" and _winwing.mod~=nil then if _get["func"]=="addOutput" then--添加输出(变化输出) --遍历数据并添加 for _dev,_devVal in pairs(_get["args"]) do for _key,_valOld in pairs(_devVal) do if type(_winwing.output[_dev])~="table" then _winwing.output[_dev]={} end _winwing.output[_dev][_key]=_valOld end end elseif _get["func"]=="getOutput" then--获取输出(仅一次) --遍历数据并回应 local _send={} _send["func"]=_get["func"] for _dev,_devVal in pairs(_get["args"]) do GetDevice(_dev):update_arguments() for _key,_valOld in pairs(_devVal) do local _valNew=GetDevice(_dev):get_argument_value(_key) if type(_send["args"])~='table' then _send["args"]={} end if type(_send["args"][_dev])~='table' then _send["args"][_dev]={} end _send["args"][_dev][_key]=_valNew end end _winwing.net.send(_send) elseif _get["func"]=="clearOutput" then--清空输出 _winwing.output={} elseif _get["func"]=="addCommon" then--添加公共接口(变化输出) --遍历数据并添加 for _key,_arg in pairs(_get["args"]) do _winwing.common[_key]={} _winwing.common[_key]["identifyMethod"]=_arg _winwing.common[_key]["value"]=nil end elseif _get["func"]=="getCommon" then--获取公共接口(仅一次) --遍历数据并回应 local _send={} _send["func"]=_get["func"] for _key,_msg in pairs(_get["args"]) do local _func,_err=loadstring(_msg) if _func then local _status,_result = pcall(_func) local _send={} _send["args"][_key]=_result else local _send={} _send["args"][_key]=tostring(_err) end end _winwing.net.send(_send) elseif _get["func"]=="clearCommon" then--清空公共接口 _winwing.common={} elseif _get["func"]=="original" then--原始接口 local _func,_err=loadstring(_get["msg"]) if _func then local _status,_result = pcall(_func) local _send={} _send["func"]=_get["func"] _send["status"]=_status _send["msg"]=_result _winwing.net.send(_send) else local _send={} _send["func"]=_get["func"] _send["status"]=false _send["msg"]=tostring(_err) _winwing.net.send(_send) end elseif _get["func"]=="setInput" then--设置输入 --遍历数据并触发 for _dev,_devVal in pairs(_get["args"]) do for _key,_val in pairs(_devVal) do local dev=GetDevice(_dev) if dev.performClickableAction~= nil then dev:performClickableAction(_key,_val) end end end end end end _winwing.sendNet=function(t) --发送之前添加的输出数据(变化发送) local _sendOutput={} _sendOutput["func"]="addOutput" _sendOutput["timestamp"]=t for _dev,_devVal in pairs(_winwing.output) do if GetDevice(_dev)==nill or type(GetDevice(_dev))~='table' then break end GetDevice(_dev):update_arguments() for _key,_valOld in pairs(_devVal) do local _valNew=GetDevice(_dev):get_argument_value(_key) if _valNew~=_valOld then _winwing.output[_dev][_key]=_valNew if type(_sendOutput["args"])~='table' then _sendOutput["args"]={} end if type(_sendOutput["args"][_dev])~='table' then _sendOutput["args"][_dev]={} end _sendOutput["args"][_dev][_key]=_valNew end end end if _sendOutput["args"]~=nil then _winwing.net.send(_sendOutput) end --发送之前添加的公共接口(变化发送) local _sendCommon={} _sendCommon["func"]="addCommon" _sendCommon["timestamp"]=t for _key,_arg in pairs(_winwing.common) do local _func,_err=loadstring(_arg.identifyMethod) if _func then local _status,_result = pcall(_func) if _winwing.json:encode(_result)~=_winwing.json:encode(_arg.value) then if type(_sendCommon["args"])~='table' then _sendCommon["args"]={} end _sendCommon["args"][_key]=_result _arg.value=_result end else if type(_sendCommon["args"])~='table' then _sendCommon["args"]={} end _sendCommon["args"][_key]=tostring(_err) end end if _sendCommon["args"]~=nil then _winwing.net.send(_sendCommon) end end _winwing.LuaExportActivityNextEvent=function(t) _winwing.clock=t+_winwing.interval --接收数据 _winwing.getNet(_winwing.clock) --发送数据 _winwing.sendNet(_winwing.clock) return _winwing.clock end _winwing.LuaExportStop=function() --任务结束,关闭网络 local _send={} _send["func"]="mission" _send["msg"]="stop" _winwing.net.send(_send) --清空缓存 _winwing.output=nil _winwing.common=nil --记录日志 log.write("WWT",log.INFO,"Export stop!") end --记录其他的(第三方)export函数,方便之后在执行我们的函数后,执行第三方函数。 _winwing.OtherLuaExportStart=LuaExportStart --开始函数 _winwing.OtherLuaExportBeforeNextFrame=LuaExportBeforeNextFrame --输入数据到DCS内部,比如控制飞机的横滚 _winwing.OtherLuaExportActivityNextEvent=LuaExportActivityNextEvent --输出数据到DCS外部,比如获取飞机的高度 _winwing.OtherLuaExportStop=LuaExportStop --结束函数 --定义dcs export函数 LuaExportStart=function() _winwing.LuaExportStart() if _winwing.OtherLuaExportStart then _winwing.OtherLuaExportStart() end end LuaExportBeforeNextFrame=function() _winwing.LuaExportBeforeNextFrame() if _winwing.OtherLuaExportBeforeNextFrame then _winwing.OtherLuaExportBeforeNextFrame() end end LuaExportActivityNextEvent=function(t) t=_winwing.LuaExportActivityNextEvent(t) if _winwing.OtherLuaExportActivityNextEvent then t=_winwing.OtherLuaExportActivityNextEvent(t) end return t end LuaExportStop=function() _winwing.LuaExportStop() if _winwing.OtherLuaExportStop then _winwing.OtherLuaExportStop() end end log.write("WWT",log.INFO,"Winwing export installed!") end end end
変更されたテキスト
ファイルを開く
-- 新增外部库地址 g_lfs=require('lfs') package.path = package.path..";"..g_lfs.writedir().."Scripts\\wwt\\?.lua" package.cpath = package.cpath..";"..g_lfs.writedir().."Scripts\\wwt\\?.dll" -- 定义dcs export函数 do --初始化 if g_winwingInit==nil then g_winwingInit=true -- 声明 local _winwing={} _winwing.selfData={} _winwing.mission=nil _winwing.mod=nil _winwing.output={} _winwing.common={} _winwing.clock=0 _winwing.delay=1.0 _winwing.interval=0.03 _winwing.json=loadfile("Scripts\\JSON.lua")() local _dev=nil local _devVal=nil local _key=nil local _val=nil --加载网络库 _winwing.net=require("wwtNetwork") --启动网络 _winwing.net.start() --网络就绪 local _send={} _send["func"]="net" _send["msg"]="ready" _winwing.net.send(_send) do --定义函数 _winwing.LuaExportStart=function() --记录日志 log.write("WWT",log.INFO,"Export start!") --任务就绪 local _send={} _send["func"]="mission" _send["msg"]="ready" _winwing.net.send(_send) end _winwing.LuaExportBeforeNextFrame=function() end _winwing.getNet=function(t) --任务开始(仅一次) if _winwing.mission==nil then _winwing.mission=true local _send={} _send["func"]="mission" _send["msg"]="start" _winwing.net.send(_send) end --获取机型 local _self=LoGetSelfData() if _self~=nil then if _winwing.mod~=_self.Name then --记录机型 log.write("WWT",log.INFO,_self.Name) _winwing.mod=_self.Name local _send={} _send["func"]="mod" _send["msg"]=_self.Name _winwing.net.send(_send) end end --接受网络数据并处理 local _get=_winwing.net.get() if type(_get)=="table" and _winwing.mod~=nil then if _get["func"]=="addOutput" then--添加输出(变化输出) --遍历数据并添加 for _dev,_devVal in pairs(_get["args"]) do for _key,_valOld in pairs(_devVal) do if type(_winwing.output[_dev])~="table" then _winwing.output[_dev]={} end _winwing.output[_dev][_key]=_valOld end end elseif _get["func"]=="getOutput" then--获取输出(仅一次) --遍历数据并回应 local _send={} _send["func"]=_get["func"] for _dev,_devVal in pairs(_get["args"]) do if _dev == nil or type(GetDevice(_dev))~='table' then break end GetDevice(_dev):update_arguments() for _key,_valOld in pairs(_devVal) do local _valNew=GetDevice(_dev):get_argument_value(_key) if type(_send["args"])~='table' then _send["args"]={} end if type(_send["args"][_dev])~='table' then _send["args"][_dev]={} end _send["args"][_dev][_key]=_valNew end end _winwing.net.send(_send) elseif _get["func"]=="clearOutput" then--清空输出 _winwing.output={} elseif _get["func"]=="addCommon" then--添加公共接口(变化输出) --遍历数据并添加 for _key,_arg in pairs(_get["args"]) do _winwing.common[_key]={} _winwing.common[_key]["identifyMethod"]=_arg _winwing.common[_key]["value"]=nil end elseif _get["func"]=="getCommon" then--获取公共接口(仅一次) --遍历数据并回应 local _send={} _send["func"]=_get["func"] for _key,_msg in pairs(_get["args"]) do local _func,_err=loadstring(_msg) if _func then local _status,_result = pcall(_func) local _send={} _send["args"][_key]=_result else local _send={} _send["args"][_key]=tostring(_err) end end _winwing.net.send(_send) elseif _get["func"]=="clearCommon" then--清空公共接口 _winwing.common={} elseif _get["func"]=="original" then--原始接口 local _func,_err=loadstring(_get["msg"]) if _func then local _status,_result = pcall(_func) local _send={} _send["func"]=_get["func"] _send["status"]=_status _send["msg"]=_result _winwing.net.send(_send) else local _send={} _send["func"]=_get["func"] _send["status"]=false _send["msg"]=tostring(_err) _winwing.net.send(_send) end elseif _get["func"]=="setInput" then--设置输入 --遍历数据并触发 for _dev,_devVal in pairs(_get["args"]) do for _key,_val in pairs(_devVal) do if (_dev ~= nil) then local dev=GetDevice(_dev) if dev ~= nil and dev.performClickableAction~= nil then dev:performClickableAction(_key,_val) end end end end end end end _winwing.sendNet=function(t) --发送之前添加的输出数据(变化发送) local _sendOutput={} _sendOutput["func"]="addOutput" _sendOutput["timestamp"]=t for _dev,_devVal in pairs(_winwing.output) do if GetDevice(_dev)==nil or type(GetDevice(_dev))~='table' then break end GetDevice(_dev):update_arguments() for _key,_valOld in pairs(_devVal) do local _valNew=GetDevice(_dev):get_argument_value(_key) if _valNew~=_valOld then _winwing.output[_dev][_key]=_valNew if type(_sendOutput["args"])~='table' then _sendOutput["args"]={} end if type(_sendOutput["args"][_dev])~='table' then _sendOutput["args"][_dev]={} end _sendOutput["args"][_dev][_key]=_valNew end end end if _sendOutput["args"]~=nil then _winwing.net.send(_sendOutput) end --发送之前添加的公共接口(变化发送) local _sendCommon={} _sendCommon["func"]="addCommon" _sendCommon["timestamp"]=t for _key,_arg in pairs(_winwing.common) do local _func,_err=loadstring(_arg.identifyMethod) if _func then local _status,_result = pcall(_func) if _winwing.json:encode(_result)~=_winwing.json:encode(_arg.value) then if type(_sendCommon["args"])~='table' then _sendCommon["args"]={} end _sendCommon["args"][_key]=_result _arg.value=_result end else if type(_sendCommon["args"])~='table' then _sendCommon["args"]={} end _sendCommon["args"][_key]=tostring(_err) end end if _sendCommon["args"]~=nil then _winwing.net.send(_sendCommon) end end _winwing.LuaExportActivityNextEvent=function(t) _winwing.clock=t+_winwing.interval --接收数据 _winwing.getNet(_winwing.clock) --发送数据 _winwing.sendNet(_winwing.clock) return _winwing.clock end _winwing.LuaExportStop=function() --任务结束,关闭网络 local _send={} _send["func"]="mission" _send["msg"]="stop" _winwing.net.send(_send) --清空缓存 _winwing.output=nil _winwing.common=nil --记录日志 log.write("WWT",log.INFO,"Export stop!") end --记录其他的(第三方)export函数,方便之后在执行我们的函数后,执行第三方函数。 _winwing.OtherLuaExportStart=LuaExportStart --开始函数 _winwing.OtherLuaExportBeforeNextFrame=LuaExportBeforeNextFrame --输入数据到DCS内部,比如控制飞机的横滚 _winwing.OtherLuaExportActivityNextEvent=LuaExportActivityNextEvent --输出数据到DCS外部,比如获取飞机的高度 _winwing.OtherLuaExportStop=LuaExportStop --结束函数 --定义dcs export函数 LuaExportStart=function() _winwing.LuaExportStart() if _winwing.OtherLuaExportStart then _winwing.OtherLuaExportStart() end end LuaExportBeforeNextFrame=function() _winwing.LuaExportBeforeNextFrame() if _winwing.OtherLuaExportBeforeNextFrame then _winwing.OtherLuaExportBeforeNextFrame() end end LuaExportActivityNextEvent=function(t) t=_winwing.LuaExportActivityNextEvent(t) if _winwing.OtherLuaExportActivityNextEvent then t=_winwing.OtherLuaExportActivityNextEvent(t) end return t end LuaExportStop=function() _winwing.LuaExportStop() if _winwing.OtherLuaExportStop then _winwing.OtherLuaExportStop() end end log.write("WWT",log.INFO,"Winwing export installed!") end end end
違いを見つける