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

GFMcp lua issues

Recommended Posts

hi Pete and all how maybe able to help

 

i have found and modified Goflight pro MCP Lua script but I have hit wall with IAS/MACH Crossover. It is falling over in the IAS/MACH section stringSPD = string.format("%03d", SPD) saying unexpected symbol near '=='

 

is the a better why to write this section, if how can i fix it.

 

prevCRS1 = -1
prevSPD = -1
prevHDG = -1
prevalt = -1
prevVS = -1
prevCRS2 = -1
prevMACH = -1
--************************All Working*************************************************
while 1 do
CRS1 = ipc.readSW("0C4E")
if (CRS1 ~= prevCRS1) then
stringCRS1 = string.format("%03d", CRS1)
gfd.setDisplay(GFMCPPRO,0,0,stringCRS1)
prevCRS1 = CRS1
end
HDG = ipc.readSD("07CC")
if (HDG ~= prevHDG) then
stringHDG = string.format("%03d", ((HDG/65536)*360))
gfd.setDisplay(GFMCPPRO,0,2,stringHDG)
prevHDG = HDG
end
alt = ipc.readSD("07D4")
if (alt ~= prevalt) then
stringalt = string.format("%05d", ((alt/65536)*3.2809))
gfd.setDisplay(GFMCPPRO,0,3,stringalt)
prevalt = alt
end
VS = ipc.readSW("07F2")
if (VS ~= prevVS) then
stringalt = string.format("%05d", VS) 
gfd.setDisplay(GFMCPPRO,0,4,stringalt)
prevVS = VS
end
CRS2 = ipc.readSW("0C5E")
if (CRS2 ~= prevCRS2) then
stringCRS2 = string.format("%03d", CRS2)
gfd.setDisplay(GFMCPPRO,0,5,stringCRS2)
prevCRS2 = CRS2
end
--*******************************************************************************************************
 
--*******************IAS/MACH Crossover NEED Help!!!!!!!!!!!!!****************************************
if ipc.readUD("07DC" and "07E4") == 0 then
SPD = ipc.readSW("07E2")
if (SPD ~= prevSPD) then
stringSPD = string.format("%03d", SPD)
gfd.SetDisplay(GFMCPPRO,0,1,stringSPD)
prevSPD = SPD
end
else ipc.readUD("07DC") == 1 and ("07E42") == 0 then
SPD = ipc.readSW("07E2")
if (SPD ~= prevSPD) then
stringSPD = string.format("%03d", SPD)
gfd.SetDisplay(GFMCPPRO,0,1,stringSPD)
prevSPD = SPD
end
else ipc.readUD("07DC") == 0 and ("07E42") == 1 then
MACH = ipc.readSD("07E8")
if (MACH ~= prevMACH) then
stringMACH = string.format ("%02f", MACH/65536)
gfd.SetDisplay(GFMCPPRO,0,1,stringMACH)
prevMACH = MACH
end
--**********************************************************************************************
    ipc.sleep(200)
end
 
Thanks
 
Johan

Share this post


Link to post
Share on other sites
i have found and modified Goflight pro MCP Lua script but I have hit wall with IAS/MACH Crossover. It is falling over in the IAS/MACH section stringSPD = string.format("%03d", SPD) saying unexpected symbol near '=='Regards

 

It would have been more precise if you had shown me the actual error message. I had to extract your code, save it as a Lua, and try loading it to find the actual line. The error message is:

 

 *** LUA Error: E:\FSX\Modules\GFMCP.lua:50: unexpected symbol near '=='

 

In other words, Line 50, not the line 46 you quote! The line in question is therefore:

 

else ipc.readUD("07DC") == 1 and ("07E42") == 0 then

 

which has a meaningless statement between the else and the then, with several errors. Looks like you might have omitted an "if" and an "ipc.readUD" and inserted an extra character in "07E42" !!! And I think you've repeated this further down.

 

I do not provide a code debugging or checking service, sorry. Please use the tools available. Once you get the syntax correct throughout, use the FSUIPC built-in tracing facilty to find execution errors (see the Logging page).

 

Pete

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

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.