From 8e3839994067737b4728805f3b16f52712aa92d2 Mon Sep 17 00:00:00 2001 From: smoothchat <100860237+smoothchat@users.noreply.github.com> Date: Wed, 13 Aug 2025 16:31:57 +1000 Subject: [PATCH 1/8] Callback Bug Fix Two additional lines to clear the do_every_frame_before_code.clear(); do_every_frame_after_code.clear(); callbacks --- src/FlyWithLua.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/FlyWithLua.cpp b/src/FlyWithLua.cpp index 509e0a4..3acbe29 100644 --- a/src/FlyWithLua.cpp +++ b/src/FlyWithLua.cpp @@ -6674,6 +6674,8 @@ void ResetLuaEngine() LuaDrawCommand.clear(); EveryFrameCallbackCommand.clear(); + do_every_frame_before_code.clear(); + do_every_frame_after_code.clear(); CallbackCommand.clear(); LongTimeCallbackCommand.clear(); NewMetarCommand.clear(); From fa102b061d97daa87da5e0c5c16bd608312a0580 Mon Sep 17 00:00:00 2001 From: smoothchat <100860237+smoothchat@users.noreply.github.com> Date: Thu, 14 Aug 2025 02:10:22 +1000 Subject: [PATCH 2/8] Add files via upload --- .../Scripts (disabled)/GrabAIPlaneDemo.lua | 286 ++++++++++++++++++ 1 file changed, 286 insertions(+) create mode 100644 FlyWithLua/Scripts (disabled)/GrabAIPlaneDemo.lua diff --git a/FlyWithLua/Scripts (disabled)/GrabAIPlaneDemo.lua b/FlyWithLua/Scripts (disabled)/GrabAIPlaneDemo.lua new file mode 100644 index 0000000..054ec31 --- /dev/null +++ b/FlyWithLua/Scripts (disabled)/GrabAIPlaneDemo.lua @@ -0,0 +1,286 @@ +-- Demonstrate the do_every_frame() and do_every_frame_after() callbacks. +-- Create a flight with 2 or more AI airxcrft, then try this script. + +if not SUPPORTS_FLOATING_WINDOWS then + -- to make sure the script doesn't stop old FlyWithLua versions + logMsg("imgui not supported by your FlyWithLua version") + return +end + +require("graphics") + +-- load the XPLM library +local ffi = require("ffi") + +-- find the right lib to load +local XPLMlib = "" +if SYSTEM == "IBM" then + -- Windows OS (no path and file extension needed) + if SYSTEM_ARCHITECTURE == 64 then + XPLMlib = "XPLM_64" -- 64bit + else + XPLMlib = "XPLM" -- 32bit + end +elseif SYSTEM == "LIN" then + -- Linux OS (we need the path "Resources/plugins/" here for some reason) + if SYSTEM_ARCHITECTURE == 64 then + XPLMlib = "Resources/plugins/XPLM_64.so" -- 64bit + else + XPLMlib = "Resources/plugins/XPLM.so" -- 32bit + end +elseif SYSTEM == "APL" then + -- Mac OS (we need the path "Resources/plugins/" here for some reason) + XPLMlib = "Resources/plugins/XPLM.framework/XPLM" -- 64bit and 32 bit +else + return -- this should not happen +end + +-- load the lib and store in local variable +local XPLM = ffi.load(XPLMlib) + +local w1 = ffi.new("int[1]") +local w2 = ffi.new("int[1]") +local w3 = ffi.new("int[1]") +local AIRCRAFT_FILENAME = ffi.new("char[1024]") +local AIRCRAFT_PATH = ffi.new("char[1024]") + +local PLANE_COUNT +local PLANE_TOTAL +local PLANE_PLUGIN +local ACQUIRED = 0 +local GrabAIPlane_window = nil +local Window_Is_Open = false +local ShowGrabAIPlaneWindow = false +local HideGrabAIPlaneWindow = false +local xp_ver = get("sim/version/xplane_internal_version") +local Callback = 0 + + +----------------------------------- +--DATAREFS +----------------------------------- + +dataref("PAUSED", "sim/time/paused") +dataref("AIRCRAFT_ALTITUDE_AGL", "sim/flightmodel/position/y_agl") + +dataref("gPlaneX", "sim/flightmodel/position/local_x", "writable") +dataref("gPlaneY", "sim/flightmodel/position/local_y", "writable") +dataref("gPlaneZ", "sim/flightmodel/position/local_z", "writable") +dataref("gPlaneTheta", "sim/flightmodel/position/theta", "writable") +dataref("gPlanePhi", "sim/flightmodel/position/phi", "writable") +dataref("gPlanePsi", "sim/flightmodel/position/psi", "writable") +dataref("gPlaneAPHeading", "sim/cockpit/autopilot/heading", "writable") +dataref("gPlaneAPCurrentAltitude", "sim/cockpit/autopilot/current_altitude", "writable") +dataref("gPlaneLandingLights", "sim/cockpit/electrical/landing_lights_on") +dataref("gPlaneNavLights", "sim/cockpit/electrical/nav_lights_on") +dataref("gPlaneBeaconLights", "sim/cockpit/electrical/beacon_lights_on") +dataref("gPlaneStrobeLights", "sim/cockpit/electrical/strobe_lights_on") +gPlaneGear = dataref_table("sim/aircraft/parts/acf_gear_deploy") +gPlaneThrottle = dataref_table("sim/flightmodel2/engines/throttle_used_ratio") + +dataref("wPlaneX1", "sim/multiplayer/position/plane1_x", "writable") +dataref("wPlaneY1", "sim/multiplayer/position/plane1_y", "writable") +dataref("wPlaneZ1", "sim/multiplayer/position/plane1_z", "writable") +dataref("wPlaneTheta1", "sim/multiplayer/position/plane1_the", "writable") +dataref("wPlanePhi1", "sim/multiplayer/position/plane1_phi", "writable") +dataref("wPlanePsi1", "sim/multiplayer/position/plane1_psi", "writable") +wPlaneGear1 = dataref_table("sim/multiplayer/position/plane1_gear_deploy", "writable") +wPlaneThrottle1 = dataref_table("sim/multiplayer/position/plane1_throttle", "writable") +dataref("wPlaneAlt1", "sim/multiplayer/position/plane1_el") +dataref("wPlaneLandingLights1", "sim/multiplayer/position/plane1_landing_lights_on", "writable") +dataref("wPlaneNavLights1", "sim/multiplayer/position/plane1_nav_lights_on", "writable") +dataref("wPlaneBeaconLights1", "sim/multiplayer/position/plane1_beacon_lights_on", "writable") +dataref("wPlaneStrobeLights1", "sim/multiplayer/position/plane1_strobe_lights_on", "writable") + +dataref("wPlaneX2", "sim/multiplayer/position/plane2_x", "writable") +dataref("wPlaneY2", "sim/multiplayer/position/plane2_y", "writable") +dataref("wPlaneZ2", "sim/multiplayer/position/plane2_z", "writable") +dataref("wPlaneTheta2", "sim/multiplayer/position/plane2_the", "writable") +dataref("wPlanePhi2", "sim/multiplayer/position/plane2_phi", "writable") +dataref("wPlanePsi2", "sim/multiplayer/position/plane2_psi", "writable") +wPlaneGear2 = dataref_table("sim/multiplayer/position/plane2_gear_deploy", "writable") +wPlaneThrottle2 = dataref_table("sim/multiplayer/position/plane2_throttle", "writable") +dataref("wPlaneLandingLights2", "sim/multiplayer/position/plane2_landing_lights_on", "writable") +dataref("wPlaneNavLights2", "sim/multiplayer/position/plane2_nav_lights_on", "writable") +dataref("wPlaneBeaconLights2", "sim/multiplayer/position/plane2_beacon_lights_on", "writable") +dataref("wPlaneStrobeLights2", "sim/multiplayer/position/plane2_strobe_lights_on", "writable") + +ffi.cdef("typedef int XPLMPluginID") +ffi.cdef("void XPLMCountAircraft (int * outPLANE_COUNT, int * outPLANE_TOTAL, XPLMPluginID * outController)") +ffi.cdef("void XPLMGetNthAircraftModel (int inINDEX, char * outAIRCRAFT_FILENAME, char *outAIRCRAFT_PATH)") +ffi.cdef("typedef void (* XPLMPlanesAvailable_f)(void * inRefcon)") +ffi.cdef("int XPLMAcquirePlanes ( char ** inAIRCRAFT_PATH, XPLMPlanesAvailable_f inCallback, void * inRefcon)") +ffi.cdef("void XPLMDisableAIForPlane (int inAI)") +ffi.cdef("void XPLMReleasePlanes(void)") + +XPLM.XPLMCountAircraft (w1 , w2 , w3) +PLANE_COUNT, PLANE_TOTAL, PLANE_PLUGIN = w1[0], w2[0], w3[0] + + +function GrabAIPlane_on_close_floating_window() + + Window_Is_Open = false + ReleaseAIPlane() + +end + +local function GrabAIPlane_hide_window() + + if Window_Is_Open then + float_wnd_destroy(GrabAIPlane_window) + Window_Is_Open = false + end + +end + +local function GrabAIPlane_show_window() + + if(Window_Is_Open == false) then + local Window_Title = string.format("Grab AI Plane Demo", view_id) + GrabAIPlane_window = float_wnd_create(536, 90, 1, true) -- Width / Height + if(GrabAIPlane_window == nil) then + return + end + Window_Is_Open = true + float_wnd_set_title(GrabAIPlane_window, Window_Title) + float_wnd_set_imgui_builder(GrabAIPlane_window, "GrabAIPlane_window_build") + float_wnd_set_onclose(GrabAIPlane_window, "GrabAIPlane_on_close_floating_window") + end + +end + +function Manage_GrabAIPlane_Window() + + if(ShowGrabAIPlaneWindow == true) then -- Window is opened via a flight loop, not a callback. + GrabAIPlane_show_window() + ShowGrabAIPlaneWindow = false + else + if(HideGrabAIPlaneWindow == true) then -- Window is closed via a flight loop, not a callback. + GrabAIPlane_hide_window() + HideGrabAIPlaneWindow = false + end + end + +end + +function acquire_AIplanes_callback() + XPLMSpeakString("Planes acquired callback invoked.") +end + +function AcquireAIPlane() + + if XPLM.XPLMAcquirePlanes(ai_plane_array, acquire_AIplanes_callback, nil) ~= 1 then -- Smoothchat Grab the AI Plane details + XPLMSpeakString("XPLM Acquire Planes did not succeed. Another plugin may be controlling the AI aircraft") + else + XPLM.XPLMDisableAIForPlane(1) + XPLM.XPLMDisableAIForPlane(2) + ACQUIRED = 1 + Callback = 1 + end + +end + +function ReleaseAIPlane() + + XPLM.XPLMReleasePlanes() + XPLM.XPLMCountAircraft (w1 , w2 , w3) + PLANE_COUNT, PLANE_TOTAL, PLANE_PLUGIN = w1[0], w2[0], w3[0] + ACQUIRED = 0 + Callback = 0 +end + +function GrabAIPlane_Open_Settings() --smoothchat + + if (Window_Is_Open == false) then + ShowGrabAIPlaneWindow = true + else + HideGrabAIPlaneWindow = true + end + +end + +function Do_GrabAIPlane() + + if Callback == 1 then + wPlaneX1 = gPlaneX + wPlaneY1 = gPlaneY + wPlaneZ1 = gPlaneZ + 20 + wPlaneTheta1 = gPlaneTheta + wPlanePsi1 = gPlanePsi + wPlanePhi1 = gPlanePhi + end + +end + +function Do_GrabAIPlaneAfter() + + if Callback == 2 then + wPlaneX2 = gPlaneX + wPlaneY2 = gPlaneY + wPlaneZ2 = gPlaneZ + 20 + wPlaneTheta2 = gPlaneTheta + wPlanePsi2 = gPlanePsi + wPlanePhi2 = gPlanePhi + end + +end + +function GrabAIPlane_window_build(formation_window, x, y) + + XPLM.XPLMCountAircraft (w1 , w2 , w3) + PLANE_COUNT, PLANE_TOTAL, PLANE_PLUGIN = w1[0], w2[0], w3[0] + + imgui.TextUnformatted("FlyWithLUA Version is " .. xp_ver) + if Callback == 1 then + imgui.TextUnformatted("Using do_every_frame() callback") + elseif Callback == 2 then + imgui.TextUnformatted("Using do_every_frame_after() callback") + else + imgui.TextUnformatted("") + end + imgui.TextUnformatted("") + + if (xp_ver < 120000 and PLUGIN_VERSION_NO >= "2.7.38") or (xp_ver >= 120000 and PLUGIN_VERSION_NO >= "2.8.13") then + if PLANE_COUNT < 3 then + imgui.TextUnformatted("Not enough AI Planes Available. Please add 2 AI planes and start again.") + else + if imgui.Button("Grab Ai Plane") then + AcquireAIPlane() + end + imgui.SameLine() + if ACQUIRED == 1 then + if imgui.Button("Release AI Plane") then + ReleaseAIPlane() + end + imgui.SameLine() + if imgui.Button("Use Legacy Callback") then + Callback = 1 + end + imgui.SameLine() + if imgui.Button("Use After Callback") then + Callback = 2 + end + end + end + else + imgui.TextUnformatted("This version does not support do_every_frame_after() callbacks.") + end + +end + + +add_macro("Show GrabA I Plane Settings", "GrabAIPlane_Open_Settings()") + +if PLUGIN_VERSION_NO == nil then PLUGIN_VERSION_NO = "0.0.0" end +if (xp_ver < 120000 and PLUGIN_VERSION_NO >= "2.7.38") or (xp_ver >= 120000 and PLUGIN_VERSION_NO >= "2.8.13") then + do_every_frame("Do_GrabAIPlane()") + do_every_frame_after("Do_GrabAIPlaneAfter()") + Callback = 0 + print("[Grab AI Plane] Later Version Found. Doing both Do_Every_frame_after() and Do_Every_frame()") +else + do_every_frame_after("Do_GrabAIPlane()") + Callback = 0 + print("[Grab AI Plane] Later Version Not Found. Doing Do_Every_frame() only") +end + +do_often("Manage_GrabAIPlane_Window()") \ No newline at end of file From 082335642e2c9158a0ce254beea73615995a94ec Mon Sep 17 00:00:00 2001 From: smoothchat <100860237+smoothchat@users.noreply.github.com> Date: Thu, 14 Aug 2025 02:19:47 +1000 Subject: [PATCH 3/8] Update GrabAIPlaneDemo.lua --- FlyWithLua/Scripts (disabled)/GrabAIPlaneDemo.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/FlyWithLua/Scripts (disabled)/GrabAIPlaneDemo.lua b/FlyWithLua/Scripts (disabled)/GrabAIPlaneDemo.lua index 054ec31..10772b6 100644 --- a/FlyWithLua/Scripts (disabled)/GrabAIPlaneDemo.lua +++ b/FlyWithLua/Scripts (disabled)/GrabAIPlaneDemo.lua @@ -1,5 +1,5 @@ -- Demonstrate the do_every_frame() and do_every_frame_after() callbacks. --- Create a flight with 2 or more AI airxcrft, then try this script. +-- Create a flight with 2 or more AI aircraft, then try this script. if not SUPPORTS_FLOATING_WINDOWS then -- to make sure the script doesn't stop old FlyWithLua versions @@ -283,4 +283,5 @@ else print("[Grab AI Plane] Later Version Not Found. Doing Do_Every_frame() only") end -do_often("Manage_GrabAIPlane_Window()") \ No newline at end of file + +do_often("Manage_GrabAIPlane_Window()") From fd492ee95c0319b7a35f85fbe11b17e09521a849 Mon Sep 17 00:00:00 2001 From: smoothchat <100860237+smoothchat@users.noreply.github.com> Date: Thu, 14 Aug 2025 02:45:55 +1000 Subject: [PATCH 4/8] Delete FlyWithLua/Scripts (disabled)/GrabAIPlaneDemo.lua --- .../Scripts (disabled)/GrabAIPlaneDemo.lua | 287 ------------------ 1 file changed, 287 deletions(-) delete mode 100644 FlyWithLua/Scripts (disabled)/GrabAIPlaneDemo.lua diff --git a/FlyWithLua/Scripts (disabled)/GrabAIPlaneDemo.lua b/FlyWithLua/Scripts (disabled)/GrabAIPlaneDemo.lua deleted file mode 100644 index 10772b6..0000000 --- a/FlyWithLua/Scripts (disabled)/GrabAIPlaneDemo.lua +++ /dev/null @@ -1,287 +0,0 @@ --- Demonstrate the do_every_frame() and do_every_frame_after() callbacks. --- Create a flight with 2 or more AI aircraft, then try this script. - -if not SUPPORTS_FLOATING_WINDOWS then - -- to make sure the script doesn't stop old FlyWithLua versions - logMsg("imgui not supported by your FlyWithLua version") - return -end - -require("graphics") - --- load the XPLM library -local ffi = require("ffi") - --- find the right lib to load -local XPLMlib = "" -if SYSTEM == "IBM" then - -- Windows OS (no path and file extension needed) - if SYSTEM_ARCHITECTURE == 64 then - XPLMlib = "XPLM_64" -- 64bit - else - XPLMlib = "XPLM" -- 32bit - end -elseif SYSTEM == "LIN" then - -- Linux OS (we need the path "Resources/plugins/" here for some reason) - if SYSTEM_ARCHITECTURE == 64 then - XPLMlib = "Resources/plugins/XPLM_64.so" -- 64bit - else - XPLMlib = "Resources/plugins/XPLM.so" -- 32bit - end -elseif SYSTEM == "APL" then - -- Mac OS (we need the path "Resources/plugins/" here for some reason) - XPLMlib = "Resources/plugins/XPLM.framework/XPLM" -- 64bit and 32 bit -else - return -- this should not happen -end - --- load the lib and store in local variable -local XPLM = ffi.load(XPLMlib) - -local w1 = ffi.new("int[1]") -local w2 = ffi.new("int[1]") -local w3 = ffi.new("int[1]") -local AIRCRAFT_FILENAME = ffi.new("char[1024]") -local AIRCRAFT_PATH = ffi.new("char[1024]") - -local PLANE_COUNT -local PLANE_TOTAL -local PLANE_PLUGIN -local ACQUIRED = 0 -local GrabAIPlane_window = nil -local Window_Is_Open = false -local ShowGrabAIPlaneWindow = false -local HideGrabAIPlaneWindow = false -local xp_ver = get("sim/version/xplane_internal_version") -local Callback = 0 - - ------------------------------------ ---DATAREFS ------------------------------------ - -dataref("PAUSED", "sim/time/paused") -dataref("AIRCRAFT_ALTITUDE_AGL", "sim/flightmodel/position/y_agl") - -dataref("gPlaneX", "sim/flightmodel/position/local_x", "writable") -dataref("gPlaneY", "sim/flightmodel/position/local_y", "writable") -dataref("gPlaneZ", "sim/flightmodel/position/local_z", "writable") -dataref("gPlaneTheta", "sim/flightmodel/position/theta", "writable") -dataref("gPlanePhi", "sim/flightmodel/position/phi", "writable") -dataref("gPlanePsi", "sim/flightmodel/position/psi", "writable") -dataref("gPlaneAPHeading", "sim/cockpit/autopilot/heading", "writable") -dataref("gPlaneAPCurrentAltitude", "sim/cockpit/autopilot/current_altitude", "writable") -dataref("gPlaneLandingLights", "sim/cockpit/electrical/landing_lights_on") -dataref("gPlaneNavLights", "sim/cockpit/electrical/nav_lights_on") -dataref("gPlaneBeaconLights", "sim/cockpit/electrical/beacon_lights_on") -dataref("gPlaneStrobeLights", "sim/cockpit/electrical/strobe_lights_on") -gPlaneGear = dataref_table("sim/aircraft/parts/acf_gear_deploy") -gPlaneThrottle = dataref_table("sim/flightmodel2/engines/throttle_used_ratio") - -dataref("wPlaneX1", "sim/multiplayer/position/plane1_x", "writable") -dataref("wPlaneY1", "sim/multiplayer/position/plane1_y", "writable") -dataref("wPlaneZ1", "sim/multiplayer/position/plane1_z", "writable") -dataref("wPlaneTheta1", "sim/multiplayer/position/plane1_the", "writable") -dataref("wPlanePhi1", "sim/multiplayer/position/plane1_phi", "writable") -dataref("wPlanePsi1", "sim/multiplayer/position/plane1_psi", "writable") -wPlaneGear1 = dataref_table("sim/multiplayer/position/plane1_gear_deploy", "writable") -wPlaneThrottle1 = dataref_table("sim/multiplayer/position/plane1_throttle", "writable") -dataref("wPlaneAlt1", "sim/multiplayer/position/plane1_el") -dataref("wPlaneLandingLights1", "sim/multiplayer/position/plane1_landing_lights_on", "writable") -dataref("wPlaneNavLights1", "sim/multiplayer/position/plane1_nav_lights_on", "writable") -dataref("wPlaneBeaconLights1", "sim/multiplayer/position/plane1_beacon_lights_on", "writable") -dataref("wPlaneStrobeLights1", "sim/multiplayer/position/plane1_strobe_lights_on", "writable") - -dataref("wPlaneX2", "sim/multiplayer/position/plane2_x", "writable") -dataref("wPlaneY2", "sim/multiplayer/position/plane2_y", "writable") -dataref("wPlaneZ2", "sim/multiplayer/position/plane2_z", "writable") -dataref("wPlaneTheta2", "sim/multiplayer/position/plane2_the", "writable") -dataref("wPlanePhi2", "sim/multiplayer/position/plane2_phi", "writable") -dataref("wPlanePsi2", "sim/multiplayer/position/plane2_psi", "writable") -wPlaneGear2 = dataref_table("sim/multiplayer/position/plane2_gear_deploy", "writable") -wPlaneThrottle2 = dataref_table("sim/multiplayer/position/plane2_throttle", "writable") -dataref("wPlaneLandingLights2", "sim/multiplayer/position/plane2_landing_lights_on", "writable") -dataref("wPlaneNavLights2", "sim/multiplayer/position/plane2_nav_lights_on", "writable") -dataref("wPlaneBeaconLights2", "sim/multiplayer/position/plane2_beacon_lights_on", "writable") -dataref("wPlaneStrobeLights2", "sim/multiplayer/position/plane2_strobe_lights_on", "writable") - -ffi.cdef("typedef int XPLMPluginID") -ffi.cdef("void XPLMCountAircraft (int * outPLANE_COUNT, int * outPLANE_TOTAL, XPLMPluginID * outController)") -ffi.cdef("void XPLMGetNthAircraftModel (int inINDEX, char * outAIRCRAFT_FILENAME, char *outAIRCRAFT_PATH)") -ffi.cdef("typedef void (* XPLMPlanesAvailable_f)(void * inRefcon)") -ffi.cdef("int XPLMAcquirePlanes ( char ** inAIRCRAFT_PATH, XPLMPlanesAvailable_f inCallback, void * inRefcon)") -ffi.cdef("void XPLMDisableAIForPlane (int inAI)") -ffi.cdef("void XPLMReleasePlanes(void)") - -XPLM.XPLMCountAircraft (w1 , w2 , w3) -PLANE_COUNT, PLANE_TOTAL, PLANE_PLUGIN = w1[0], w2[0], w3[0] - - -function GrabAIPlane_on_close_floating_window() - - Window_Is_Open = false - ReleaseAIPlane() - -end - -local function GrabAIPlane_hide_window() - - if Window_Is_Open then - float_wnd_destroy(GrabAIPlane_window) - Window_Is_Open = false - end - -end - -local function GrabAIPlane_show_window() - - if(Window_Is_Open == false) then - local Window_Title = string.format("Grab AI Plane Demo", view_id) - GrabAIPlane_window = float_wnd_create(536, 90, 1, true) -- Width / Height - if(GrabAIPlane_window == nil) then - return - end - Window_Is_Open = true - float_wnd_set_title(GrabAIPlane_window, Window_Title) - float_wnd_set_imgui_builder(GrabAIPlane_window, "GrabAIPlane_window_build") - float_wnd_set_onclose(GrabAIPlane_window, "GrabAIPlane_on_close_floating_window") - end - -end - -function Manage_GrabAIPlane_Window() - - if(ShowGrabAIPlaneWindow == true) then -- Window is opened via a flight loop, not a callback. - GrabAIPlane_show_window() - ShowGrabAIPlaneWindow = false - else - if(HideGrabAIPlaneWindow == true) then -- Window is closed via a flight loop, not a callback. - GrabAIPlane_hide_window() - HideGrabAIPlaneWindow = false - end - end - -end - -function acquire_AIplanes_callback() - XPLMSpeakString("Planes acquired callback invoked.") -end - -function AcquireAIPlane() - - if XPLM.XPLMAcquirePlanes(ai_plane_array, acquire_AIplanes_callback, nil) ~= 1 then -- Smoothchat Grab the AI Plane details - XPLMSpeakString("XPLM Acquire Planes did not succeed. Another plugin may be controlling the AI aircraft") - else - XPLM.XPLMDisableAIForPlane(1) - XPLM.XPLMDisableAIForPlane(2) - ACQUIRED = 1 - Callback = 1 - end - -end - -function ReleaseAIPlane() - - XPLM.XPLMReleasePlanes() - XPLM.XPLMCountAircraft (w1 , w2 , w3) - PLANE_COUNT, PLANE_TOTAL, PLANE_PLUGIN = w1[0], w2[0], w3[0] - ACQUIRED = 0 - Callback = 0 -end - -function GrabAIPlane_Open_Settings() --smoothchat - - if (Window_Is_Open == false) then - ShowGrabAIPlaneWindow = true - else - HideGrabAIPlaneWindow = true - end - -end - -function Do_GrabAIPlane() - - if Callback == 1 then - wPlaneX1 = gPlaneX - wPlaneY1 = gPlaneY - wPlaneZ1 = gPlaneZ + 20 - wPlaneTheta1 = gPlaneTheta - wPlanePsi1 = gPlanePsi - wPlanePhi1 = gPlanePhi - end - -end - -function Do_GrabAIPlaneAfter() - - if Callback == 2 then - wPlaneX2 = gPlaneX - wPlaneY2 = gPlaneY - wPlaneZ2 = gPlaneZ + 20 - wPlaneTheta2 = gPlaneTheta - wPlanePsi2 = gPlanePsi - wPlanePhi2 = gPlanePhi - end - -end - -function GrabAIPlane_window_build(formation_window, x, y) - - XPLM.XPLMCountAircraft (w1 , w2 , w3) - PLANE_COUNT, PLANE_TOTAL, PLANE_PLUGIN = w1[0], w2[0], w3[0] - - imgui.TextUnformatted("FlyWithLUA Version is " .. xp_ver) - if Callback == 1 then - imgui.TextUnformatted("Using do_every_frame() callback") - elseif Callback == 2 then - imgui.TextUnformatted("Using do_every_frame_after() callback") - else - imgui.TextUnformatted("") - end - imgui.TextUnformatted("") - - if (xp_ver < 120000 and PLUGIN_VERSION_NO >= "2.7.38") or (xp_ver >= 120000 and PLUGIN_VERSION_NO >= "2.8.13") then - if PLANE_COUNT < 3 then - imgui.TextUnformatted("Not enough AI Planes Available. Please add 2 AI planes and start again.") - else - if imgui.Button("Grab Ai Plane") then - AcquireAIPlane() - end - imgui.SameLine() - if ACQUIRED == 1 then - if imgui.Button("Release AI Plane") then - ReleaseAIPlane() - end - imgui.SameLine() - if imgui.Button("Use Legacy Callback") then - Callback = 1 - end - imgui.SameLine() - if imgui.Button("Use After Callback") then - Callback = 2 - end - end - end - else - imgui.TextUnformatted("This version does not support do_every_frame_after() callbacks.") - end - -end - - -add_macro("Show GrabA I Plane Settings", "GrabAIPlane_Open_Settings()") - -if PLUGIN_VERSION_NO == nil then PLUGIN_VERSION_NO = "0.0.0" end -if (xp_ver < 120000 and PLUGIN_VERSION_NO >= "2.7.38") or (xp_ver >= 120000 and PLUGIN_VERSION_NO >= "2.8.13") then - do_every_frame("Do_GrabAIPlane()") - do_every_frame_after("Do_GrabAIPlaneAfter()") - Callback = 0 - print("[Grab AI Plane] Later Version Found. Doing both Do_Every_frame_after() and Do_Every_frame()") -else - do_every_frame_after("Do_GrabAIPlane()") - Callback = 0 - print("[Grab AI Plane] Later Version Not Found. Doing Do_Every_frame() only") -end - - -do_often("Manage_GrabAIPlane_Window()") From 1fe43e68535199c7eda67e9320d149d82faf9008 Mon Sep 17 00:00:00 2001 From: smoothchat <100860237+smoothchat@users.noreply.github.com> Date: Thu, 14 Aug 2025 02:51:41 +1000 Subject: [PATCH 5/8] LUA demo of the do_every_frame_after() callback --- .../DoEveryFrameAfterDemo.lua | 286 ++++++++++++++++++ 1 file changed, 286 insertions(+) create mode 100644 FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua diff --git a/FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua b/FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua new file mode 100644 index 0000000..e459413 --- /dev/null +++ b/FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua @@ -0,0 +1,286 @@ +-- Demonstrate the do_every_frame() and do_every_frame_after() callbacks. +-- Create a flight with 2 or more AI aircraft, then try this script. + +if not SUPPORTS_FLOATING_WINDOWS then + -- to make sure the script doesn't stop old FlyWithLua versions + logMsg("imgui not supported by your FlyWithLua version") + return +end + +require("graphics") + +-- load the XPLM library +local ffi = require("ffi") + +-- find the right lib to load +local XPLMlib = "" +if SYSTEM == "IBM" then + -- Windows OS (no path and file extension needed) + if SYSTEM_ARCHITECTURE == 64 then + XPLMlib = "XPLM_64" -- 64bit + else + XPLMlib = "XPLM" -- 32bit + end +elseif SYSTEM == "LIN" then + -- Linux OS (we need the path "Resources/plugins/" here for some reason) + if SYSTEM_ARCHITECTURE == 64 then + XPLMlib = "Resources/plugins/XPLM_64.so" -- 64bit + else + XPLMlib = "Resources/plugins/XPLM.so" -- 32bit + end +elseif SYSTEM == "APL" then + -- Mac OS (we need the path "Resources/plugins/" here for some reason) + XPLMlib = "Resources/plugins/XPLM.framework/XPLM" -- 64bit and 32 bit +else + return -- this should not happen +end + +-- load the lib and store in local variable +local XPLM = ffi.load(XPLMlib) + +local w1 = ffi.new("int[1]") +local w2 = ffi.new("int[1]") +local w3 = ffi.new("int[1]") +local AIRCRAFT_FILENAME = ffi.new("char[1024]") +local AIRCRAFT_PATH = ffi.new("char[1024]") + +local PLANE_COUNT +local PLANE_TOTAL +local PLANE_PLUGIN +local ACQUIRED = 0 +local GrabAIPlane_window = nil +local Window_Is_Open = false +local ShowGrabAIPlaneWindow = false +local HideGrabAIPlaneWindow = false +local xp_ver = get("sim/version/xplane_internal_version") +local Callback = 0 + + +----------------------------------- +--DATAREFS +----------------------------------- + +dataref("PAUSED", "sim/time/paused") +dataref("AIRCRAFT_ALTITUDE_AGL", "sim/flightmodel/position/y_agl") + +dataref("gPlaneX", "sim/flightmodel/position/local_x", "writable") +dataref("gPlaneY", "sim/flightmodel/position/local_y", "writable") +dataref("gPlaneZ", "sim/flightmodel/position/local_z", "writable") +dataref("gPlaneTheta", "sim/flightmodel/position/theta", "writable") +dataref("gPlanePhi", "sim/flightmodel/position/phi", "writable") +dataref("gPlanePsi", "sim/flightmodel/position/psi", "writable") +dataref("gPlaneAPHeading", "sim/cockpit/autopilot/heading", "writable") +dataref("gPlaneAPCurrentAltitude", "sim/cockpit/autopilot/current_altitude", "writable") +dataref("gPlaneLandingLights", "sim/cockpit/electrical/landing_lights_on") +dataref("gPlaneNavLights", "sim/cockpit/electrical/nav_lights_on") +dataref("gPlaneBeaconLights", "sim/cockpit/electrical/beacon_lights_on") +dataref("gPlaneStrobeLights", "sim/cockpit/electrical/strobe_lights_on") +gPlaneGear = dataref_table("sim/aircraft/parts/acf_gear_deploy") +gPlaneThrottle = dataref_table("sim/flightmodel2/engines/throttle_used_ratio") + +dataref("wPlaneX1", "sim/multiplayer/position/plane1_x", "writable") +dataref("wPlaneY1", "sim/multiplayer/position/plane1_y", "writable") +dataref("wPlaneZ1", "sim/multiplayer/position/plane1_z", "writable") +dataref("wPlaneTheta1", "sim/multiplayer/position/plane1_the", "writable") +dataref("wPlanePhi1", "sim/multiplayer/position/plane1_phi", "writable") +dataref("wPlanePsi1", "sim/multiplayer/position/plane1_psi", "writable") +wPlaneGear1 = dataref_table("sim/multiplayer/position/plane1_gear_deploy", "writable") +wPlaneThrottle1 = dataref_table("sim/multiplayer/position/plane1_throttle", "writable") +dataref("wPlaneAlt1", "sim/multiplayer/position/plane1_el") +dataref("wPlaneLandingLights1", "sim/multiplayer/position/plane1_landing_lights_on", "writable") +dataref("wPlaneNavLights1", "sim/multiplayer/position/plane1_nav_lights_on", "writable") +dataref("wPlaneBeaconLights1", "sim/multiplayer/position/plane1_beacon_lights_on", "writable") +dataref("wPlaneStrobeLights1", "sim/multiplayer/position/plane1_strobe_lights_on", "writable") + +dataref("wPlaneX2", "sim/multiplayer/position/plane2_x", "writable") +dataref("wPlaneY2", "sim/multiplayer/position/plane2_y", "writable") +dataref("wPlaneZ2", "sim/multiplayer/position/plane2_z", "writable") +dataref("wPlaneTheta2", "sim/multiplayer/position/plane2_the", "writable") +dataref("wPlanePhi2", "sim/multiplayer/position/plane2_phi", "writable") +dataref("wPlanePsi2", "sim/multiplayer/position/plane2_psi", "writable") +wPlaneGear2 = dataref_table("sim/multiplayer/position/plane2_gear_deploy", "writable") +wPlaneThrottle2 = dataref_table("sim/multiplayer/position/plane2_throttle", "writable") +dataref("wPlaneLandingLights2", "sim/multiplayer/position/plane2_landing_lights_on", "writable") +dataref("wPlaneNavLights2", "sim/multiplayer/position/plane2_nav_lights_on", "writable") +dataref("wPlaneBeaconLights2", "sim/multiplayer/position/plane2_beacon_lights_on", "writable") +dataref("wPlaneStrobeLights2", "sim/multiplayer/position/plane2_strobe_lights_on", "writable") + +ffi.cdef("typedef int XPLMPluginID") +ffi.cdef("void XPLMCountAircraft (int * outPLANE_COUNT, int * outPLANE_TOTAL, XPLMPluginID * outController)") +ffi.cdef("void XPLMGetNthAircraftModel (int inINDEX, char * outAIRCRAFT_FILENAME, char *outAIRCRAFT_PATH)") +ffi.cdef("typedef void (* XPLMPlanesAvailable_f)(void * inRefcon)") +ffi.cdef("int XPLMAcquirePlanes ( char ** inAIRCRAFT_PATH, XPLMPlanesAvailable_f inCallback, void * inRefcon)") +ffi.cdef("void XPLMDisableAIForPlane (int inAI)") +ffi.cdef("void XPLMReleasePlanes(void)") + +XPLM.XPLMCountAircraft (w1 , w2 , w3) +PLANE_COUNT, PLANE_TOTAL, PLANE_PLUGIN = w1[0], w2[0], w3[0] + + +function GrabAIPlane_on_close_floating_window() + + Window_Is_Open = false + ReleaseAIPlane() + +end + +local function GrabAIPlane_hide_window() + + if Window_Is_Open then + float_wnd_destroy(GrabAIPlane_window) + Window_Is_Open = false + end + +end + +local function GrabAIPlane_show_window() + + if(Window_Is_Open == false) then + local Window_Title = string.format("Grab AI Plane Demo", view_id) + GrabAIPlane_window = float_wnd_create(536, 90, 1, true) -- Width / Height + if(GrabAIPlane_window == nil) then + return + end + Window_Is_Open = true + float_wnd_set_title(GrabAIPlane_window, Window_Title) + float_wnd_set_imgui_builder(GrabAIPlane_window, "GrabAIPlane_window_build") + float_wnd_set_onclose(GrabAIPlane_window, "GrabAIPlane_on_close_floating_window") + end + +end + +function Manage_GrabAIPlane_Window() + + if(ShowGrabAIPlaneWindow == true) then -- Window is opened via a flight loop, not a callback. + GrabAIPlane_show_window() + ShowGrabAIPlaneWindow = false + else + if(HideGrabAIPlaneWindow == true) then -- Window is closed via a flight loop, not a callback. + GrabAIPlane_hide_window() + HideGrabAIPlaneWindow = false + end + end + +end + +function acquire_AIplanes_callback() + XPLMSpeakString("Planes acquired callback invoked.") +end + +function AcquireAIPlane() + + if XPLM.XPLMAcquirePlanes(ai_plane_array, acquire_AIplanes_callback, nil) ~= 1 then -- Smoothchat Grab the AI Plane details + XPLMSpeakString("XPLM Acquire Planes did not succeed. Another plugin may be controlling the AI aircraft") + else + XPLM.XPLMDisableAIForPlane(1) + XPLM.XPLMDisableAIForPlane(2) + ACQUIRED = 1 + Callback = 1 + end + +end + +function ReleaseAIPlane() + + XPLM.XPLMReleasePlanes() + XPLM.XPLMCountAircraft (w1 , w2 , w3) + PLANE_COUNT, PLANE_TOTAL, PLANE_PLUGIN = w1[0], w2[0], w3[0] + ACQUIRED = 0 + Callback = 0 +end + +function GrabAIPlane_Open_Settings() --smoothchat + + if (Window_Is_Open == false) then + ShowGrabAIPlaneWindow = true + else + HideGrabAIPlaneWindow = true + end + +end + +function Do_GrabAIPlane() + + if Callback == 1 then + wPlaneX1 = gPlaneX + wPlaneY1 = gPlaneY + wPlaneZ1 = gPlaneZ + 20 + wPlaneTheta1 = gPlaneTheta + wPlanePsi1 = gPlanePsi + wPlanePhi1 = gPlanePhi + end + +end + +function Do_GrabAIPlaneAfter() + + if Callback == 2 then + wPlaneX2 = gPlaneX + wPlaneY2 = gPlaneY + wPlaneZ2 = gPlaneZ + 20 + wPlaneTheta2 = gPlaneTheta + wPlanePsi2 = gPlanePsi + wPlanePhi2 = gPlanePhi + end + +end + +function GrabAIPlane_window_build(formation_window, x, y) + + XPLM.XPLMCountAircraft (w1 , w2 , w3) + PLANE_COUNT, PLANE_TOTAL, PLANE_PLUGIN = w1[0], w2[0], w3[0] + + imgui.TextUnformatted("FlyWithLUA Version is " .. xp_ver) + if Callback == 1 then + imgui.TextUnformatted("Using do_every_frame() callback") + elseif Callback == 2 then + imgui.TextUnformatted("Using do_every_frame_after() callback") + else + imgui.TextUnformatted("") + end + imgui.TextUnformatted("") + + if (xp_ver < 120000 and PLUGIN_VERSION_NO >= "2.7.38") or (xp_ver >= 120000 and PLUGIN_VERSION_NO >= "2.8.13") then + if PLANE_COUNT < 3 then + imgui.TextUnformatted("Not enough AI Planes Available. Please add 2 AI planes and start again.") + else + if imgui.Button("Grab Ai Plane") then + AcquireAIPlane() + end + imgui.SameLine() + if ACQUIRED == 1 then + if imgui.Button("Release AI Plane") then + ReleaseAIPlane() + end + imgui.SameLine() + if imgui.Button("Use Legacy Callback") then + Callback = 1 + end + imgui.SameLine() + if imgui.Button("Use After Callback") then + Callback = 2 + end + end + end + else + imgui.TextUnformatted("This version does not support do_every_frame_after() callbacks.") + end + +end + + +add_macro("Show GrabA I Plane Settings", "GrabAIPlane_Open_Settings()") + +if PLUGIN_VERSION_NO == nil then PLUGIN_VERSION_NO = "0.0.0" end +if (xp_ver < 120000 and PLUGIN_VERSION_NO >= "2.7.38") or (xp_ver >= 120000 and PLUGIN_VERSION_NO >= "2.8.13") then + do_every_frame("Do_GrabAIPlane()") + do_every_frame_after("Do_GrabAIPlaneAfter()") + Callback = 0 + print("[Grab AI Plane] Later Version Found. Doing both Do_Every_frame_after() and Do_Every_frame()") +else + do_every_frame_after("Do_GrabAIPlane()") + Callback = 0 + print("[Grab AI Plane] Later Version Not Found. Doing Do_Every_frame() only") +end + +do_often("Manage_GrabAIPlane_Window()") \ No newline at end of file From 4d821cb2619cb13e8c2fa68f7b5b355fc008a5b2 Mon Sep 17 00:00:00 2001 From: smoothchat <100860237+smoothchat@users.noreply.github.com> Date: Thu, 14 Aug 2025 11:26:47 +1000 Subject: [PATCH 6/8] Update DoEveryFrameAfterDemo.lua Added some comments and general cleanup. Sorry about all the updates. --- .../DoEveryFrameAfterDemo.lua | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua b/FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua index e459413..4de8856 100644 --- a/FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua +++ b/FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua @@ -1,5 +1,5 @@ -- Demonstrate the do_every_frame() and do_every_frame_after() callbacks. --- Create a flight with 2 or more AI aircraft, then try this script. +-- Create a flight with 2 or more AI aircraft, then invoke this script via it's menu item. if not SUPPORTS_FLOATING_WINDOWS then -- to make sure the script doesn't stop old FlyWithLua versions @@ -53,7 +53,7 @@ local Window_Is_Open = false local ShowGrabAIPlaneWindow = false local HideGrabAIPlaneWindow = false local xp_ver = get("sim/version/xplane_internal_version") -local Callback = 0 +local Callback = 0 -- which callback to use ----------------------------------- @@ -113,18 +113,19 @@ ffi.cdef("int XPLMAcquirePlanes ( char ** inAIRCRAFT_PATH, XPLMPlanesAvailable_f ffi.cdef("void XPLMDisableAIForPlane (int inAI)") ffi.cdef("void XPLMReleasePlanes(void)") -XPLM.XPLMCountAircraft (w1 , w2 , w3) +-- Get aircraft details +XPLM.XPLMCountAircraft (w1 , w2 , w3) PLANE_COUNT, PLANE_TOTAL, PLANE_PLUGIN = w1[0], w2[0], w3[0] -function GrabAIPlane_on_close_floating_window() +function GrabAIPlane_on_close_floating_window() -- cleanup when nthe window is closed. Needs to be global. Window_Is_Open = false - ReleaseAIPlane() + ReleaseAIPlanes() end -local function GrabAIPlane_hide_window() +local function GrabAIPlane_hide_window() -- Hide the window if Window_Is_Open then float_wnd_destroy(GrabAIPlane_window) @@ -133,11 +134,11 @@ local function GrabAIPlane_hide_window() end -local function GrabAIPlane_show_window() +local function GrabAIPlane_show_window() -- Show the app window. Needs to be global. if(Window_Is_Open == false) then - local Window_Title = string.format("Grab AI Plane Demo", view_id) - GrabAIPlane_window = float_wnd_create(536, 90, 1, true) -- Width / Height + local Window_Title = string.format("do_every_frame_after() Demo", view_id) + GrabAIPlane_window = float_wnd_create(550, 90, 1, true) -- Width / Height if(GrabAIPlane_window == nil) then return end @@ -149,13 +150,13 @@ local function GrabAIPlane_show_window() end -function Manage_GrabAIPlane_Window() +function Manage_GrabAIPlane_Window() -- needs to be a global function so do_often() can see it. - if(ShowGrabAIPlaneWindow == true) then -- Window is opened via a flight loop, not a callback. + if(ShowGrabAIPlaneWindow == true) then -- This indow is opened via a flight loop, not a callback. GrabAIPlane_show_window() ShowGrabAIPlaneWindow = false else - if(HideGrabAIPlaneWindow == true) then -- Window is closed via a flight loop, not a callback. + if(HideGrabAIPlaneWindow == true) then -- This window is closed via a flight loop, not a callback. GrabAIPlane_hide_window() HideGrabAIPlaneWindow = false end @@ -163,13 +164,13 @@ function Manage_GrabAIPlane_Window() end -function acquire_AIplanes_callback() +function acquire_AIplanes_callback() -- This is requred so that when released, the AI plane will return under control of x-plane. Needs to be global. XPLMSpeakString("Planes acquired callback invoked.") end -function AcquireAIPlane() +local function AcquireAIPlanes() - if XPLM.XPLMAcquirePlanes(ai_plane_array, acquire_AIplanes_callback, nil) ~= 1 then -- Smoothchat Grab the AI Plane details + if XPLM.XPLMAcquirePlanes(ai_plane_array, acquire_AIplanes_callback, nil) ~= 1 then -- Grab the AI Plane details XPLMSpeakString("XPLM Acquire Planes did not succeed. Another plugin may be controlling the AI aircraft") else XPLM.XPLMDisableAIForPlane(1) @@ -180,7 +181,7 @@ function AcquireAIPlane() end -function ReleaseAIPlane() +function ReleaseAIPlanes() -- Needs to be global so GrabAIPlane_on_close_floating_window()can see it. XPLM.XPLMReleasePlanes() XPLM.XPLMCountAircraft (w1 , w2 , w3) @@ -189,8 +190,7 @@ function ReleaseAIPlane() Callback = 0 end -function GrabAIPlane_Open_Settings() --smoothchat - +function GrabAIPlane_Open_Settings() -- set a variable that will cause the doOften() to open the window. Needs to be global. if (Window_Is_Open == false) then ShowGrabAIPlaneWindow = true else @@ -199,20 +199,20 @@ function GrabAIPlane_Open_Settings() --smoothchat end -function Do_GrabAIPlane() +function Do_GrabAIPlane() -- needs to be a global function so do_every_frame() can see it. - if Callback == 1 then - wPlaneX1 = gPlaneX - wPlaneY1 = gPlaneY - wPlaneZ1 = gPlaneZ + 20 - wPlaneTheta1 = gPlaneTheta - wPlanePsi1 = gPlanePsi - wPlanePhi1 = gPlanePhi + if Callback == 1 then + wPlaneX1 = gPlaneX -- move the AI plane near to the user plane + wPlaneY1 = gPlaneY -- "" + wPlaneZ1 = gPlaneZ + 20 -- "" offset by 20 + wPlaneTheta1 = gPlaneTheta -- copy the user plane's attitude + wPlanePsi1 = gPlanePsi -- "" + wPlanePhi1 = gPlanePhi -- "" end end -function Do_GrabAIPlaneAfter() +function Do_GrabAIPlaneAfter() -- needs to be a global function so do_every_frame_after() can see it. if Callback == 2 then wPlaneX2 = gPlaneX @@ -239,21 +239,21 @@ function GrabAIPlane_window_build(formation_window, x, y) imgui.TextUnformatted("") end imgui.TextUnformatted("") - + -- check if the FlyWithLUA version is compatible with the do__every+_frame_after() callback. if (xp_ver < 120000 and PLUGIN_VERSION_NO >= "2.7.38") or (xp_ver >= 120000 and PLUGIN_VERSION_NO >= "2.8.13") then - if PLANE_COUNT < 3 then + if PLANE_COUNT < 3 then -- do we have enough AI planes imgui.TextUnformatted("Not enough AI Planes Available. Please add 2 AI planes and start again.") else - if imgui.Button("Grab Ai Plane") then - AcquireAIPlane() + if imgui.Button("Grab AI Plane") then + AcquireAIPlanes() end imgui.SameLine() if ACQUIRED == 1 then if imgui.Button("Release AI Plane") then - ReleaseAIPlane() + ReleaseAIPlanes() end imgui.SameLine() - if imgui.Button("Use Legacy Callback") then + if imgui.Button("Use Standard Callback") then Callback = 1 end imgui.SameLine() @@ -269,18 +269,18 @@ function GrabAIPlane_window_build(formation_window, x, y) end -add_macro("Show GrabA I Plane Settings", "GrabAIPlane_Open_Settings()") +add_macro("Show Grab AI Plane Window", "GrabAIPlane_Open_Settings()") -- add menu item -if PLUGIN_VERSION_NO == nil then PLUGIN_VERSION_NO = "0.0.0" end -if (xp_ver < 120000 and PLUGIN_VERSION_NO >= "2.7.38") or (xp_ver >= 120000 and PLUGIN_VERSION_NO >= "2.8.13") then +if PLUGIN_VERSION_NO == nil then PLUGIN_VERSION_NO = "0.0.0" end -- Older version didn't have a a version variable. +if (xp_ver < 120000 and PLUGIN_VERSION_NO >= "2.7.38") or (xp_ver >= 120000 and PLUGIN_VERSION_NO >= "2.8.13") then -- check if compatible version do_every_frame("Do_GrabAIPlane()") do_every_frame_after("Do_GrabAIPlaneAfter()") Callback = 0 - print("[Grab AI Plane] Later Version Found. Doing both Do_Every_frame_after() and Do_Every_frame()") + print("[Grab AI Plane] Later Version Found. Doing both do_every_frame_after() and do_every_frame()") -- write to log.txt else do_every_frame_after("Do_GrabAIPlane()") Callback = 0 - print("[Grab AI Plane] Later Version Not Found. Doing Do_Every_frame() only") + print("[Grab AI Plane] Later Version Not Found. Doing do_every_frame() only") end -do_often("Manage_GrabAIPlane_Window()") \ No newline at end of file +do_often("Manage_GrabAIPlane_Window()") From 4573d5e766e2ac1045d13c3422d13514a4bc5439 Mon Sep 17 00:00:00 2001 From: smoothchat <100860237+smoothchat@users.noreply.github.com> Date: Thu, 14 Aug 2025 11:42:04 +1000 Subject: [PATCH 7/8] Update DoEveryFrameAfterDemo.lua Sorry, another small update --- FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua b/FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua index 4de8856..1a40477 100644 --- a/FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua +++ b/FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua @@ -269,7 +269,7 @@ function GrabAIPlane_window_build(formation_window, x, y) end -add_macro("Show Grab AI Plane Window", "GrabAIPlane_Open_Settings()") -- add menu item +add_macro("Show after() demo Window", "GrabAIPlane_Open_Settings()") -- add menu item if PLUGIN_VERSION_NO == nil then PLUGIN_VERSION_NO = "0.0.0" end -- Older version didn't have a a version variable. if (xp_ver < 120000 and PLUGIN_VERSION_NO >= "2.7.38") or (xp_ver >= 120000 and PLUGIN_VERSION_NO >= "2.8.13") then -- check if compatible version @@ -284,3 +284,4 @@ else end do_often("Manage_GrabAIPlane_Window()") + From 7e6497f15df46c2d6efc87759a2d89b77834dda8 Mon Sep 17 00:00:00 2001 From: smoothchat <100860237+smoothchat@users.noreply.github.com> Date: Fri, 15 Aug 2025 15:49:28 +1000 Subject: [PATCH 8/8] Update DoEveryFrameAfterDemo.lua Sorry, another tweak --- FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua b/FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua index 1a40477..cafe57b 100644 --- a/FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua +++ b/FlyWithLua/Scripts (disabled)/DoEveryFrameAfterDemo.lua @@ -276,12 +276,13 @@ if (xp_ver < 120000 and PLUGIN_VERSION_NO >= "2.7.38") or (xp_ver >= 120000 and do_every_frame("Do_GrabAIPlane()") do_every_frame_after("Do_GrabAIPlaneAfter()") Callback = 0 - print("[Grab AI Plane] Later Version Found. Doing both do_every_frame_after() and do_every_frame()") -- write to log.txt + print("[do_every_frame_after() demo] Later Version Found. Doing both do_every_frame_after() and do_every_frame()") -- write to log.txt else do_every_frame_after("Do_GrabAIPlane()") Callback = 0 - print("[Grab AI Plane] Later Version Not Found. Doing do_every_frame() only") + print("[do_every_frame_after() demo] Later Version Not Found. Doing do_every_frame() only") end do_often("Manage_GrabAIPlane_Window()") +