Jump to content
The simFlight Network Forums
Sign in to follow this  
mudd1293

Help with ipcready.lua

Recommended Posts

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")

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.