added function MarkLisener.showMarkItems and function MarkLisener.getParams
This commit is contained in:
+54
-1
@@ -15,6 +15,9 @@ MarkLisener = {}
|
||||
|
||||
|
||||
do
|
||||
MarkLisener.Debug = true
|
||||
|
||||
|
||||
function MarkLisener.showMarkItems(event)
|
||||
local msg = " "
|
||||
if event.id then
|
||||
@@ -56,11 +59,61 @@ do
|
||||
trigger.action.outText(msg,5)
|
||||
end
|
||||
|
||||
function MarkLisener.getParams(text)
|
||||
-- command heading altitude speed
|
||||
|
||||
local command, heading, altitude, speed
|
||||
if not text or text == '' then return nil end
|
||||
|
||||
local parts = {}
|
||||
for part in string.gmatch(text,"%S+") do
|
||||
table.insert(parts,part)
|
||||
end
|
||||
|
||||
command = parts[1]
|
||||
for i=2,4,1 do
|
||||
if not parts[i] then break end
|
||||
|
||||
parts[i] = tonumber(parts[i])
|
||||
|
||||
if not heading then
|
||||
if parts[i] >= 0 and parts[i] < 360 then
|
||||
heading = parts[i]
|
||||
end
|
||||
end
|
||||
|
||||
if not speed then
|
||||
if parts[i] >= 230 and parts[i] <= 430 then --节
|
||||
speed = parts[i]
|
||||
end
|
||||
end
|
||||
|
||||
if not altitude then
|
||||
if parts[i] >= 3000 and parts[i] <= 45000 then --英尺
|
||||
altitude = parts[i]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return command, heading, altitude, speed
|
||||
end
|
||||
|
||||
local ev = {}
|
||||
|
||||
function ev:onEvent(event)
|
||||
if event.id == 25 or event.id == 26 then
|
||||
|
||||
--Debug
|
||||
if MarkLisener.Debug then
|
||||
MarkLisener.showMarkItems(event)
|
||||
end
|
||||
|
||||
local markID = event.idx
|
||||
local pos = event.pos
|
||||
local text = event.text
|
||||
|
||||
if string.sub(text,1,1) == "/" then
|
||||
MarkLisener.getParams(text)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user