Tom_G_2010 Posted November 1, 2012 Report Posted November 1, 2012 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)endipc.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.
guenseli Posted November 1, 2012 Report Posted November 1, 2012 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)endipc.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:
Tom_G_2010 Posted November 1, 2012 Author Report Posted November 1, 2012 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:
guenseli Posted November 1, 2012 Report Posted November 1, 2012 I got bit by something so basic... happens to me every day :razz:
Gypsy Baron Posted November 2, 2012 Report Posted November 2, 2012 happens to me every day :razz: Now THAT explains a lot, Günter ! :razz: paul
Tom_G_2010 Posted November 2, 2012 Author Report Posted November 2, 2012 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!
guenseli Posted November 2, 2012 Report Posted November 2, 2012 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!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now