October 4, 201510 yr hi just started writing modules . would like some help scripting a rotory switch controlled by a Lvar variable with 4 positions. in the tracer when the switch is rotated up it reads ERP_ATR=1 ERP_ATR=2 ERP_ATR=3 when rotated down ERP_ATR=2 ERP_ATR=1 ERP_ATR=0 how can I script this to operate the switch going up and down through the cycle thanks for any help
October 5, 201510 yr Hi ashere Before I can better answer your question can you say which aircraft you are using, what rotary switch you plan to use, where you got the Lvar variables from and what your level of programming skills and knowledge of LUA are? Andrew Gransden Scotland, UK LINDA Support/Developer - VATSIM and BAVirtual - Airbus Flyer i7 1TB SSD GTX980 - FSX/P3D - Aerosoft Airbus A318/A319/A320/A321 - FS2Crew
October 5, 201510 yr Author hi the aircraft is atr 42 by virtualcol and the swich is the mct control for config engines. the Lvar variables are from the linda tracer when the switch is operated with the mouse. don't know much about programming and lua and have done most of the other controls looking at other aircraft scripts and coping.
October 5, 201510 yr hi the aircraft is atr 42 by virtualcol and the swich is the mct control for config engines. the Lvar variables are from the linda tracer when the switch is operated with the mouse. don't know much about programming and lua and have done most of the other controls looking at other aircraft scripts and coping. I have not been able to identify the MCT Control through Google. Do you have a link? How does LINDA see the device and how is the rotary switch up/down selection operate? Does LINDA see separate up or down movement or are there discrete positions? Andrew Gransden Scotland, UK LINDA Support/Developer - VATSIM and BAVirtual - Airbus Flyer i7 1TB SSD GTX980 - FSX/P3D - Aerosoft Airbus A318/A319/A320/A321 - FS2Crew
October 5, 201510 yr Author have done some checking and there may be a bad translation in the manual , have checked other planes and the switch is called pwr mgt . in the sim with the switch at the position when you first load . when you mouse click once and check the variables erp_atr moves to erp_atr=1 when you rotate again it moves to erp_atr=2 then erp_atr=3. that is full . going the other way it reads erp_atr=2 then erp_atr=1 then erp_atr=0 this is full back
October 5, 201510 yr have done some checking and there may be a bad translation in the manual , have checked other planes and the switch is called pwr mgt . in the sim with the switch at the position when you first load . when you mouse click once and check the variables erp_atr moves to erp_atr=1 when you rotate again it moves to erp_atr=2 then erp_atr=3. that is full . going the other way it reads erp_atr=2 then erp_atr=1 then erp_atr=0 this is full back I can understand how the Lvar is increasing when you operate the switch with the mouse. The question we need to answer is how you wish to operate the Power Management (Pwr Mgt) switch using LINDA. Do you want to press a button on a device/joystick to increase and press another to decrease? I think you are looking for code similar to this. -- To increment the ERP value: function ATR_ERP_inc local Lvar = "ERP_ATR" local erp = ipc.readLvar(Lvar) erp = erp +1 if erp > 3 then erp = 3 ipc.writeLvar(Lvar, erp) end -- To decrease the ERP value function ATR_ERP_dec local Lvar = "ERP_ATR" local erp = ipc.readLvar(Lvar) erp = erp +0 if erp < 0 then erp = 0 ipc.writeLvar(Lvar, erp) end Assign the ATR_ERP_inc function to the button you want to increase the value and the ATR_ERP_dec to the button you want to use to decrease the value. Andrew Gransden Scotland, UK LINDA Support/Developer - VATSIM and BAVirtual - Airbus Flyer i7 1TB SSD GTX980 - FSX/P3D - Aerosoft Airbus A318/A319/A320/A321 - FS2Crew
October 7, 201510 yr Author hi thanks for the help struggled to get this to work and found another script that works posted below . function ERP_atr_inc () local t = ipc.readLvar('ERP_atr') t = t + 1 if t > 3 then t = 3 end ipc.writeLvar('ERP_atr', t) end I don't know programming so try to look at other scripts and adjust them to work for me . also how do I upload my modules which are basic and mostly use fsx default with a few Lvar functions .
October 7, 201510 yr hi thanks for the help struggled to get this to work and found another script that works posted below . function ERP_atr_inc () local t = ipc.readLvar('ERP_atr') t = t + 1 if t > 3 then t = 3 end ipc.writeLvar('ERP_atr', t) end I don't know programming so try to look at other scripts and adjust them to work for me . also how do I upload my modules which are basic and mostly use fsx default with a few Lvar functions . I am glad to got the function to work and learned a little along the way. The main lesson is that LUA is case sensitive. I used the uppercase Lvars you quoted - it appears that it uses upper and lowercase. The best place for these functions is the new actions.lua or users.lua file for your aircraft located in /FSX/modules/Linda/aircraft/ATR (or something similar). If you are using FSX default, these will appear in LINDA as green assignments. Andrew Gransden Scotland, UK LINDA Support/Developer - VATSIM and BAVirtual - Airbus Flyer i7 1TB SSD GTX980 - FSX/P3D - Aerosoft Airbus A318/A319/A320/A321 - FS2Crew
Create an account or sign in to comment