Lua IDE programming for Nspire

908 views
Skip to first unread message

math7

unread,
Oct 15, 2012, 2:35:15 AM10/15/12
to tins...@googlegroups.com
Hello all,

anyone know if Lua can be programmed in any IDE that is different TI Nspire Software?, because I believe it would be more convenient to leverage the capabilities that have some IDE like Eclipse to program in Lua

Adriweb

unread,
Oct 15, 2012, 9:52:56 AM10/15/12
to tins...@googlegroups.com
I've worked with Intellij Idea recently (with its great Lua plugin) and I can only say it's the best Lua IDE I've seen and worked with so far. The auto-completion etc. is very useful :D I've also made a plugin so that it links the nspire-lua library against Inspired-Lua and you can get a help popup anytime loading the function documentation !
Its "re-format code" is quite awesome : it just re-indents everything and cleans stuff :)


You can download the Lua plugin inside directly.
I can give you my Nspire-Lua add-on later.

TRMP

unread,
Oct 15, 2012, 10:18:10 AM10/15/12
to tins...@googlegroups.com
Hi Adriweb, can u plz post your Nspire-Lua add-on, because i download IntelliJ IDEA and Im a little lost... tnx

math7

unread,
Oct 16, 2012, 2:40:32 AM10/16/12
to tins...@googlegroups.com
Thanks Adriweb is excellent news, as I dropped the IntelliJIDEA and I'll see if I can download the plugin for Lua, and I'll be waiting if you can send me your add on, I appreciate it,

Adriweb

unread,
Oct 16, 2012, 2:56:34 PM10/16/12
to tins...@googlegroups.com
Just follow the guide here to install Intellij + the Lua plugin.
(text first then there are screenshots)

I'll post my nspire-lua addon later but let me tell this right away : I havetn't figured out a way yet to have proper autocompletion of dot-based methods (sadly 99% of the nspire lua api....). But anyway the overall lua plugin makes it context based so it's good enough.

math7

unread,
Oct 16, 2012, 11:08:42 PM10/16/12
to tins...@googlegroups.com
I downloaded the IntelliJ IDEA plugin and downloaded the correct Lua and this plugin is very good, has code completion and you need to Lua, I'll be waiting for the release of your plugin for Nspire, thanks


El lunes, 15 de octubre de 2012 00:35:15 UTC-6, math7 escribió:

Jim Fullerenex

unread,
Oct 17, 2012, 9:38:57 AM10/17/12
to tins...@googlegroups.com
Hi Adrien,

Is there a Lua plugin for eclipse? I'm using Juno, btw.

Thanks,

Jim
--
To post to this group, send email to tins...@googlegroups.com
To unsubscribe send email to tinspire+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com.au/group/tinspire?hl=en-GB?hl=en-GB
The tns documents shared by group members are archived at
https://sites.google.com/site/tinspiregroup/classroom-news/welcome-abouttime

TRMP

unread,
Oct 17, 2012, 6:29:18 PM10/17/12
to tins...@googlegroups.com
I thought the Nspire-Lua add-on is a TNS file, inst!?
TY

Adriweb

unread,
Oct 18, 2012, 10:27:30 AM10/18/12
to tins...@googlegroups.com
Hi,

I have not used/tried it, though.

Adriweb

unread,
Oct 18, 2012, 10:28:10 AM10/18/12
to tins...@googlegroups.com
No, the addon is for the IDE, it has nothing to do with a .tns files. It describes the Lua API for the Nspire etc.
I'll look into that soon.

TRMP

unread,
Oct 18, 2012, 2:35:36 PM10/18/12
to tins...@googlegroups.com
You can now post the nspire-lua addon?
Cheers m8.


Em terça-feira, 16 de outubro de 2012 15h56min34s UTC-3, Adriweb escreveu:

math7

unread,
Oct 18, 2012, 3:19:26 PM10/18/12
to tins...@googlegroups.com
I have been using and testing IntelliJ IDEA and the truth is it's fantastic, it's a very complete editor with many utilities as Adriweb said, I recommend is amazing and Lua plugin is downloaded with it is very complete, just need to wait the add-on for the Nspire of Adriweb and be even better

