One time lua scripts.

openTx has introduced a range of new features, ideas and bling. It is fast becoming the firmware of choice for many users. openTx will run on ALL current hardware platforms, including the gruvin9x and sky9x boards. Work has already started to support the new FrSky X9D radio!
Post Reply
mrpraline
Posts: 7
Joined: Wed Dec 26, 2012 1:06 pm
Country: -

One time lua scripts.

Post by mrpraline »

Hi,

I'm having trouble understanding 'one time scripts'.

I have some basic lua experience and I've googled for lua script examples and so far I found only mix and telemetry scripts. Together with what's in the reference manual I believe I have a basic understanding how to implement those. However one time scripts seem are a mystery to me.

The reference guide is has a single page on one time scripts and no examples. It seems like the only way to invoke them is through executing them directly from the SD card. I really don't know how to start such a script from 'a specific radio function or when the user selects them from a contextual menu' as it is written in the reference guide.

It seems to me like they should look more or less like wizard scripts, but I can get even the simplest script working.

I tried this as a 'hello world' example:

Code: Select all

local function run(e)
  print("ḧello world")
end
return{run=run}
I also tried

Code: Select all

lcd.drawText(1, 0, "Hello world", 0)
instead of the print()
.
But all I get is a 'Script syntax error'

Does anyone know of a simple example of a 'one time script' and how to invoke them?

User avatar
Kilrah
Posts: 11109
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: One time lua scripts.

Post by Kilrah »

You have examples in the wizard, the S6R script, the crossfire script (the last 2 for 2.2, but you didn't specify a version).

Looks like you're just missing a "return 0" in your function. print() puts out things on the debug serial port, you want lcd.drawText() to actually display on the screen.
mrpraline
Posts: 7
Joined: Wed Dec 26, 2012 1:06 pm
Country: -

Re: One time lua scripts.

Post by mrpraline »

Thanks!
I missed that.
So my guess that they are more or less the same as wizards is correct.

(BTW I'm on 2.1.9)

Post Reply

Return to “openTx”