Jump to content
The simFlight Network Forums

Recommended Posts

Posted

I have been struggling with this error for the past 2 hours. Can't seem to clear it. I have reread the Lua documents and viewed several FSUIPC7 Plugins.

The error and code are:

********* LUA: "Alpha_Buttons" Log [from FSUIPC version 7.3.25] *********
  3128781 System time = 13/11/2023 11:33:10, Simulator time = 11:33:15 (16:33Z)
  3128781 LUA: beginning "C:\FSUIPC7\Alpha_Buttons.lua"
  3128781 *** LUA Error: C:\FSUIPC7\Alpha_Buttons.lua:13: 'then' expected near '='
  3128797 >>> Thread forced exit (ipc.exit or os.exit) <<<
  3128797 System time = 13/11/2023 11:33:10, Simulator time = 11:33:15 (16:33Z)
********* LUA execution terminated: Log Closed *********

7        k1 = 13                
8        k2 = 14                
9    function TOGGLE_AVIONICS_MASTER(joynum, button, downup)                    
10        b = button                
11        avstate = ipc.readSD(0x2E80)                
12        display.show(h, 1, "Avionics " .. avstate .. "On Off")                
13        if b = k1 then                
14            if avstate = 0 then        -- AV is off            
15                ipc.log("AV_Alpha On")        
16                ipc.control(66293,0) -- turn  AV on        
17            else            
18                ipc.log("AP_Alpha On No Chg")        
19            end            
20            return            
21        end                
22        if b = k2 then                
23            if avstate > 0 then        -- AV is on            
24                ipc.log("AP_Alpha Off")        
25                ipc.control(66293,0) -- turn  AV off        
26            else            
27                ipc.log("AV_Alpha Off No Chg")        
28            end            
29            return            
30        end                
31        ipc.log("Error AV_Alpha On Off")                
32    end                    
 

I have tried several itterations:

if button = 13 then

k = 13

b = button

if b = k then

etc. 

No matter what I don I receive the error 

Posted
36 minutes ago, DrDave- said:

14            if avstate = 0 then        -- AV is off            

For testing values, use '==' not '=', e.g.
   if avstate == 0 then
  ....

A single '=' is used for assignment, not conditionals.

Posted
33 minutes ago, DrDave- said:

12        display.show(h, 1, "Avionics " .. avstate .. "On Off")                

The display library is for WideClient only. If not using WideClient. you probably want to use ipc.display. However, the SimConnect text display functions are no longer working in MSFS. You may see something, but it is not reliable and the underlying functions have been deprecated. For displaying information in a window from lua, you should use the Wnd library.

John

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
×
×
  • 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.