mudd1293 Posted January 16, 2012 Report Posted January 16, 2012 Hi, I’m trying my best to understand how to use lua for my pmdg js 41 and I’ve gotten some knowledge with regards to it. However, I'm having trouble using the ipcready.lua script. When trying to figure out how to activate the parking brake and turn on a led , I found this provided by Pete to another use: function set_brake(offset, value) if value == 32767 then gfd.SetLight(GFP8, 1, 7) else gfd.ClearLight(GFP8, 1, 7) end end event.offset(0x0BC8, "SW", "set_brake") I changed it to work with my go flight hw and it works when it’s the only thing in the ipcready.lua script. However, if I add anything else to it, it doesn’t work (see below, which includes a script that someone made for thePMDG js41 – it also works when it’s by itself, but not with the above script). I’m sure it’s user error, but cant’ figure out what I’m doing wrong. Any help would be appreciative. prevHDG = -1 prevSPD = -1 prevALT = -1 while 1 do HDG = ipc.readLvar ("L:HDGBug") if HDG ~= prevHDG then stringHDG = string.format("%03d", HDG) gfd.setDisplay(GFMCP,0,1,stringHDG) prevHDG = HDG end SPD = ipc.readLvar ("L:IASBug") if SPD ~= prevSPD then stringSPD = string.format("%03d", SPD) gfd.setDisplay(GFMCP,0,2,stringSPD) prevSPD = SPD end ALT = ipc.readLvar ("L:AltSelAlt") if ALT ~= prevALT then stringALT = string.format("%05d", ALT) gfd.setDisplay(GFMCP,0,4,stringALT) prevALT = ALT end ipc.sleep(50) end function set_brake(offset, value) if value == 32767 then gfd.SetLight(GFP8, 1, 7) else gfd.ClearLight(GFP8, 1, 7) end end event.offset(0x0BC8, "SW", "set_brake")
Pete Dowson Posted January 17, 2012 Report Posted January 17, 2012 I’m trying my best to understand how to use lua for my pmdg js 41 and I’ve gotten some knowledge with regards to it. However, I'm having trouble using the ipcready.lua script. When trying to figure out how to activate the parking brake and turn on a led ... I changed it to work with my go flight hw and it works when it’s the only thing in the ipcready.lua script. However, if I add anything else to it, it doesn’t work (see below, which includes a script that someone made for thePMDG js41 – it also works when it’s by itself, but not with the above script). I’m sure it’s user error, but cant’ figure out what I’m doing wrong. Any help would be appreciative. The problem is that the first part is event-driven -- i.e. it sits in memory waiting for something to happen, and does nothing until that happens, whilst the second part is in a never-ending loop testing for something. If you wanted them in one plug-in you'd have to re-write one or the other -- either to do everything in a never-ending loop, or to make everything event-driven. Really the best step is to keep both parts separate altotgether. Save then as two differently named Lua modules. As an example I'll call one of them A.lua and the other B.lua. Save both in the Modules folder. Now you can get them loaded in one of two ways. The first, using ipcReady.lua, is simply to make that lua load the others, as follows: ipc.runlua("A") ipc.runlua("B") That's it, all you need in ipcReady.lua. When you want other plug-ins to run automatically, add similar lines here with their names. The second way is to use the facilities to execute macros automatically. This is by adding an [Auto] section in the FSUIPC INI file: [Auto] 1=lua A 2=lua B Again, that can be extended as needed. Regards Pete
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now