TI-Nspire Lua Scripting

1,218 views
Skip to first unread message

Andy Kemp

unread,
Jun 2, 2011, 6:58:33 AM6/2/11
to TI-Nspire Google Group
There has been a bit of discussion since the 3.0 launch about the fact the Periodic Table file provided with 3.0 was written using a previously unavailable scripting language called Lua.  There has also been a fair bit of work over on the TI-Bank forums looking at this feature and what it might mean for the Nspire.

As of yesterday TI have opened up access to their early development tools for working with Lua script, which can be found by visiting:

At this stage these features are not being formally launched as they are still under development and in the FAQ on the page they explain:
"We have not formally opened up Lua programming on the TI-Nspire platform, but we are piloting it now to learn what math and science applications are most valuable."

These tools are still fairly rudimentary at the moment (and currently windows only) and a full SDK is not expected until 2012, however for those looking for a richer more flexible programming environment then there is much here worth looking at, and TI say that 'additional enhancements are planned for future releases' so I am optimistic things will improve further!  At present all the scripting has to be carried out using an external text editor, and then use the linked conversion tool to get the script into a TNS file.

Included with the development tools are a handful of example scripts and TNS files which may be of interest even if you don't think that scripting is for you...

Here's hoping that these tools get used to build useful tools for the Maths/Science classroom!

Cheers
Andy

John Hanna

unread,
Jun 2, 2011, 8:00:35 AM6/2/11
to tins...@googlegroups.com

Andy, would you mind sharing your amazing work: Game of Life and Tower of Hanoi tns files?

 

John Hanna

jeh...@optonline.net

www.johnhanna.us

T3 - Teachers Teaching with Technology

"A cowchip is paradise to a fly."

 


--
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
http://lafacroft.com/archive/nspire.php

Andy Kemp

unread,
Jun 2, 2011, 8:15:03 AM6/2/11
to tins...@googlegroups.com
Of course, I've been working on a couple of files using these tools and attached is my Game of Life simulation and the Tower or Hanoi...

Attached are the TNS files and Lua scripts for those who are interested.  There may still be bugs in these as they haven't been widely tested but should fine on any handheld or software running 3.0.1 or 3.0.2...

Comments or suggestions are always appreciated!

Cheers
Andy
Game of Life v5.tns
HanoiV2.tns
HanoiV2.lua
Game of Life v5.lua

John Hanna

unread,
Jun 2, 2011, 8:57:32 AM6/2/11
to tins...@googlegroups.com

Thanks, Andy.

 

A note to all: should there be an error in the code, you will see the app replaced with an error screen with the error message at the top and a screen of code filling the page. Kindly report the error to the author, perhaps with a screen capture of the error, or, since Andy was kind enough to provide the Lua source code for his apps, you could try debugging yourself J.

 

This truly opens up a whole new world of opportunities for the TI-Nspire world! I only wish I were more adept at Lua programming.

Andy Kemp

unread,
Jun 2, 2011, 9:12:34 AM6/2/11
to tins...@googlegroups.com
I must admit my lua skills are still all over the place whilst I get my head into it!  I find I'm still having to recompile the code after every change to see if it did what I expected!!

However I am really enjoying what I can achieve with it even if I am sure everything I have written could be done significantly neater and shorter if I genuinely knew what I was doing!!

Adrien Bertrand

