From 7e9469fa70f81f60a9f4369602eab756081b0806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=BC=E5=A4=9C=E7=8B=8E=E6=98=B5?= <1046295287@qq.com> Date: Thu, 21 Nov 2024 16:57:52 +0800 Subject: [PATCH] added function MarkLisener.showMarkItems and function MarkLisener.getParams --- markListener.lua | 55 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/markListener.lua b/markListener.lua index 735268f..958d7f8 100644 --- a/markListener.lua +++ b/markListener.lua @@ -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