New Products Flash Sale
Thread Tools
Old Jun 05, 2014, 02:00 PM
Fig Newton is offline
Find More Posts by Fig Newton
Registered User
Fig Newton's Avatar
United States, TX, Burnet
Joined Jan 2013
417 Posts
Discussion
LUA scripting - Technical discussion

I wanted to start a new thread dedicated to Lua scripting so that it doesn't get tangeled up in the OpenTX threads or specific radio threads. I will start this off with a link to a little game I came up with using Lua scripting and the OpenTX v2.0 on my Taranis radio.

http://www.rcgroups.com/forums/showthread.php?t=2180470

I am by no means an expert on this, but have programmed for most of my life. I will put in some placeholder posts for things like a FAQ, or some bookmarks. Let's also make sure that we clearly state which script we are talking about in our posts. I can see this getting quite confusing as the thread advances and more and more scripts are written.
Fig Newton is offline Find More Posts by Fig Newton
Last edited by Fig Newton; Jun 05, 2014 at 02:40 PM.
Reply With Quote
Sign up now
to remove ads between posts
Old Jun 05, 2014, 02:01 PM
Fig Newton is offline
Find More Posts by Fig Newton
Registered User
Fig Newton's Avatar
United States, TX, Burnet
Joined Jan 2013
417 Posts
Placeholder 1. Maybe for a FAQ.
Fig Newton is offline Find More Posts by Fig Newton
Reply With Quote
Old Jun 05, 2014, 02:02 PM
Fig Newton is offline
Find More Posts by Fig Newton
Registered User
Fig Newton's Avatar
United States, TX, Burnet
Joined Jan 2013
417 Posts
Placeholder 2. Some good bookmarks.

projectkk2glider's Lua instructions for OpenTx
https://github.com/opentx/opentx/wik...ting-in-OpenTX

Lua script repository on rcsettings.com
http://rcsettings.com/index.php/view...13-lua-scripts

Lua Gotchas
http://www.luafaq.org/gotchas.html

New Wizard script from davidppoole7 for v2.0.4
http://www.rcgroups.com/forums/showp...1&postcount=58
Fig Newton is offline Find More Posts by Fig Newton
Last edited by Fig Newton; Jul 10, 2014 at 05:35 PM.
Reply With Quote
Old Jun 08, 2014, 01:46 PM
nigelsheffield is online now
Find More Posts by nigelsheffield
Registered User
United Kingdom, Horbury
Joined Oct 2007
6,341 Posts
For the full instruction and all available fields etc opentx docs for lua

https://docs.google.com/document/d/1...ilebasic?pli=1





OK thanks, I'm in, now what do I need to download to make a script from start?
I might be in over my head thinking I could do one but I have programmed for fun a lot of years ago in basic, machine code on zx 81 and spectrum, and a little masm on a PC, so the logic is in there but the knowledge and tools specific to this are not.

Is there a free download which would give me the tools to do the job and some basic instructions/tutorials and are there limitations etc specific to the Taranis?

If this is not really doable then perhaps suggestions and requests for scripts could be posted and built by those that can and then put in at the starting posts for others to use?
nigelsheffield is online now Find More Posts by nigelsheffield
Last edited by nigelsheffield; Sep 13, 2014 at 11:19 AM.
Reply With Quote
Old Jun 08, 2014, 02:13 PM
nigelsheffield is online now
Find More Posts by nigelsheffield
Registered User
United Kingdom, Horbury
Joined Oct 2007
6,341 Posts
Do you think my idea of having dlg flight times defined by pulling a momentary switch displayed in a list is possible? Have followed the links and read through the opentx part but not really sure what's doable and what is not?
I thought it would be a simple case of when the switch is pulled it triggers the script to take the timer 1 and put the results on the screen and then scroll down and do it again next time switch is pulled etc etc, obviously disabling the normal screen while this script is running end only ending when user flicks another switch or something.
Is it more complicated then that , does the screen reset itself every time or something?

Case opened here to see if any advice could be offered.
https://github.com/opentx/opentx/iss...mment-45438770
nigelsheffield is online now Find More Posts by nigelsheffield
Reply With Quote
Old Jun 08, 2014, 06:23 PM
Fig Newton is offline
Find More Posts by Fig Newton
Registered User
Fig Newton's Avatar
United States, TX, Burnet
Joined Jan 2013
417 Posts
Quote:
Originally Posted by nigelsheffield View Post
OK thanks, I'm in, now what do I need to download to make a script from start?
I might be in over my head thinking I could do one but I have programmed for fun a lot of years ago in basic, machine code on zx 81 and spectrum, and a little masm on a PC, so the logic is in there but the knowledge and tools specific to this are not.

