Jump to content
The simFlight Network Forums

LUA Recuperation de Lvar


Recommended Posts

Hello

I seek to recover the value of a power Lvar send it to an offset of FSUIPC.

 

I tried two different ways, namely:

 

1)

function RUN_update(time)

   dot=ipc.readLvar("L:AB_AP_ALT_Mode")
   ipc.writreUB(0x66CC, dot) 

end

 

event.timer(100,"RUN_update")

 

2)

function DOT_ALT_chg ("L:AB_AP_ALT_Mode",dot)
   dot = ipc.readLvar("L:AB_AP_ALT_Mode")
   ipc.writeUB(0x66CC,dot)
end

 

event.Lvar("L:AB_AP_ALT_Mode",100,"DOT_ALT_chg")

 
but neither of them work
Can you tell me what's wrong
thank you
 
 
is an indication here is my script SIOC
 
Var 0020, name OFF_DOT_ALT , Link FSUIPC_IN , offset $66CC , Length 1
 
 
It is a Lvar Aerosoft Airbus Extended

 

 

Merci and excuse my english.

Edited by Eagle_For
Link to comment
Share on other sites

I seek to recover the value of a power Lvar send it to an offset of FSUIPC.

 

I tried two different ways, namely:

 

...

   ipc.writreUB(0x66CC, dot)

 

I don't know whether the L:Var name is correct (I don't have that aircraft), but if it is I can see two things wrong:

 

As Roman says, the first example should have "ipc.writeUB" as the function called, not "ipc.writre".

 

The second example shows a little misunderstanding of how a function is defined:

 

function DOT_ALT_chg ("L:AB_AP_ALT_Mode",dot)

 

You cannot provide a constant like ":AB_AP_ALT_Mode" as the name of the parameter to be filled in by the caller. That has to be the name of the variable to receive the name of the LVar. So:

 

function DOT_ALT_chg (name, dot)

 

Okay, you do not use 'name' in the function, but the purpose is to allow one function to handle more than one LVar, so the name then becomes useful. (Sorry, I see the documentation is a little misleading here -- it is expplained in words but the example is poor).

 

The value of that LVar is provided in 'dot', so you don't need to ipc.readLvar in the function at all, it is supplied for you.

 

So this should do it:

function DOT_ALT_chg (name,dot)
   ipc.writeUB(0x66CC,dot)
end

event.Lvar("L:AB_AP_ALT_Mode",100,"DOT_ALT_chg")

The other thing to consider is whether the value returned for the LVar is going to fit adequately in an 8-bit Byte (66CC). Do you know its values? If it is only a 0 or 1, like a switch, then it should be okay, but you need to check. Have you logged its values to see?

 

is an indication here is my script SIOC
Var 0020, name OFF_DOT_ALT , Link FSUIPC_IN , offset $66CC , Length 1

 

I'm afraid I don't know SIOC and cannot comment on whether this is correct.

 

Regards

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.