Jump to content
The simFlight Network Forums

How can I create a variable in one lua program and evaluate it in another lua program.


Recommended Posts

Posted

 

 

I have lua program that sets a variable to 1.  VarOut.lua.

 

In the attached FSUIPC.log shows “18156 LUA.3: Global: Var1 = 1”.

I have another lua program that I hoped would read and evaluate Var1 = 1. VarIn.lua

Var1 is however only evaluated as == nil

Usually when I have problems like this it’s typo error of syntactical error.

 Thanks for looking

Rozel

VarIn.lua VarOut.lua FSUIPC7.log

Posted

Each lua runs in its own thread and the variables are only global to the thread. To share a variable between luas, use the ipc.set and ipc.get functions - see the FSUIPC Lua Library document.

John

 

Posted

Hi John,

The VarOut.lua I attached does as I expected but the VarIn.lua doesn't seem to get a nul only. Would you take a look at the VarIn.lua and see if  you see my error.

Rozel

VarIn.lua

Posted
3 hours ago, rozelc said:

The VarOut.lua I attached does as I expected but the VarIn.lua doesn't seem to get a nul only.

But the ipc.set in your VarOut.lua doesn't set anything:

ipc.set("Var1")

The syntax as documented is 

ipc.set(“name”, value)

You are setting no value, same as nul.

Pete

 

Posted

Just a quick follow up on my original post.

Using a modification or the TripleUse.lua that senses the push button of a rotary switch and a couple of other lua programs that sense CW or CCW of that rotary switch I can control the range of the mfd map, range of the pfd map and the barometric setting, in the G1000 nxi.

Thank you so much for your help

Rozel

RngBaroDEC.lua PB_RotaryRange.lua INITIALIZE_VARS.lua FSUIPC7.ini RngBaroINC.lua

Posted

@rozelcThats great, thanks. Maybe you could create a topic in the User Contributions section, and attach the files there. I am sure they would be useful to many people.

Thanks,

John

PS. If not, no problem - I'll move them there myself, when I get a chance....

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.