unread,
Jun 2, 2011, 10:06:40 AM6/2/11
to tinspire
Just so everybody knows : official TI-Nspire lua scripting website
(soon going to be linked in TI's page if not already) :
http://www.inspired-lua.org

Have fun !

On 2 juin, 15:12, Andy Kemp <a...@kemp.co> wrote:
> I must admit my lua skills are still all over the place whilst I get my head
> into it!  I find I'm still having to recompile the code after every change
> to see if it did what I expected!!
>
> However I am really enjoying what I can achieve with it even if I am sure
> everything I have written could be done significantly neater and shorter if
> I genuinely knew what I was doing!!
>
>
>
> On Thu, Jun 2, 2011 at 1:57 PM, John Hanna <johneha...@gmail.com> wrote:
> >  Thanks, Andy.
>
> > A note to all: should there be an error in the code, you will see the app
> > replaced with an error screen with the error message at the top and a screen
> > of code filling the page. Kindly report the error to the author, perhaps
> > with a screen capture of the error, or, since Andy was kind enough to
> > provide the Lua source code for his apps, you could try debugging yourself
> > J.
>
> > This truly opens up a whole new world of opportunities for the TI-Nspire
> > world! I only wish I were more adept at Lua programming.
>
> > John Hanna
>
> > jeha...@optonline.net
>
> >www.johnhanna.us
>
> > T3 - Teachers Teaching with Technology
>
> > *"A cowchip is paradise to a fly."*
>
> >   ------------------------------
>
> > *From:* tins...@googlegroups.com [mailto:tins...@googlegroups.com] *On
> > Behalf Of *Andy Kemp
> > *Sent:* Thursday, June 02, 2011 8:15 AM
> > *To:* tins...@googlegroups.com
> > *Subject:* Re: [tinspire] TI-Nspire Lua Scripting
>
> > Of course, I've been working on a couple of files using these tools and
> > attached is my Game of Life simulation and the Tower or Hanoi...
>
> > Attached are the TNS files and Lua scripts for those who are interested.
> >  There may still be bugs in these as they haven't been widely tested but
> > should fine on any handheld or software running 3.0.1 or 3.0.2...
>
> > Comments or suggestions are always appreciated!
>
> > Cheers
>
> > Andy
>
> > On Thu, Jun 2, 2011 at 1:00 PM, John Hanna <johneha...@gmail.com> wrote:
>
> > Andy, would you mind sharing your amazing work: *Game of Life* and *Tower*
> > * of Hanoi* *tns* files?
>
> > John Hanna
>
> > jeha...@optonline.net
>
> >www.johnhanna.us
>
> > T3 - Teachers Teaching with Technology
>
> > *"A cowchip is paradise to a fly."*
>
> >   ------------------------------
>
> > *From:* tins...@googlegroups.com [mailto:tins...@googlegroups.com] *On
> > Behalf Of *Andy Kemp
> > *Sent:* Thursday, June 02, 2011 6:59 AM
> > *To:* TI-Nspire Google Group
> > *Subject:* [tinspire] TI-Nspire Lua Scripting

Don Shepherd

unread,
Jun 2, 2011, 11:19:50 AM6/2/11
to tinspire
Andy, this is great news and I'm happy that TI is providing this tool
and is committed to this programming environment. Now I've got to go
learn Lua and get a CX!

Don Shepherd

Andy Kemp

unread,
Jun 2, 2011, 11:27:41 AM6/2/11
to tins...@googlegroups.com
The most impressive thing about their Lua implementation is how naturally it sits within the Nspire framework.  I suspect this is why it has taken so long to do...  The ability to interact with variables in the Nspire platform within the script is so simple but incredibly powerful...  I have a few other examples I have been working on which I will share later, but one that is attached is a simulation of flipping n coins (and looking to see what the probability of getting a run of at least x heads in a row is...) (i.e. 7heads in a row from 100 coin flips)

The nice thing is that I can build this simulation in Lua script and then pass the data back into the regular Nspire environment where the user can then carry out the data analysis themselves...

Enjoy!
Andy

Run of 7Heads.tns

Travis Bower

unread,
Jun 2, 2011, 11:31:21 AM6/2/11
to tins...@googlegroups.com
Just when I thought I reached the summit, there is a whole other mountain range.  All right you mavericks and scouts....go get 'em and report back.
 
google game of life   http://www.bitstorm.org/gameoflife/  for more info.
 
Great job Andy.
First and quick attempt at Hanoi....
06-02-2011 Image001.jpg

Steve Phelps

unread,
Jun 2, 2011, 3:33:14 PM6/2/11
to tins...@googlegroups.com
Kudos, Andy! I will use this next year in Stats!

Joe

unread,
Jun 2, 2011, 8:41:56 PM6/2/11
to tinspire
I am not at all familiar with Lua, but the obvious question is can the
recreational games that were popular for the ti-83/84 series now
become available for the nspire? Perhaps in the past some teachers
had bored students sitting in the back playing games on their
calculator during class. So I am curious if opening the nspire up to
Lua will allow that sort of thing occur?
>  Run of 7Heads.tns
> 18KViewDownload- Hide quoted text -
>
> - Show quoted text -

Lionel Debroux

unread,
Jun 3, 2011, 4:37:17 AM6/3/11
to tins...@googlegroups.com
Hi,

> I am not at all familiar with Lua, but the obvious question is can
> the recreational games that were popular for the ti-83/84 series
> now become available for the nspire?

Definitely. In fact, they have started in April, very soon after TI
released the periodic table and OS 3.0.1.1753 :)
I'll only mention six of them, but there are more: 15puzzle, 9sweeper,
nFighter, TI-Basket, Falldown, Puissance 4 Lua.

Another noteworthy Lua program: Levak ported his BASIC Make3D program to
Lua, for a huge interactivity and speed boost. He developed a lot of
code for creating a menu and character map system, in order to work
around the online Nspire document player not dealing with the computer's
keyboard.

All of that occurred before TI released any documentation or tool.
The release quickly followed the involuntary leak of said documentation
(most of which had already been reverse-engineered anyway) and tool on
the website of someone who had access to them, but misconfigured his Web
server and let the directory that contained them be readable (and
probably indexed by search engines, I guess).


> Perhaps in the past some teachers had bored students sitting in
> the back playing games on their calculator during class. So I am
> curious if opening the nspire up to Lua will allow that sort of
> thing occur?

Lua will only widen what has already been possible for more than one
year with C/C++/ASM, all the more programming in Lua is easier than
programming in C/C++/ASM.
Neither C/C++/ASM nor Lua can currently be modified directly on the
calculator, though.


