Jump to content
The simFlight Network Forums

LUA Error: Aerosoft Airbus + FS Linda


Recommended Posts

Hello Pete and team,

 

My script is as below, and the error I get is below, what I don't understand is what have I missed?

 

 
Syntax error!
 
...Steam\steamapps\common\FSX\Modules
Line:
22: attempt to call field 'Lvar' (a nil value)
stack traceback:
...Steam\steamapps\common\FSX\Modules\linda\lua\tmp.lua:22: in main chunk
-- This function will be called when the lvars
-- change. (See events below)
function lvarChanged(varname, value)
    -- Check which lvar has changed
    if varname == "AB_AP_AP1" then
       -- Write the value (in this case 1 byte)
       -- into an offset
       ipc.writeUB(0x66C0, value)
    elseif varname == "AB_AP_AP2" then
       ipc.writeUB(0x66C1, value)
    end
end


-- Set up events to call the function above
-- when the lvar changes.
event.Lvar("AB_AP_AP1", 100, "lvarChanged")
Link to comment
Share on other sites

My script is as below, and the error I get is below, what I don't understand is what have I missed?

 

 
Syntax error!
 
...Steam\steamapps\common\FSX\Modules
Line:
22: attempt to call field 'Lvar' (a nil value)
stack traceback:
...Steam\steamapps\common\FSX\Modules\linda\lua\tmp.lua:22: in main chunk
-- This function will be called when the lvars
-- change. (See events below)
function lvarChanged(varname, value)
    -- Check which lvar has changed
    if varname == "AB_AP_AP1" then
       -- Write the value (in this case 1 byte)
       -- into an offset
       ipc.writeUB(0x66C0, value)
    elseif varname == "AB_AP_AP2" then
       ipc.writeUB(0x66C1, value)
    end
end


-- Set up events to call the function above
-- when the lvar changes.
event.Lvar("AB_AP_AP1", 100, "lvarChanged")

 

Is that event.Lvar line number 22? It doesn't count to 22 but maybe you've taken an extract?

 

I've just saved your plug-in above as "TestLvar" and with Trace/Debug Lua option enabled in FSUIPC I get this okay results logged:

 

   191054 LUA.0: beginning "E:\Steam\steamapps\common\FSX\Modules\testlvar.lua"
   191054 LUA.0: E:\Steam\steamapps\common\FSX\Modules\testlvar.lua:12
   191054 LUA.0: Global: ipcPARAM = 0
   191054 LUA.0: E:\Steam\steamapps\common\FSX\Modules\testlvar.lua:3
   191054 LUA.0: E:\Steam\steamapps\common\FSX\Modules\testlvar.lua:17
   191054 LUA.0: Waiting for an event in "E:\Steam\steamapps\common\FSX\Modules\testlvar.lua"
 
Line 17 seems correct for the last line in your plug-in.
 
BTW please always state the version of FSUIPC in use. If not at least 4.949 please update.
 
Pete
Link to comment
Share on other sites

Hi Pete,

 

That is the entire script and its the latest I brought it a few days ago 4.949.

 

In essence what I want too do is detect the autopilot state AB_AP_AP1 and write to 66C0 so I can then write and read from that offset.

 

Best regards

Link to comment
Share on other sites

That is the entire script and its the latest I brought it a few days ago 4.949.

 

In essence what I want too do is detect the autopilot state AB_AP_AP1 and write to 66C0 so I can then write and read from that offset.

 

The Lua, exactly as you have it there, all 17 lines of it (no line 22 possible with only 17 altogether) loads fine here.

 

Enable Lua debug/trace in the Logging tab and load the plug-in again. Show me the log. i want to see how it can be different to the exact same plug-in here!

 

BTW your subject title mentions Linda. What has that to do with this? Are you sure you are checking the correct Lua file? Doesn't Linda use a lot of different ones?

 

Pete

Link to comment
Share on other sites

I will do Pete,Linda I have installed and when I created that script that was the error Linda was giving me.

 

Really stupid question, I add an auto section to FSUIPC.ini with the name of the script right?

 

It must be me doing something stupid

Link to comment
Share on other sites

Really stupid question, I add an auto section to FSUIPC.ini with the name of the script right?

 

You mean to just run your Lua plug-in, as you showed me, on it's own? I take it that you were running Linda before?  Did you call your bit tmp.lua? As in

 

Steam\steamapps\common\FSX\Modules\linda\lua\tmp.lua

 

If you want to run it on its own, yes, you can start it via an Auto parameter line. But just to test it would be easier to put it directly into the Modules folder (not Modules\Linda\Lua) and assign a spare keypress or button to it, one to can remove later. If it's in the Modules folder when FS is loaded it wil be assignable in the drop-downs as "Lua tmp" (or whatever you call it instead of "tmp", because I don't think that tmp.lua can be exactly your code as it has at least 22 lines and yours only 17, as I said).

 

Pete

Link to comment
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
×
×
  • 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.