Lua syntak error

Help with any software/desktop related issues. e.g. companion9x, eePe, etc
Post Reply
Raythegreat
Posts: 191
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Lua syntak error

Post by Raythegreat » Sun Jan 13, 2019 7:52 pm

Hi,

I'm starting to learn about LUA scripts on Taranis+. I have never used Lua before but know very well the C language.

I saved with Notepad++ the file named pr.lua the following program and when I execute this lua script in the radio setup I have the following error message: "script syntax error".
I saved it on SD card in SCRIPTS/FUNCTIONS

Please advise what can be the problem? Scripts is below.
Thanks,


lcd.clear()
lcd.drawText(1, 1,"drawText() example", 0)
lcd.drawText(1, 11,"0 - default", 0)
lcd.drawText(1, 21,"BLINK", BLINK)
lcd.drawText(1, 31,"INVERS + BLINK", INVERS + BLINK)
lcd.drawText(120, 1,"XXLSIZE", DBLSIZE)
lcd.drawText(120, 21,"MIDSIZE", MIDSIZE)

rdeanchurch
Posts: 614
Joined: Tue Dec 27, 2011 11:22 pm
Country: -
Location: Gardnerville, Nv

Re: Lua syntak error

Post by rdeanchurch » Mon Jan 14, 2019 12:51 am

If that is the complete program, you need to put a wrapper on it.

local function run()
lcd.clear()
lcd.drawText(1, 1,"drawText() example", 0)
lcd.drawText(1, 11,"0 - default", 0)
lcd.drawText(1, 21,"BLINK", BLINK)
lcd.drawText(1, 31,"INVERS + BLINK", INVERS + BLINK)
lcd.drawText(120, 1,"XXLSIZE", DBLSIZE)
lcd.drawText(120, 21,"MIDSIZE", MIDSIZE)
print (" @#$% @#$% @#$% @#$% @#$% pr.lua run()")
end
return { run=run }

BUT first read about function scripts in
https://opentx.gitbooks.io/opentx-2-2-l ... ripts.html
Particularily,
"
Limitations
should not exceed allowed run-time/ number of instructions.
all function scripts are stopped while one-time script is running (see Lua One-time scripts)
Function scripts DO NOT HAVE ACCESS TO LCD DISPLAY
"
The print statement shows in runs, but nothing shows on the LCD.
Try running it as a Telemetry script.
Dean
OldDmbThms: 1. Takeoff, 2. Crash, 3. Repair, GOTO 1

Raythegreat
Posts: 191
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Lua syntak error

Post by Raythegreat » Mon Jan 14, 2019 1:54 am

Thanks rdeanchurch,

Yes I I forgot the wrappers, they were not there.
Do I absolutely need an init and run functions? Like the main() in C language?
How do I show something of the LCD? Let's say I want to print Rudder = 76 and see the result on my screen?

Thanks,
RTG

rdeanchurch
Posts: 614
Joined: Tue Dec 27, 2011 11:22 pm
Country: -
Location: Gardnerville, Nv

Re: Lua syntak error

Post by rdeanchurch » Mon Jan 14, 2019 2:49 am

Use a Telemetry script.
As I'm flyer, I use voice for in critical flight information so I do not have to look at the lcd.
Since I don't necessarily have the telemetry screen showing, I often put critical announcements in background(), but if there is nothing you want to setup initially or run even when the telemetry screen isn't being displayed, then you do not need init() or background().
You can playFile of the rudder, throttle, ...
Dean
OldDmbThms: 1. Takeoff, 2. Crash, 3. Repair, GOTO 1

Raythegreat
Posts: 191
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Lua syntak error

Post by Raythegreat » Mon Jan 14, 2019 3:05 am

Thank you again rdeancherch.

Where can I find a list and the description of parameters of allowable lua functions for Taranis?
That would help me greatly. I looked around and found no place where functions are listed with their parameters description (for the Taranis).

RTG


rdeanchurch
Posts: 614
Joined: Tue Dec 27, 2011 11:22 pm
Country: -
Location: Gardnerville, Nv

Re: Lua syntak error

Post by rdeanchurch » Mon Jan 14, 2019 3:41 am

In the same document that the above url points to
https://opentx.gitbooks.io/opentx-2-2-l ... guide.html

Best to start at the beginning
https://opentx.gitbooks.io/opentx-2-2-l ... e/content/
Dean
OldDmbThms: 1. Takeoff, 2. Crash, 3. Repair, GOTO 1

Raythegreat
Posts: 191
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Lua syntak error

Post by Raythegreat » Mon Jan 14, 2019 3:58 am

Many thanks rdeanchurch

RTG

Post Reply

Return to “Software”