El lunes, 15 de octubre de 2012 00:35:15 UTC-6, math7 escribió:

Adriweb

unread,
Oct 18, 2012, 4:04:50 PM10/18/12
to tins...@googlegroups.com
All right, I tested it on a fresh computer setup to make sure it works well. Looks like it's all good !
It's quite nontrivial to set up but it's worth it :P

Basically, you can do either : 

This (longer but it will make seperate SDKs for normal computer Lua and Nspire Lua)
  1. Download Lua for windows 5.1
  2. Add a new Lua SDK in Intellij (you can find that in the module settings, for example)
  3. Select the Lua folder in program files as the lua sdk folder.
  4. Download my addon and decompress it somewhere
  5. Add from my addon the folder "nspirelua-api" as an external classpath folder in your new SDK 
  6. Save, apply, etc.
or (easier/faster but it will make computer lua think it has nspire lua API available) :
  1. In Intellij's ( / module's ) settings, edit the KahLua SDK
  2. Download my addon and decompress it somewhere
  3. Add from my addon the folder "nspirelua-api" as an external classpath folder in your new SDK 
  4. Save, apply, etc.

After all that, create a new Lua project, and in the libraries on the left side, you should see not only the stdlib (of which you can unlink the io and debug API which aren't present on the Nspire), and you should be able to enjoy Intellij's Lua plugin things but for the Nspire Lua API too.

This it what it looks like when it's set up, on my computer :

Autocompletion example (of the events and other functions ) :




Auto-completion + arguments help : 



Interactive documentation based on Inspired-Lua's wiki :  (Ctrl-Q on a word)




Good luck and have fun :)

nspirelua-api.zip

math7

unread,
Oct 18, 2012, 9:14:17 PM10/18/12
to tins...@googlegroups.com
Hello Adriweb ,

 I've tried the plugin and it is excellent, it does recognize the Lua API for Nspire and also shows support for each Lua function is very good, however I have a question ...

if I make a function with "on.paint" for example, are within the body of the function if I call "gc", effectively leaving support for the autocompletion, but the options appear with a "." instead of colon ":" is correct in this way?

And another question: when you run the program in IntelliJ IDEA fails because it does not recognize the Nspire commands, but it would be possible in the future build or attach an emulator for this IDE?

Thanks and keep up the excellent project

Note: image attached

El lunes, 15 de octubre de 2012 00:35:15 UTC-6, math7 escribió:
gc capture.png

math7

unread,
Oct 19, 2012, 12:20:06 AM10/19/12
to tins...@googlegroups.com
Hi Adriweb,

This add-on contains autocomplete for the physics engine of the Nspire Lua?  I write some functions of the API reference guide and the plugin did not show me the code completion for the physics engine functions.


El lunes, 15 de octubre de 2012 00:35:15 UTC-6, math7 escribió:

Adrien Bertrand

unread,
Oct 19, 2012, 2:08:24 AM10/19/12
to tins...@googlegroups.com
Indeed I didn't put the Physics API at the time I made it, sorry. Don't worry, I'll try to add that tonight :)
--

Adriweb

unread,
Oct 19, 2012, 7:44:20 AM10/19/12
to tins...@googlegroups.com
Hi,

 I've tried the plugin and it is excellent, it does recognize the Lua API for Nspire and also shows support for each Lua function is very good, however I have a question ...
Thanks ! 


if I make a function with "on.paint" for example, are within the body of the function if I call "gc", effectively leaving support for the autocompletion, but the options appear with a "." instead of colon ":" is correct in this way?
This is an issue I've been struggling with and I don't think it can be fixed actually (so far). Indeed I added the gc recognition at least it works when you type "gc.". When you're not in a function where gc is passed, it works as expected but if you're in a paint function, the IDE recognizes it as a local variable and doesn't show the things you would expect... I have 2 solutions : 
  1. Temporarily remove "gc" from your function's parameter. Edit your code etc. and put back those 2 letters in the function.
  2. instead of writing gc:drawString(...), write gc.drawString(gc, ...). This is the exact same thing and you'll get autocompletion too. However the code will look weird, that's why I prefer the first solution.

