October 4, 20196 yr Hi all, My question is this; is a LINDA actions file purely reacting to a change in a switch condition when it happens or, is LINDA monitoring the actions file repeatedly looking for a change in status? I ask this because as I am building up my code for various switches and knobs on my panels, all is going well but where I am looking for LINDA to react to a change in a variable (say, 0x1264, TOTAL FUEL QUANTITY) it seems only to react to a change in that variable (i.e. quantity less than 30 gallons) if the code is embedded in a switch function. What I am looking for is a way of placing the code that monitors the status of the variable constantly so LINDA detects the change in real time and not just on the prompt of a switch. Is there a place where this sort of code can be placed so that LINDA checks it regularly or, is there something other than a 'function' call that I could use? Otherwise, totally happy camper! Thanks in advance, G
October 4, 20196 yr LINDA primarily waits for button presses and releases before calling the assigned functions. LINDA is also timer driven to monitor and display certain parameters for the likes of the MCP panels. A few of basic offsets are monitored and reacted to using event.offset(). There is a user timer that allows you to place repetitive code in user.lua to carry out he operation you describe. Alternatively, you can set up a event.offset(0x1264, "TotalFuel"). As far as resolution of the parameters are concerned you need to look up the FSUIPC Offset PDF in /modules/fsuipc documents. 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 4, 20196 yr Author Okay, so would a piece of code looking like this, placed in the user.lua file do the trick? event.offset() if ipc.readUD(0x1264)<=30 then fuelwb=sound.playloop("Warning_Fuel_Tone") end Or is that me being too simplistic? btw, the ipc.read offset does the job under a switch function but like I said, only once when the switch is activated. Thanks, G
October 4, 20196 yr It can be that simply. However, you need to separate the event.offset and the code call. There are examples in the common.lua and various aircraft action.lua files. I would however recommend that you user the built in user timer LibUserTime1Hz to repetitively call you fuel warning tone function in the aircraft's user.lua file. Setting up the event.offset requires some deep modification of the main LINDA LUA code (not recommended) or creating your initialisation code and calling it once when you first load the aircraft. 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 4, 20196 yr Author I apologise for how clumsy this must look and it doesn't work but am I close? (In the .user file)... function Init () LibUserTime1Hz=chkf function checkfuel() chkf=ipc.readUD(0x1264) if chkf<=30 then fuelwa=sound.play("Warning_Fuel") fuelwb=sound.playloop("Warning_Fuel_Tone") sound.adjust(fuelwa,-25) sound.adjust(fuelwb,-25) end end end
October 4, 20196 yr You cannot define your own init() as this will prevent LINDA initialising correctly. I would leave this out. You need to define LibUserTimer1Hz in your user.lua file as: function LibUserTimer1Hz() checkfuel() end Then use your checkfuel function without all the ends. I cannot code for you. From past experience try it and see. Edited October 4, 20196 yr by ScotFlieger 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 4, 20196 yr Author Thanks ScotFlieger, I'll pursue this and no, I won't benefit from having someone code for me but a little coaching, like this, goes a long way. Thanks again, G
October 5, 20196 yr This was how I did it, using FSUIPC4 to autoload the lua file: function fuelcheckAll () fuelcheck1 () fuelcheck2 () fuelcheck3 () fuelcheck4 () end function fuelcheck1 (TankEng1) i = ipc.readLvar("L:TankEng1") n = ipc.readLvar("L:Eng1FuelCutOffSwitch") if (0 < i and i <= 35) and (n==1) then alarm_enable () else end end event.Lvar("L:TankEng1", 60000, "fuelcheck1") function fuelcheck2 (TankEng2) i = ipc.readLvar("L:TankEng2") n = ipc.readLvar("L:Eng2FuelCutOffSwitch") if (0 < i and i <= 35) and (n==1) then alarm_enable () else end end event.Lvar("L:TankEng2", 60000, "fuelcheck2") function fuelcheck3 (TankEng3) i = ipc.readLvar("L:TankEng3") n = ipc.readLvar("L:Eng3FuelCutOffSwitch") if (0 < i and i <= 35) and (n==1) then alarm_enable () else end end event.Lvar("L:TankEng3", 60000, "fuelcheck3") function fuelcheck4 (TankEng4) i = ipc.readLvar("L:TankEng4") n = ipc.readLvar("L:Eng4FuelCutOffSwitch") if (0 < i and i <= 35) and (n==1) then alarm_enable () else end end event.Lvar("L:TankEng4", 60000, "fuelcheck4") function alarm_enable () n=ipc.readLvar("L:GearHornSwitch") if n==1 then alarmf=sound.play("STALLHRN") sound.adjust(alarmf, 100) else end end
October 5, 20196 yr Author Hi Masterius, Thanks for this. I sort of boiled it down to suit my ship, which has only one tank and engine and tried to compensate for your Lvars with those that you will see herein. LINDA doesn't like the event.Lvar line claiming that the Lvar is a nil value. This is how I ended up, it's apprent that I'm missing something somewhere else but obviously, I don't know what it is: function fuelcheckAll () fuelcheck () end function fuelcheck () i = ipc.readLvar("L:FUEL TOTAL QUANTITY") n = ipc.readLvar("L:FUEL VALVE ENG1") if(0 < i and i <=30) then alarm_enable () else end end event.Lvar("L:FUEL TOTAL QUANTITY", 1000, "fuelcheck") function alarm_enable () if n==1 then fuelwb=sound.play("Warning_Fuel_Tone") sound.adjust(fuelwb, -100) else end end My previous approach was this: function LibUserTime10Hz () checkfuel () end function checkfuel () if ipc.readUD(0x1264) <=30 then fuelwb=sound.playloop("Warning_Fuel_Tone") sound.adjust(fuelwb,-100) end end That didn't work either but I do know that the ipc.readUD... line works if I place the function under a switch such as the master battery. I think my understanding of 'event' calls is very primitive. Thank you for your help so far, G
October 5, 20196 yr 6 hours ago, Damlimey said: function alarm_enable () if n==1 then fuelwb=sound.play("Warning_Fuel_Tone") Not sure if this is the only error, but you haven't set the "n" variable in the alarm_enable function. You really don't need that variable unless you want to use an aircraft switch to enable/disable the alarm. I used the gear horn as that wasn't actually used in the A2A B-17. Not sure if you have any handy spare switches. Also, you probably need to autoload/run the function/script during sim initialization. I did so using FSUIPC4, but I'm sure there is a way of doing so with LINDA. I'm just not sure how to do that. Edited October 5, 20196 yr by Masterius
October 6, 20196 yr Author Hi all, Success! Of sorts... I have taken on board guidence from ScottFlieger and example code from Masterius and came up with this, which works albeit on a basic level: function LibUserTimer1Hz() ipc.sleep(5000) fuelcheck () end function fuelcheck () i = ipc.readUD(0x1264) if (i <=30) then fuelwb=sound.play("Warning_Fuel_Tone") sound.adjust(fuelwb, -100) --alarm_enable () else end end event.offset(0x1264, "UD", "fuelcheck") I will build on this and I am grateful to you both for your time. Many thanks, G Edited October 6, 20196 yr by Damlimey
October 14, 20196 yr On 10/6/2019 at 4:51 AM, Damlimey said: I will build on this and I am grateful to you both for your time. Many thanks, You're very welcome! Hope you continue having fun with both LINDA and flight sims! ~Al
Archived
This topic is now archived and is closed to further replies.