Is there a free download which would give me the tools to do the job and some basic instructions/tutorials and are there limitations etc specific to the Taranis?

If this is not really doable then perhaps suggestions and requests for scripts could be posted and built by those that can and then put in at the starting posts for others to use?
Nigel,
Shouldn't need anything special to download. The .lua files are just text files saved in the /SCRIPTS folder on your SD card. The transmitter compiles them for you. I am using a simple text editor and saving them to the scripts folder on the sd card subdir I am pointing CompanionTX to. So when I go to CompanionTX and simulate the radio the scripts are there. You navigate to the lua page and select them.

Update, it's important to note that there are two kinds of lua scripts. Model and One Time. Model scripts are run multiple times a second and sound have certain rules applied to them. They are spelled out in projectkk2glider's instructions I posted above. One time scripts are like the wizard that asks for user input and makes changes to settings.
Fig Newton is offline Find More Posts by Fig Newton
Last edited by Fig Newton; Jun 08, 2014 at 07:15 PM.
Reply With Quote
Old Jun 08, 2014, 06:27 PM
Fig Newton is offline
Find More Posts by Fig Newton
Registered User
Fig Newton's Avatar
United States, TX, Burnet
Joined Jan 2013
417 Posts
Quote:
Originally Posted by nigelsheffield View Post
Do you think my idea of having dlg flight times defined by pulling a momentary switch displayed in a list is possible? Have followed the links and read through the opentx part but not really sure what's doable and what is not?
I thought it would be a simple case of when the switch is pulled it triggers the script to take the timer 1 and put the results on the screen and then scroll down and do it again next time switch is pulled etc etc, obviously disabling the normal screen while this script is running end only ending when user flicks another switch or something.
Is it more complicated then that , does the screen reset itself every time or something?

Case opened here to see if any advice could be offered.
https://github.com/opentx/opentx/iss...mment-45438770
I think this goes into the conversation between model and one time scripts. I am sure what you want is doable, but not sure that you would want a model script popping up text over the main screen. The solution to this would be to be able to put the lua output on the Telemetry page. The script could count your flights and display them on the telemetry page along with other info you want. Bertrand is working on this according to his reply when I brought this up on openrcforums.
Fig Newton is offline Find More Posts by Fig Newton
Reply With Quote
Old Jun 09, 2014, 02:46 AM
nigelsheffield is online now
Find More Posts by nigelsheffield
Registered User
United Kingdom, Horbury
Joined Oct 2007
6,341 Posts
Thanks ,
So one time scripts no good for it and model scripts arent for displaying anything - yet.
I guess the telemetry page would work, a bit limiting but will do, you could could have a page of telemtry with all the flight times on maybe but how would we log each one and then move to the next slot to log the next?.
Sure would be simpler if we could have a direct output to the screen, for instance your GPS heading program could have arrows pointing to where the plane is if you stand facing north!

The main screen could be disabled when scripts want to use the screen, we have voice for alarms etc so never really have to look at the screen anymore for much at all!

Hopefully bertrand will come up with something workable,

How much can be done remains to be seen I suppose, but would be VERY cool if "task" or games based on flight times could be done, for instance dlg ladder task where you must get 30 seconds flight and then a 45 seconds flight and then 1 min etc up to whatever time you want in a given time frame scored according to whatever rules might apply.
There are various other tasks too and could be a great deal of fun for both ales and dlg, take into account GPS and altimeters and games based on reaching certain heights and or waypoints could be conceivable.
nigelsheffield is online now Find More Posts by nigelsheffield
Last edited by nigelsheffield; Jun 09, 2014 at 03:05 AM.
Reply With Quote
Old Jun 09, 2014, 07:52 AM
nigelsheffield is online now
Find More Posts by nigelsheffield
Registered User
United Kingdom, Horbury
Joined Oct 2007
6,341 Posts
I've tried using note to make a file.lua in scripts with a simple screen massage then pointing to it in companion but nothing comes up, your follow me Lua does though but my PC knows yours is a Lua file, does the tx itself need to compile it?
nigelsheffield is online now Find More Posts by nigelsheffield
Reply With Quote
Old Jun 09, 2014, 10:51 PM
Fig Newton is offline
Find More Posts by Fig Newton
Registered User
Fig Newton's Avatar
United States, TX, Burnet
Joined Jan 2013
417 Posts
You shouldn't have to compile the .lua script. The transmitter or simulator should automatically interpret the file. The catch is that if there is an error, you will just have the page where the script is selected sit there. If you hit the exit button, it will show the main lua page with your script and (error) over on the right hand side. This means there is some kind of syntax error usually. Since we don't have any other real tools for it at this point, it's kind of a search and rescue. For my gps heading script, I had to completely tear it down and add the pieces back in until I got the bugs out.