Lionel.

Andy Kemp

unread,
Jun 3, 2011, 5:06:39 AM6/3/11
to tins...@googlegroups.com
There are a couple of important differences though between Lua script and what was possible before with tools like Ndless.  Primarily Lua script will run natively on any current (i.e. 3.0+) device with no user modification, which means its use will be more widespread...

I also think the whole climate of portable gaming has significantly changed since the preeminence of the TI84 as the gaming platform of choice in the classroom.  It is now far more likely that those 'bored students' you mention have a mobile phone in the pocket which is capable of playing far more advanced and complex games then are ever likely to be developed for the Nspire...

Ultimately, providing a more flexible and powerful programming language was always going to open up the gates to a range of recreational games for the device.  Personally I am not concerned about this development as I never felt that it was TI's job to manage what goes on in my classroom (that's my job!) 

There are however a few things that TI could choose to implement to aid the management of these scripts.  
  • One would be to prevent the running of these scripts when the calculator is in P2T mode  (i.e. as one of the options)...
  • Another would be to require some sort of dongle to be connected to the USB port for the scripts to run...
  • Or to have the P2T light flash a particular pattern when Lua scripts are running (i.e. to flag to the teacher that they are running some script)
As TI say on their website about this, scripting is still in the piloting stage and I am sure there will be a lot of discussion about the management of these scripts between now and their formal launch... Personally I would favour something like an indicator light from the P2T LED and the ability to disable (i.e. for tests etc) using P2T...

These are definitely interesting and exciting times!

Cheers
Andy


--

Lionel Debroux

unread,
Jun 3, 2011, 8:34:11 AM6/3/11
to tins...@googlegroups.com
> There are a couple of important differences though between Lua script
> and what was possible before with tools like Ndless. Primarily Lua
> script will run natively on any current (i.e. 3.0+) device with no
> user modification, which means its use will be more widespread...
Lua _programming_ will definitely be more widespread than C/C++/ASM
_programming_, because Lua is easier to program with than C/C++/ASM is.
Especially if an on-calc Lua editor is released.

Lua _use_ may end up being more widespread than _use_ of native code
programs, but I feel that Lua and native code programs are going to be
used in a complementary manner - when native code is available on OS
3.x, of course.
Even with a JIT ( http://luajit.org ), Lua can't reach the speed of
native code, and it won't reach the level of control on the hardware and
software offered by native code.

Even for math programs, as I already mentioned, interacting with the CAS
in internal data form could bring greater speed, and more powerful
manipulations.
Why nest e.g. when, part, expr, str, left, right, mid, in order to try
and cope with the way input expressions are written, if you could call
e.g. next_expression_index, factor_exponent_index, lead_factor_index,
lead_term_index, and dozens of similar functions ?


On the topic of user modification: more than 10 years on the TI-68k and
TI-Z80 have consistently shown that if people want a program which
requires a "kernel" or "shell" (both misnomers, but whatever), they do
what it takes (which usually is easy) to install it ;)
Only to name a few, in random order: CrASH, Ion, DoorsCS, Zshell, Fargo,
DoorsOS, PreOS, and of course Ndless.


> I also think the whole climate of portable gaming has significantly
> changed since the preeminence of the TI84 as the gaming platform of
> choice in the classroom. It is now far more likely that those
> 'bored students' you mention have a mobile phone in the pocket which
> is capable of playing far more advanced and complex games then are
> ever likely to be developed for the Nspire...

Agreed, it's a fact.
But usage of phones tend to be prohibited in classrooms (at least, in
some countries), while usage of calculators in the classroom usually
isn't :)

> Ultimately, providing a more flexible and powerful programming
> language was always going to open up the gates to a range of
> recreational games for the device.

Yes.


> Personally I am not concerned about this development as I never
> felt that it was TI's job to manage what goes on in my classroom
> (that's my job!)

I'm not a teacher, but I tend to agree.

> There are however a few things that TI could choose to implement
> to aid the management of these scripts.
>

> - One would be to prevent the running of these scripts when the


> calculator is in P2T mode (i.e. as one of the options)...

Well, the PTT mode prohibits access to any user documents, among which
are the Lua documents ?
(at least, that's how it worked in OS 1.x, the only ones I've tested PTT
with)
> - Another would be to require some sort of dongle to be


> connected to the USB port for the scripts to run...

Somewhat cumbersome IMO.
> - Or to have the P2T light flash a particular pattern when Lua


> scripts are running (i.e. to flag to the teacher that they are
> running some script)

That could work... but circumvention by colored adhesive tape + ink mark
looks rather easy to me, while remaining hard to detect from a distance.

> As TI say on their website about this, scripting is still in the
> piloting stage and I am sure there will be a lot of discussion
> about the management of these scripts between now and their formal
> launch...

It's likely.

> Personally I would favour something like an indicator light from
> the P2T LED and the ability to disable (i.e. for tests etc) using
> P2T...

I'd think the second item is already available :)


Lionel.

Andy Kemp

unread,
Jun 3, 2011, 8:51:34 AM6/3/11
to tins...@googlegroups.com
Hi Lionel,
You can run Lua script while in P2T if you copy the file once in p2t mode...

I'm not looking for complex solutions and if students really want to
waste their time playing games in class they will (and always have)
find a way...

A simple indicator light I think would suffice for the 99% of people
who are casual users...

There will always be those who wish to do more or to circumvent these
measures but that is up to them...

Cheers
Andy

Sent from my iPhone

Jessica Kachur

unread,
Jun 3, 2011, 9:30:14 AM6/3/11
to tins...@googlegroups.com
Ok, for the dumb in all of us, could you please explain to me what Lua scripting is and how it is helpful in programming,  Please start with the basics!  Thanks.
 
Jess Kachur
T3 Regional Instructor
Muka, CGC, TDI, Retired, CL2, CL3-F, CL3-S, CL3-H, TN-O, WV-N
and
Jibay, Sandy Acres lil' Phantom, NA, CGC, ChFH, CL4, CL4-F, CL4-S, CL4-H



From: Andy Kemp <an...@kemp.co>
To: "tins...@googlegroups.com" <tins...@googlegroups.com>
Sent: Fri, June 3, 2011 7:51:34 AM
Subject: Re: [tinspire] Re: TI-Nspire Lua Scripting
> To unsubscribe send email to tinspire+unsub...@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
> http://lafacroft.com/archive/nspire.php

--
To post to this group, send email to tins...@googlegroups.com
To unsubscribe send email to tinspire+unsub...@googlegroups.com

Andy Kemp

unread,
Jun 3, 2011, 12:42:20 PM6/3/11
to tins...@googlegroups.com
Hi Jess,
This is a surprisingly difficult question to answer!  Lua is a text based programming language that can be used to write interactive environments...  This is a very different skill than the ability to create an 'interactive document'...

Coding an environment in Lua has several advantages and several disadvantages over building something normally on the Nspire...  Using Lua it is possible to create controls based on the keyboard and build custom buttons...  But you also have to build everything else from scratch...  So whilst I could wrote some code to draw a square with a side length that can be changed it would be easier to do this in the regular Nspire environment...

However using Lua script it is possible to add more logic to these objects, for example if you look at the Tower of Hanoi files attached earlier to this thread, you will find a document in which you can drag around the 'disks' but through writing it in lua I have restricted how the disks behave (i.e. it understands that larger disks cannot go on top of smaller disks etc)...

If you have never done any programming before I wouldn't say Lua is the easiest to pick up, but it has the potential to be used to build all sorts of useful documents that could be widely used in classrooms even if only a small handful of users are actually writing the documents...

I don't expect the vast majority of teachers will take up the ability to code in Lua themselves but I can see a bank of resources developing which will be much more widely used by teachers and students in the classroom.

I suggest you download the examples I posted and the ones in the TI link from the first post in this thread and have a look at some of the examples of what is possible...

Cheers
Andy

To unsubscribe send email to tinspire+u...@googlegroups.com

Eric Findlay

unread,
Jun 3, 2011, 1:18:42 PM6/3/11
to tins...@googlegroups.com
Small point of note:  Lua is a Scripting Language, not a Programming Language.

Programming languages are compiled into byte codes (instructions for the processor), which makes them faster at runtime, but are not usually capable of running on different types of processors (need to be recompiled for different instruction sets).  The set of compiled byte codes is a program.

Scripting languages are interpreted into the processor instructions on the fly at run-time, which leads to slower run-time (not noticeable these days), but more cross-platform compatibility.  The set of instructions to be interpreted is called a script.

Not a huge deal, but I thought I'd point out the difference.

  --Eric

Andy Kemp

unread,
Jun 3, 2011, 1:21:45 PM6/3/11
to tins...@googlegroups.com
You are indeed right to correct me, I am a little lazy in my terminology and tend to swap arbitrarily between the two!  I tend to fall back to programming language as more people have a vague understanding of what that means!

Eric Findlay

unread,
Jun 3, 2011, 1:47:59 PM6/3/11
to tins...@googlegroups.com
That's exactly why I corrected you, yet said it's a minor point.

There is actually quite a distinctive and important difference on the back end. And I know there are people here that will understand and appreciate the difference; however, for the rest, it has widely become accepted (through laziness or misunderstanding) to also use "programming" instead of "scripting," and I will not fault people for using the incorrect term, as I will likely slip up, myself, from time to time.

I just thought it was worth a mention once, since we were discussing what it is.

  --Eric

Andy Kemp

unread,
Jun 3, 2011, 1:49:40 PM6/3/11
to tins...@googlegroups.com
I completely agree the distinction is important, and I'm glad you pointed it out!

Don Shepherd

unread,
Jun 3, 2011, 3:23:14 PM6/3/11
to tinspire
Eric, the distinction between compiled versus interpreted
traditionally applied to programming languages (back before there were
such things as "scripting" languages). When BASIC stared out at
Dartmouth in 1964, it was compiled on the GE minicomputer on which it
ran. When Bill Gates and Paul Allen adapted BASIC to run on the
Altair, the first viable microcomputer, BASIC became interpreted
because of severe memory restrictions. It remained interpreted on
most versions on the PC platform. I believe there are still BASIC
interpreters running on PCs today.

Gates and Allen rather perverted the original BASIC language to get it
to fit in the memory of the Altair, and Kemeny and Kurtz (the
inventors of BASIC) were not very happy about that.

Don
On Jun 3, 1:18 pm, Eric Findlay <eagle-...@duetsoftware.net> wrote:
> Small point of note:  Lua is a Scripting Language, not a Programming Language.
>
> Programming languages are compiled into byte codes (instructions for the processor), which makes them faster at runtime, but are not usually capable of running on different types of processors (need to be recompiled for different instruction sets).  The set of compiled byte codes is a program.
>
> Scripting languages are interpreted into the processor instructions on the fly at run-time, which leads to slower run-time (not noticeable these days), but more cross-platform compatibility.  The set of instructions to be interpreted is called a script.
>
> Not a huge deal, but I thought I'd point out the difference.
>
>   --Eric
>
> On Jun 3, 2011, at 9:42 AM, Andy Kemp <a...@kemp.co> wrote:
>
>
>
> > Hi Jess,
> > This is a surprisingly difficult question to answer!  Lua is a text based programming language that can be used to write interactive environments...  This is a very different skill than the ability to create an 'interactive document'...
>
> > Coding an environment in Lua has several advantages and several disadvantages over building something normally on the Nspire...  Using Lua it is possible to create controls based on the keyboard and build custom buttons...  But you also have to build everything else from scratch...  So whilst I could wrote some code to draw a square with a side length that can be changed it would be easier to do this in the regular Nspire environment...
>
> > However using Lua script it is possible to add more logic to these objects, for example if you look at the Tower of Hanoi files attached earlier to this thread, you will find a document in which you can drag around the 'disks' but through writing it in lua I have restricted how the disks behave (i.e. it understands that larger disks cannot go on top of smaller disks etc)...
>
> > If you have never done any programming before I wouldn't say Lua is the easiest to pick up, but it has the potential to be used to build all sorts of useful documents that could be widely used in classrooms even if only a small handful of users are actually writing the documents...
>
> > I don't expect the vast majority of teachers will take up the ability to code in Lua themselves but I can see a bank of resources developing which will be much more widely used by teachers and students in the classroom.
>
> > I suggest you download the examples I posted and the ones in the TI link from the first post in this thread and have a look at some of the examples of what is possible...
>
> > Cheers
> > Andy
>
> > On Fri, Jun 3, 2011 at 2:30 PM, Jessica Kachur <jessicakac...@yahoo.com> wrote:
> > Ok, for the dumb in all of us, could you please explain to me what Lua scripting is and how it is helpful in programming,  Please start with the basics!  Thanks.
>
> > Jess Kachur
> > T3 Regional Instructor
> > Muka, CGC, TDI, Retired, CL2, CL3-F, CL3-S, CL3-H, TN-O, WV-N
> > and
> > Jibay, Sandy Acres lil' Phantom, NA, CGC, ChFH, CL4, CL4-F, CL4-S, CL4-H
>
> > From: Andy Kemp <a...@kemp.co>
> > To: "tins...@googlegroups.com" <tins...@googlegroups.com>
> > Sent: Fri, June 3, 2011 7:51:34 AM
> > Subject: Re: [tinspire] Re: TI-Nspire Lua Scripting
>
> > Hi Lionel,
> > You can run Lua script while in P2T if you copy the file once in p2t mode...
>
> > I'm not looking for complex solutions and if students really want to
> > waste their time playing games in class they will (and always have)
> > find a way...
>
> > A simple indicator light I think would suffice for the 99% of people
> > who are casual users...
>
> > There will always be those who wish to do more or to circumvent these
> > measures but that is up to them...
>
> > Cheers
> > Andy
>
> > Sent from my iPhone
>
> > On 3 Jun 2011, at 13:34, Lionel Debroux <debroux.lio...@gmail.com> wrote:
>
> > >> There are a couple of important differences though between Lua script
> > >> and what was possible before with tools like Ndless.  Primarily Lua
> > >> script will run natively on any current (i.e. 3.0+) device with no
> > >> user modification, which means its use will be more widespread...
> > > Lua _programming_ will definitely be more widespread than C/C++/ASM
> > > _programming_, because Lua is easier to program with than C/C++/ASM is.
> > > Especially if an on-calc Lua editor is released.
>
> > > Lua _use_ may end up being more widespread than _use_ of native code
> > > programs, but I feel that Lua and native code programs are going to be
> > > used in a complementary manner - when native code is available on OS
> > > 3.x, of course.
> > > Even with a JIT (http://luajit.org), Lua can't reach the speed of
> >http://lafacroft.com/archive/nspire.php- Hide quoted text -

Lionel Debroux

unread,
Jun 3, 2011, 4:04:18 PM6/3/11
to tins...@googlegroups.com
Hello,

(Eric)


> Small point of note: Lua is a Scripting Language, not a
> Programming Language.

Well, Lua is both: scripting languages are a special case of programming
languages ;)

> Programming languages are compiled into byte codes (instructions
> for the processor),

* "byte code" usually refers to neutral, processor-independent code. For
example, Java uses a processor-independent bytecode.

* processor-specific instructions directly executable by a given
processor are usually termed e.g. "native code", but not "bytecode".

* the intersection of bytecode and native code is almost void. The
Jazelle extensions of the ARM ISA are supposed to speed up
interpretation of Java, but AFAIK, hardly anybody uses them because
they're mostly undocumented...

Bytecode can be transformed into native code by virtue of Just In Time
(JIT) compilation (at runtime), or Ahead Of Time (AOT) compilation (at
compile time). Some languages support both modes.


> which makes them faster at runtime, but are not usually capable of
> running on different types of processors (need to be recompiled for
> different instruction sets).

You're talking about native code here :)


> The set of compiled byte codes is a program.

That's the terminology for both native code and bytecode.

> Scripting languages are interpreted into the processor
> instructions on the fly at run-time,

Yup.


> which leads to slower run-time (not noticeable these days),

It's common for non-JIT/AOT'ed scripting languages to be ten to one
thousand times slower than equivalent native code. TI's implementations
of BASIC and Lua on the Nspire belong to the set of non-JIT/AOT'ed
scripting languages.

The slowdown of pure interpretation is noticeable in a number of use
cases, especially on embedded platforms, and even though the Lua
interpreter is well known as lightweight and fast, compared to the
standard interpreter of scripting languages such as Python.
As a proof, check the benchmarks at
http://luajit.org/performance_arm.html and
http://luajit.org/performance_x86.html . They show the gap between
interpreted Lua and JIT'ed Lua (the latter being closer to native code),
10 to 100+ times slower indeed.

> but more cross-platform compatibility. The set of instructions to be
> interpreted is called a script.

Yes, and yes.


Lionel.

Andy Kemp

unread,
Jun 4, 2011, 6:45:43 AM6/4/11
to tins...@googlegroups.com
Jess,
It occurred to me a better description for the layman might be that with Lua scripting it should be possible to recreate the kind of maths games that are available as flash games on the web so they run on the Nspire handheld, which now that we have the colour CXs is really exciting!

Cheers
Andy

To unsubscribe send email to tinspire+u...@googlegroups.com

Joe

unread,
Jun 4, 2011, 7:55:18 AM6/4/11
to tinspire
I wonder if I have this straight? C++ is a "programing language" and
you write instructions (coding) in the C++ language which are batch
processed into machine language by a compiler. Lua is a "scripting
language" so when you write inscructions in Lua it is called scripting
and the instuctions are only converted into machine language as they
are used and that is done by an interpreter rather than a compiler.
Is that the gist of it?

On Jun 4, 3:45 am, Andy Kemp <a...@kemp.co> wrote:
> Jess,
> It occurred to me a better description for the layman might be that with Lua
> scripting it should be possible to recreate the kind of maths games that are
> available as flash games on the web so they run on the Nspire handheld,
> which now that we have the colour CXs is really exciting!
>
> Cheers
> Andy
>
> On Fri, Jun 3, 2011 at 2:30 PM, Jessica Kachur <jessicakac...@yahoo.com>wrote:
>
>
>
> > Ok, for the dumb in all of us, could you please explain to me what Lua
> > scripting is and how it is helpful in programming,  Please start with the
> > basics!  Thanks.
>
> > Jess Kachur
> > T3 Regional Instructor
> > Muka, CGC, TDI, Retired, CL2, CL3-F, CL3-S, CL3-H, TN-O, WV-N
> > and
> > Jibay, Sandy Acres lil' Phantom, NA, CGC, ChFH, CL4, CL4-F, CL4-S, CL4-H
>
> >  ------------------------------
> > *From:* Andy Kemp <a...@kemp.co>
> > *To:* "tins...@googlegroups.com" <tins...@googlegroups.com>
> > *Sent:* Fri, June 3, 2011 7:51:34 AM
> > *Subject:* Re: [tinspire] Re: TI-Nspire Lua Scripting
>
> > Hi Lionel,
> > You can run Lua script while in P2T if you copy the file once in p2t
> > mode...
>
> > I'm not looking for complex solutions and if students really want to
> > waste their time playing games in class they will (and always have)
> > find a way...
>
> > A simple indicator light I think would suffice for the 99% of people
> > who are casual users...
>
> > There will always be those who wish to do more or to circumvent these
> > measures but that is up to them...
>
> > Cheers
> > Andy
>
> > Sent from my iPhone
>
> > On 3 Jun 2011, at 13:34, Lionel Debroux <debroux.lio...@gmail.com> wrote:
>
> > >> There are a couple of important differences though between Lua script
> > >> and what was possible before with tools like Ndless.  Primarily Lua
> > >> script will run natively on any current (i.e. 3.0+) device with no
> > >> user modification, which means its use will be more widespread...
> > > Lua _programming_ will definitely be more widespread than C/C++/ASM
> > > _programming_, because Lua is easier to program with than C/C++/ASM is.
> > > Especially if an on-calc Lua editor is released.
>
> > > Lua _use_ may end up being more widespread than _use_ of native code
> > > programs, but I feel that Lua and native code programs are going to be
> > > used in a complementary manner - when native code is available on OS
> > > 3.x, of course.
> > > Even with a JIT (http://luajit.org), Lua can't reach the speed of
> > > 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
> > >http://lafacroft.com/archive/nspire.php
>
> > --
> > 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
> >http://lafacroft.com/archive/nspire.php
>
> > --
> > 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
> >http://lafacroft.com/archive/nspire.php- Hide quoted text -

Don Shepherd

unread,
Jun 4, 2011, 9:00:51 AM6/4/11
to tinspire
Joe, that's essentially correct, except "batch processing" is a rather
dated phrase referring to how punch-card jobs used to be submitted to
mainframe computers for sequential executing, it really doesn't apply
to what people do on PC's these days.

I don't make a big distinction between "computer languages" and
"scripting languages", they both do the same thing: you write code
and it is executed. With today's processor speeds, the difference
between compiling and interpreting is negligible.

Don
> > >http://lafacroft.com/archive/nspire.php-Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -

Jessica Kachur

unread,
Jun 4, 2011, 9:33:15 AM6/4/11
to tins...@googlegroups.com
Ok, I looked at the files, and it is way fcool. I went on the internet and found a site that gives the basics of writing Lua script and I am going to spend some time learning it this summer (yes I am a geek), besides games, is there a good use for this (mathematically speaking)? 
 
where do people see this as being useful?  (i'm not saying the games arent useful and such, I'm trying to think of how I could use this in action/consequence documents).  I like this stuff and I want to use a lot of it
 
Jess Kachur
T3 Regional Instructor
Muka, CGC, TDI, Retired, CL2, CL3-F, CL3-S, CL3-H, TN-O, WV-N
and
Jibay, Sandy Acres lil' Phantom, NA, CGC, ChFH, CL4, CL4-F, CL4-S, CL4-H

Sent: Sat, June 4, 2011 5:45:43 AM

Andy Kemp

unread,
Jun 4, 2011, 9:37:51 AM6/4/11
to tins...@googlegroups.com
The obvious things that I have tried have been probability simulations (see the run of heads file in this thread), or game theory type problems (Game of Life)...

I also think there is a huge scope to do things like decision mathematics (sorting algorithms for example)

Sean Bird

unread,
Jun 4, 2011, 10:12:24 AM6/4/11
to tins...@googlegroups.com
As in Hanoi, you see that you can click on (which is even easier then ctrl click to grab) and then move it only to a certain place. Another thing that I've heard developers of action consequence request is that if you click something, then something happens. Currently with the Nspire, only clicking something does not make something happen, like
 - change color
 - give a message, make labels appear
 - bold, show a side of a cube.

I don't know how many A/C documents you've had your students try on the handheld, but there are some that a little more difficult to use on the handheld, perhaps you could try to make one like that.

I think Andy has done some work so that current users will find using a page with Lua on it more intuitive because it uses the same kind of buttons for to play, pause, reset a simulation.

Again a supper cool thing about Lua, is that information that occurs on that page can be used and analyzed on other native Nspire pages. For more ideas on simulations, many of which can be used in math classrooms to bring real world relevance to what we teach, check out the free simulations at http://phet.colorado.edu/

- Sean Bird


On Sat, Jun 4, 2011 at 9:33 AM, Jessica Kachur <jessic...@yahoo.com> wrote:
Ok, I looked at the files, and it is way cool. I went on the internet and found a site that gives the basics of writing Lua script and I am going to spend some time learning it this summer (yes I am a geek), besides games, is there a good use for this (mathematically speaking)? 

Andy Kemp

unread,
Jun 4, 2011, 12:40:52 PM6/4/11
to tins...@googlegroups.com
Another Lua example that might be of interest to people (in fact this was my first proper project).

Attached is the Sierpinski Gasket generated by the monte carlo method...

I should add - make sure you to try pressing menu (or looking at the menu on the software) as many of these files have extra options etc within the menu...

Cheers
Andy

Sierpinski v5.lua

Travis Bower

unread,
Jun 4, 2011, 4:50:27 PM6/4/11
to tins...@googlegroups.com
Sorry, but when it is just the .lua file, then we need to do what?

Andy Kemp

unread,
Jun 4, 2011, 4:55:50 PM6/4/11
to tins...@googlegroups.com
Sorry, I meant to post the tns file!  To convert the Lua file you will need the conversion tools linked to in the original post!

I'll email the tns file when I am back at my computer!

Sent from my iPad

Andy Kemp

unread,
Jun 4, 2011, 5:27:21 PM6/4/11
to tins...@googlegroups.com
Attached is the TNS file for the Sierpinski Gasket
Sierpinski v5.tns

Steve Phelps

unread,
Jun 4, 2011, 6:51:18 PM6/4/11
to tins...@googlegroups.com
I downloaded the TI Lua scripting "toolkit," but I am not sure how to use it or what to do with it.

Adrien Bertrand

unread,
Jun 5, 2011, 6:10:11 AM6/5/11
to tinspire

John Hanna

unread,
Jun 5, 2011, 9:00:33 AM6/5/11
to tins...@googlegroups.com

Re:  I downloaded the TI Lua scripting "toolkit," but I am not sure how to use it or what to do with it.

 

  1. Use a text editor* to write a Lua program for the TI-Nspire. See the Examples online or the ones that Andy posted.
  2. Run the TI-Nspire Scripting Tools program and Load a Lua App (the lua text file). You’ll see a message that the script has been copied to the clipboard.
  3. In a TI-Nspire document, insert a page and press ctrl-v to pase the Lua program onto the blank page.

If all goes well you should see your program running in TI-Nspire. If not, then there’s an error.

 

Note that this Lua to TI-Nspire environment is in the early stages and is not for novices.

The TI-Nspire Scripting Tools program is also used to convert images into a text form that can be pasted into a Lua program.

 

* Notepad++ is nice and has a Lua view.

 

John Hanna

jeh...@optonline.net

www.johnhanna.us

T3 - Teachers Teaching with Technology

"A cowchip is paradise to a fly."

 


From: tins...@googlegroups.com [mailto:tins...@googlegroups.com] On Behalf Of Steve Phelps
Sent: Saturday, June 04, 2011 6:51 PM
To: tins...@googlegroups.com
Subject: Re: [tinspire] Re: TI-Nspire Lua Scripting

 

I downloaded the TI Lua scripting "toolkit," but I am not sure how to use it or what to do with it.

--

Andy Kemp

unread,
Jun 5, 2011, 9:05:25 AM6/5/11
to tins...@googlegroups.com
Just to add to that I find CTRL+V doesn't always work for me (maybe because I am running the tools in a virtual windows install on a mac via Parallels) so you can also go to Edit>Paste from the menu which worked more often for me...

Joe

unread,
Jun 7, 2011, 12:01:30 PM6/7/11
to tinspire
It just occurred that since a scripted language is interpreted
(converted into machine language) as used, instead of being all
compiled before hand, that must mean that a Lua intrepreter is on the
nspire as part of the OS. Would that be correct? If so, that raises
two other questions. 1.) Does the Lua intrepreter on the nspire have
all the standard Lua commands of just a subset with some custom
commands added? (This effects what needs to be learned in order to
use Lua in the nspire.) 2.) Lua script must be marked somehow to be
intrepreted by the nspire. How is that done? By identifying a set of
instructions as a Lua program when loading them into the nspire as an
app?
> > > >http://lafacroft.com/archive/nspire.php-Hidequoted text -

Andy Kemp

unread,
Jun 7, 2011, 12:27:01 PM6/7/11
to tins...@googlegroups.com
I believe you are correct in your assertion that Lua interpreter is
part of the OS since 3.0.

The Lua interpreter used in the Nspire includes all the standard Lua
commands with the exception of the of the file, io, os and package
libraries, and the docile and load file commands - this is all
documented in the official documents that were linked to at the start
of this thread...

I'm not certain how from the perspective of the Nspire the code is
marked as being Lua script, but from the user's perspective it is
currently done using the conversion tool which is necessary to move
the Lua script on to the Nspire at the moment... I'm not sure if we
will get the ability to write Lua on the handheld at some stage but it
is theoretically possible...

Cheers
Andy

Sent from my iPad

Eric Findlay

unread,
Jun 7, 2011, 12:31:51 PM6/7/11
to tins...@googlegroups.com
I'm not familiar with the entirety of Lua, but I'm pretty sure it's a subset, plus some extra Nspire specific stuff. I know that if you go to the Nspire scripting page (link in first message of this thread - where you download the Lua conversion package), there's a PDF which lists all the Lua commands (or, at least, libraries) which are available with the Nspire.

--Eric

Joe

unread,
Jun 7, 2011, 2:10:24 PM6/7/11
to tinspire
Thanks a bunch Eric and Andy. I am begining to understand the
significance of Lua on nspire.
> >>>>>http://lafacroft.com/archive/nspire.php-Hidequotedtext -
>
> >>>> - Show quoted text -- Hide quoted text -
>
> >>> - Show quoted text -- Hide quoted text -
>
> >> - Show quoted text -
>
> > --
> > 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
>
> ...
>
> read more »- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages