June 24, 20196 yr After failing to be able to use acceleration on my Heading rotary , I have tried to make it toggle between 1 deg steps and 10 deg steps by pressing the button on the rotary. It's for the Aerosoft Airbus and there is a script for toggling the ALT but not the HDG. Therefore I copied the ALT script and adjusted to toggle the HDG but can't get it to toggle. Here is the relevant section... much obliged if someone can help... AB_HDGSTEP_set function AB_HDG_Step_tog () var = ipc.readLvar("AB_HDGSTEP_set") if var == 1 then AB_HDG_Step_1 () else AB_HDG_Step_10 () end end function AB_HDG_Step_1 () LVarSet = ("AB_HDGSTEP_set") ipc.writeLvar(LVarSet, 0) Anim = ("AB_AP_HDG_Knob_Ani") ipc.writeLvar(Anim, 1) ipc.sleep(30) ipc.writeLvar(Anim, 0) end function AB_HDG_Step_10 () LVarSet = ("AB_HDGSTEP_set") ipc.writeLvar(LVarSet, 1) Anim = ("AB_AP_HDG_Knob_Ani") ipc.writeLvar(Anim, -1) ipc.sleep(30) ipc.writeLvar(Anim, 0) end ....and the log The button animation doesn't toggle either (as an indication) but does work both ways in/out if set manually in the script. AB_Triple_HDG.lua Everything else works great... press Twice for heading set mode and press longer for heading managed mode Edited June 24, 20196 yr by aerostar
June 25, 20196 yr Author Apologies for messing the Log was trying different things then editing my post... I have stripped out the unnecessary parts and this is the part that's not toggling/switching... I have posted the corresponding Log where it can be seen that on button flag 4 it always stays at ' AB_HDG_Step_10' I have also included the full Lua file attached... not very big. Here is the Lua file - AB_Triple_HDG.lua Ian
June 25, 20196 yr Are you sure about this LVar name, AB_HDGSTEP_set ? I took a quick look at the LINDA file for the Airbus and the ALT functions you seem to have replicated address an LVar called AB_AP_ALTSTEP. If you are sure, then I would try checking for var ~= 0 in place of var == 1. MarkH https://www.youtube.com/@AlmostAviation AMD Ryzen 7 9800X3D / 64Gb DDR5 / Zotac RTX 5070 Ti / 2560 x 1440 display
June 25, 20196 yr Author Hi Mark, thank you thank you... I have replaced the AB_HDGSTEP_set with the AB_AP_ALTSTEP LVar and now it toggles and works good... now the only thing is when I toggle the HDG step it also toggles the ALT step as they are now sharing the same LVar... I think that means that I need to properly define the AB_HDGSTEP_set LVar as it's probably not being recognised, I created it. I thought by naming it and giving it a value outside the Function that would define it. I also changed the == to ~= Can I ask how I should define the LVar AB_HDGSTEP_set so that it is recognised and usable ? Thanks again, Ian
June 26, 20196 yr 9 hours ago, aerostar said: Can I ask how I should define the LVar AB_HDGSTEP_set so that it is recognised and usable ? Oh I see, you are defining this variable yourself. If you were using LINDA, you could create persistent local Lua variables like you have done here. That's because a LINDA Lua program stays running so all its module-level variables are persistent. But if you're just using plain old FSUIPC Lua, each Lua file is a separate program that runs and terminates when you bind it to a key or event. This means its local variable don't persist. But you can create persistent variables with the ipc.set() library function and read them from other Lua programs with ipc.get(). These aren't the same as LVars, which are variables defined inside of XML gauges. MarkH https://www.youtube.com/@AlmostAviation AMD Ryzen 7 9800X3D / 64Gb DDR5 / Zotac RTX 5070 Ti / 2560 x 1440 display
June 26, 20196 yr Author Whoopee... thanks again Mark, using ipc.get and .set works a treat, it's now all working... can't figure how the AB_AP_ALTSTEP worked though as it is using readLvar and writeLvar ... Now I may try and figure a way to get some kind of Rotary Acceleration working and then I wouldn't even need the button toggle which would free up another button... do you use Rotary Acceleration and if so, what method do you use... I hope I'm not over stepping with my questions... once again though , thank you Mark for your help... Ian
June 26, 20196 yr 40 minutes ago, aerostar said: do you use Rotary Acceleration and if so, what method do you use... No, I use pretty much the same method as you. The only difference is I set my toggle variable on and off in the button down and button up events for the rotary control's push button. So the push button acts like a SHIFT key. Now I can have slow increments if I just turn the knob, but fast increments if I push and turn it at the same time. Something like this (each of these functions will need to be a separate Lua file): function Rotary_Shift_ON() -- Call from the button-down event of the push switch ipc.set("RotaryShiftActive", 1) end function Rotary_Shift_OFF() -- Call from the button-up event of the push switch ipc.set("RotaryShiftActive", 0) end function HDG_Bug_Inc() if ipc.get("RotaryShiftActive") == 1 then for n = 1, 10 do ipc.control(65879) -- Increment the HDG bug end else ipc.control(65879) end end function HDG_Bug_Dec() if ipc.get("RotaryShiftActive") == 1 then for n = 1, 10 do ipc.control(65880) -- Decrement the HDG bug end else ipc.control(65880) end end MarkH https://www.youtube.com/@AlmostAviation AMD Ryzen 7 9800X3D / 64Gb DDR5 / Zotac RTX 5070 Ti / 2560 x 1440 display
Archived
This topic is now archived and is closed to further replies.