I am happy to say that my V1.4 was flown and tested tonight with excellent results. A slow moving Radian was the test plane, and I thought it did an awesome job. Not that I am bragging, just very thrilled to see it come to life. I have been writing software for years and years and it still gives you that rush when something that took a lot of brainstorming works.

On to the previous comments about the types of scripts. I too am eager to see what Bertrand comes up with. Right now for model scripts the recommendation is not to pop up on the screen, don't adjust values that could affect flight, and be ready for your program to be killed at any time. I think a lot of cool ideas are yet to come, and will make this platform a real game changer (not that it already isn't...)!
Fig Newton is offline Find More Posts by Fig Newton
Reply With Quote
Old Jun 10, 2014, 02:13 AM
nigelsheffield is online now
Find More Posts by nigelsheffield
Registered User
United Kingdom, Horbury
Joined Oct 2007
6,341 Posts
Great, I think you are right about it being a game changer again!
Think of the lua like an app feature for phones, the Taranis is now a smart tx lol.
Regarding my attempts not working, I will try again today and maybe use different text editor or it might be the save type file , but if not I will probably be better waiting till more is decided and know about the lua format etc with some instructions for us.
But good to know you and others can make programs and share them with us and we can pick and choose what ones we want!
nigelsheffield is online now Find More Posts by nigelsheffield
Reply With Quote
Old Jun 11, 2014, 02:47 AM
nigelsheffield is online now
Find More Posts by nigelsheffield
Registered User
United Kingdom, Horbury
Joined Oct 2007
6,341 Posts
Sorry wrong post.
nigelsheffield is online now Find More Posts by nigelsheffield
Reply With Quote
Old Jun 11, 2014, 05:39 AM
mikeshellim is offline
Find More Posts by mikeshellim
Registered User
Joined Dec 2002
249 Posts
Quote:
Originally Posted by Fig Newton View Post
I think a lot of cool ideas are yet to come, and will make this platform a real game changer (not that it already isn't...)!
Not exactly sexy, but it would be really useful to be able to write one time scripts for modifying multiple setups quickly. The sort of thing which happens is you think of a good idea, implement it in one model, and are then faced with replicating the changes in several others.

This is a particular problem which users of my F3F glider setup are having, as I've just released a new version to handle the different mixer processing in OpenTx version 2. Only a few mixers are affected by the changes, but it's enough to make manual modification error prone.

As it stands, I'm not clear if the API already supports the kind of operations needed to implement upgrade scripts (reading, writing and deleting mixers, special functions etc.). It doesn't appear so from the documentation. I guess the focus lately has been (rightly) the core features of v. 2.x. However it would be great if development of the API and documentation were to progress to enable this.
mikeshellim is offline Find More Posts by mikeshellim
Last edited by mikeshellim; Jun 11, 2014 at 07:25 PM.
Reply With Quote
Old Jun 11, 2014, 08:31 AM
nigelsheffield is online now
Find More Posts by nigelsheffield
Registered User
United Kingdom, Horbury
Joined Oct 2007
6,341 Posts
Good idea, if you have lots of models all based one the same programming and mixes and only trims etc are different it would make it easy to update them all.
If we can have a lua script to set up a whole model for us then should be able to do that IF znd when developers allow it to be implemented.
nigelsheffield is online now Find More Posts by nigelsheffield
Reply With Quote
Old Jun 11, 2014, 03:02 PM
scott page is offline
Find More Posts by scott page
|Taranis|>|All other Tx's|
scott page's Avatar
United States, WA, Richland
Joined May 2009
6,779 Posts
Quote:
Originally Posted by nigelsheffield View Post
Good idea, if you have lots of models all based one the same programming and mixes and only trims etc are different it would make it easy to update them all.
If we can have a lua script to set up a whole model for us then should be able to do that IF znd when developers allow it to be implemented.
I think the Tx script for model setup stopped short - it should have also had rates, and expo - not just channels. Perhaps a separate script just for winged aircraft ??
scott page is offline Find More Posts by scott page
Reply With Quote


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion <--it says Discussion, more "birther" issues, Please Discuss Majortomski Life, The Universe, and Politics 27 Dec 17, 2013 05:01 PM
Discussion MELBOURNE and Rural Victoria - Technical and general discussion flyingrally Australia 76 Apr 10, 2008 01:44 AM
Discussion Technical Discussion Pad ghee-grose Alabama's Rocket City Renegades 12 Jan 14, 2006 05:10 AM