RegisterSearchFAQMemberlistUsergroupsLog in
Reply to topic Page 1 of 1
Lua scripting comment format / bug from word wrapping
Author Message
Reply with quote
Post Lua scripting comment format / bug from word wrapping 
When first setting up ShiftX2 I pasted in the Disco Lights Demo code from the website into RC using my phone and it didn't work. After quite a bit of time checking everything I finally discovered part of the comment line "--ShiftX2 library functions--" had wrapped so I had:

--ShiftX2 library
functions-- function sxSetLed(i,l,r,g,b,f)

which erroneously gave an undefined function and commented out the sxSetLed function. Not a big deal to fix once found, but leads to a series of questions.

1) The RC Lua script window appears to include word wrapping to scale to your screen size, makes sense. How does that effect / protect situations like this when pasting in code?

2) All other RC sample Lua code given has leading -- for comment lines, but this example also has trailing -- too. I think it's not needed in this case, but does Lua have a start and stop comment syntax like other codes that can be used to quickly (and safely?) comment out many lines at a time?
Edit: Found answer, use --[[ ]] Also suggested trick is use ---[[ --]] so the first '-' can be added/removed to quickly deactivate/activate that block.

3) This might have also been caused by word wrapping the code text in mobile browser view and pasting it in that way, switching to request desktop view might eliminates that. Is this more likely the root cause?

4) Can the RC app please allow access to the Lua script window when not connected to RC hardware? I'd like to debug things like this away from the car.

View user's profile Send private message
Reply with quote
Post  
Hi,

Thanks for the note.

Normally when the script is copied/pasted, the word wrapping should not be turned into line breaks. Something in the middle of the copy/paste operation might have done that.

Also, with the new app we have introduced the concept of Script presets, which loads the script cleanly, preventing any accidental line wraps. Be sure to check it out.

Thanks,


_________________
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter
View user's profile Send private message Send e-mail
Reply with quote
Post  
Thanks Brent. I'm using the latest app.

By Script presets you mean the ability to load from the cloud or some other new feature? I'm using Wifi instead of Bluetooth to connect to RC, so I've not been able to try the cloud icon. If this is what you mean, guess I need to try out Wifi client mode.

View user's profile Send private message
Reply with quote
Post  
Hi, yes, it is a new feature in the latest app. Go to the script window, press "Presets" and you will see a list of script presets.

Be sure to press the cloud update button to get the latest.

The one loaded right now is the demo script which will work with your ShiftX2 (requires 2.15.0 firmware or higher).

Hope this helps,


_________________
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter
View user's profile Send private message Send e-mail
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum