RCU Forums - View Single Post - FRSky Taranis Beginners Support Group
View Single Post
Old 02-02-2020, 07:43 AM
  #211  
tedsander
 
Join Date: Jul 2004
Location: White Bear lake, MN
Posts: 758
Likes: 0
Received 68 Likes on 64 Posts
Default

Originally Posted by Jim.Thompson
Lua Scripts.

I have read some of the literature ostensibly explaining what these are and what they are used for etc.
However, the more I read, the more abstract and unclear the descriptions became.
Are these important to understand for the beginner? Or for the experienced OpenTx user?

I seem to have all the functions for the models I have set up so far with OpenTx while remaining in blissful ignorance of "LUA scripts"
Is there someone can set my mind to rest about these please?
Should I tackle them seriously and read more?

Jim.
Have you been lurking on my posts over on the other forums??? (Just joking....)

Starting a couple of weeks ago, I decided to dip into lua. Initially just wanted to do something additional that the vast capabilities of the radio couldn't do. In this case: "If this is the first start up of the day, reset a global variable to "0", and reset one of the timers.". It was "first startup of the day" part the radio couldn't automatically do without lua. It was only every startup, or none.
While I have done a moderate bit of coding, I am in no way qualified to even be called a "lua newbie". There is a huge amount of writing lua in OpenTX I don't understand ...
To specifically answer:

You can rest assured that you can remain blissfully ignorant for all of your days.

Lua allows for more complicated logic and program flows than does the included world of logical switches. It is a full on programming language. It allows one to create custom screens, displaying bits of information that otherwise would not be available. And it can serve to pass information back and forth - to/from data files, talking to things like flight controllers (for initial configuration), etc.
While it can be used to change behaviors in flight, it is strongly, strongly advised to never do so. It is a secondary process, and if the radio needs the memory or processing to fly the plane, it will stop any running lua programs. Which would be bad if you had a lua program directing, say, your elevator.....
It is primarily used for:
1. Displaying custom screens that report telemetry information and "current state" values ("Throttle is at 30%", "Flight controller is in return to home mode", etc) or information derived from those values ("your average flight time today was XX:XX")..
2. Custom screens to read/write/pass some configuration parameter when not flying, either to the radio or connected device. ("Reset a timer", "Set a new value to be used for mixing", "Tell a flight controller to initialize GPS", etc.) (and most of those can be done without lua!)
- the "Create new model" wizard is an extreme example of this.

That said, there are a great number of scripts that you may find helpful. Think of them as add-on "apps" for your transmitter that you may find very useful for analyzing information, or in helping you set up things:
Installing and running lua scripts written by others is usually very easy. Drop the file onto the SD card, and follow the instructions from the author on how to get it running. Usually by configuring a custom screen on the Telemetry tab of the radio, which is just a couple of button pushes to set up (but there are a couple of other ways to run some types of scripts, so go by what the author says).
As always, save all of your current models to the computer, so you can easily restore if you don't like it. Don't forget to delete any files put on the SD card, if uninstalling.
Scripts written by Miami Mike, Mike Shellim, or I shems referenced over on RCGroups may be of interest to try.
https://rc-soar.com/opentx/
https://www.rcgroups.com/forums/member.php?u=15789
https://www.rcgroups.com/forums/member.php?u=577751
https://rcsettings.com/index.php/vie...13-lua-scripts

Actually writing scripts yourself? That takes you into a whole 'nother world of burning many hours of writing programming code. Which for some, can be fun in itself...and for others the worst possible way to spend their time.
See my first ever attempt just posted. https://www.rcgroups.com/forums/member.php?u=82725

Ted

Last edited by tedsander; 02-02-2020 at 07:55 AM.