Jump to content
The simFlight Network Forums

Recommended Posts

Posted

I am in the process of learning how to use lua scripting. I've been reading the doc's and reviewing several other users contributed scripts. I've written some basic scripts now myself. One function I have not figured out how to use properly is "ipcparam".

I gathered from review of several other scripts and the documentation that it reads a parameter that is sent to a lua script and can be used in things like if/then/else statements. With that idea I wrote a variety of very simple test scripts. Here's one that I used:


ipc.display("PARAM TEST START")
ipc.sleep(2000)
if ipcparam == 1 then
ipc.display("PARAM 1")
ipc.sleep(2000)
elseif ipcparam == 2 then
ipc.display("PARAM 2")
ipc.sleep(2000)
elseif ipcparam == nil then
ipc.display("PARAM IS NULL")
ipc.sleep(2000)
else
ipc.display("PARAM 1, 2, or NUL NOT DETECTED")
ipc.sleep(2000)
end

ipc.display("PARAM TEST END")
ipc.sleep(2000)
[/CODE]

What I'm not understanding is how to send the parameter to the script. After bouncing some ideas around with a more experienced script writer I did the following in hopes that this was the proper method.

I assigned a button via FSUIPC to launch the above script (C90 TEST.lua) by selecting "[i]lua C90 TEST[/i]" in the "[i]Control sent when button pressed[/i]" drop down menu, and set the [i]Parameter[/i] entry for that button to [i]1[/i]. What I hoped to see, of course, was my displayed message of "[b]PARAM 1[/b]". That's not what happened though. No matter what I set the parameter value to 0, 1, 2, 3, etc. I got the "[b]PARAM IS NULL[/b]" message.

So, obviously I'm not doing this right, or ipcparam reads values from some other source, or it is not intended for the purpose I thought it was.

Any advice, direction, wisdom, or insight (or a dope slap) would be greatly appreciated.

Tom G.

Posted

Ah, that is why I said I'm no programer!

The obvious does not catch my eye ...


ipc.display("PARAM TEST START")
ipc.sleep(2000)
if ipcPARAM == 1 then
ipc.display("PARAM 1")
ipc.sleep(2000)
elseif ipcPARAM == 2 then
ipc.display("PARAM 2")
ipc.sleep(2000)
end
ipc.display("PARAM TEST END")
ipc.sleep(2000)
[/CODE]

this is working.

LUA is [b]CASE SENSITIVE![/b]

The correct command is [b]ipcPARAM[/b], not ipcparam.

Same if you have Variables: [b]Var [/b]ist the same as [b]var[/b]

:razz:

Posted

That was it! THANKS!!!

I can't believe I got bit by something so basic... :oops:

I now have a new tool in the lua tool box!

I'm off to work now, but with visions of lua scripts dancing in my head! :mrgreen:

Posted

Paul and Gunter, between the two of you and Pete I may actually get to the point where I have a clue about this lua stuff THANKS!!!!!!

With the help the two of you have provided I have almost all my basic switch functions up and running on my King Air. This weekend I'll be baning my head agast the keyboard trying to figure out how Carnado implements timers in their code... http://forum.simflight.com/topic/72914-carenado-king-air-c90-switch-timers/

Again, THANKS!

Posted

Tom,

as I see how you try to trap LUA variables with the log file: please try LINDA!!!!

Just for hunting LUA variables it is a lot lot easier.

You can immediately try out LUA variables from the LINDA GUI with parameters you want!

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.