And another question: when you run the program in IntelliJ IDEA fails because it does not recognize the Nspire commands, but it would be possible in the future build or attach an emulator for this IDE?
 

Well this i the exact same question as here :D I replied :
Indeed this is just for editing.
But then you have for example Luna, which you can use in a shell script to build your files and open the .tns in the software etc, all that called from within the IDE with a build configuration.
We use that for FormulaPro : https://github.com/adriweb/EEPro-for-Nspire/blob/master/build.sh
However, if you want to tet out some algorithms for example, written in "pure" lua, it will run indeed in the console (for that you have to install Lua for your computer tho)

We may imagine some approach of linking nspire_emu (or kArmaTI) -those are community Nspire emulators) to the IDE and see if we could automate the build+run process, but I'm not sure on that one for now

Adriweb

unread,
Oct 19, 2012, 7:45:07 AM10/19/12
to tins...@googlegroups.com

math7

unread,
Oct 19, 2012, 6:14:27 PM10/19/12
to tins...@googlegroups.com
excellent, I'll be waiting for the inclusion of the physics engine in your add on

Adrien Bertrand

unread,
Oct 19, 2012, 6:50:54 PM10/19/12
to tins...@googlegroups.com
I have started working on it but we are facing the same issue as objects like gc. Here it's worse though: since it's simple auto completion, it won't recognize, say, a body variable because it won't examine its type first (physics.Body). That forces us to use the dot-notation of the generic method (followed by the object's name as the first argument of the function) instead of the direct object call... 
Moreover, I'm having troubles making the arguments completion work, I don't know why...
I'll see what I can do tomorrow.
I also have added more 3.2 functions.

Anyway, I hope TI will have all these nice and smart autocompletion things in the SDK as soon as possible ;)
--

Adriweb

unread,
Oct 20, 2012, 7:47:25 AM10/20/12
to tins...@googlegroups.com
Great update !

I re-started from scratch this morning and found out how to make the whole thing work better !
There still are problems with gc being understood as a local variable in paint functions (but at least there is parameters-helping once you wrote the things, now)
Again, same things with D2Editors, for example. The Lua plugin doesn't understand the class() system (we can't really blame it for that) and won't know that some variable is a D2Editor and thus accepts the methods defined for the auto-completion :(
So, if you want to see autocompletion and parameters (and that works for everything in the API), just put the global name (for example D2Editor:setWordWrapWidth(...) then just remplace "D2Editor" by your real variable name :-) )

(BTW, there are now much less files needed, it's way cleaner)

I have updated the whole things for the 3.2 API, with all the new stuff.
The physics engine is there too, but not finished yet. (it's a lot of work !)



I'll update it when I can but here is the new version for now. (just delete and replace the old folder with this one)
(Also, go to Settings -> Lua -> check the Add additionnal completions box, it might help)

Remember that you can Ctrl-Click a method to access its declaration and see more about it.
Ctrl-Q over a word makes it search on Inspired-Lua if it can so you can get its full documentation.

If you have troubles seeing the updated things, do : File -> Invalidate Caches and restart.

If you want to help by completing the physics engine API, you're welcome to do so in the physics.lua file ;)
nspirelua-api-v2.zip

Adriweb

unread,
Oct 20, 2012, 7:56:52 AM10/20/12
to tins...@googlegroups.com
I also forgot to say that the general physics functions to create objects have a "_" before them, because this is the only "acceptable" way to have these functions for autocompletion etc.

For example, if you create a body, you write :  newBody = physics.Body(10, 0), but if you want autocompletion first to know what's possible & the arguments, just put a "_" (otherwise you will get nothing).

An image is worth thousand words :



Don't forget to remove the "_" when you're done ;)

math7

unread,
Oct 21, 2012, 1:03:44 AM10/21/12
to tins...@googlegroups.com
which part of the physics engine API needed closing, I would like to help
Reply all
Reply to author
Forward
0 new messages