<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.inspired-lua.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jonius7</id>
	<title>Inspired-Lua Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.inspired-lua.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jonius7"/>
	<link rel="alternate" type="text/html" href="https://wiki.inspired-lua.org/Special:Contributions/Jonius7"/>
	<updated>2026-04-09T01:29:57Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://wiki.inspired-lua.org/index.php?title=class&amp;diff=1049</id>
		<title>class</title>
		<link rel="alternate" type="text/html" href="https://wiki.inspired-lua.org/index.php?title=class&amp;diff=1049"/>
		<updated>2013-07-15T04:37:12Z</updated>

		<summary type="html">&lt;p&gt;Jonius7: tutorial link url&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A complete tutorial about classes is written here: http://inspired-lua.org/index.php/2011/05/5-object-classes/&lt;br /&gt;
&lt;br /&gt;
Here's how the class() function is defined, in the API :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
class = function(prototype)&lt;br /&gt;
local derived={}&lt;br /&gt;
 	if prototype then&lt;br /&gt;
 		function derived.__index(t,key)&lt;br /&gt;
 			return rawget(derived,key) or prototype[key]&lt;br /&gt;
 		end&lt;br /&gt;
 	else&lt;br /&gt;
 		function derived.__index(t,key)&lt;br /&gt;
 			return rawget(derived,key)&lt;br /&gt;
 		end&lt;br /&gt;
 	end&lt;br /&gt;
 	function derived.__call(proto,...)&lt;br /&gt;
 		local instance={}&lt;br /&gt;
 		setmetatable(instance,proto)&lt;br /&gt;
 		local init=instance.init&lt;br /&gt;
 		if init then&lt;br /&gt;
 			init(instance,...)&lt;br /&gt;
 		end&lt;br /&gt;
 		return instance&lt;br /&gt;
 	end&lt;br /&gt;
 	setmetatable(derived,derived)&lt;br /&gt;
 	return derived&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jonius7</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.inspired-lua.org/index.php?title=TI.Image&amp;diff=1020</id>
		<title>TI.Image</title>
		<link rel="alternate" type="text/html" href="https://wiki.inspired-lua.org/index.php?title=TI.Image&amp;diff=1020"/>
		<updated>2013-07-01T08:17:59Z</updated>

		<summary type="html">&lt;p&gt;Jonius7: /* Bytes and Data sections */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The TI.Image format is a type of image used in several places in the Nspire documents, such as Lua scripts.&lt;br /&gt;
&lt;br /&gt;
The format is some form of bitmap, with almost no compression at all.&lt;br /&gt;
&lt;br /&gt;
The examples here, as the encoded strings visible in .lua files sometimes show letters and symbols instead of expected &amp;quot;\xxx&amp;quot; characters. This is because the &amp;quot;\xxx&amp;quot; is actually a representation of a non-printable character, and when, by chance, the character is printable the editor displays its value, which can be a letter, a symbol etc.&lt;br /&gt;
&lt;br /&gt;
==Bytes and Data sections==&lt;br /&gt;
&lt;br /&gt;
All the data in a Ti.image is formatted in what we call bytes.&lt;br /&gt;
A byte can look like this (without the quotes): &amp;quot;&amp;lt;tt&amp;gt;\255&amp;lt;/tt&amp;gt;&amp;quot;, &amp;quot;&amp;lt;tt&amp;gt;\129&amp;lt;/tt&amp;gt;&amp;quot;, &amp;quot;&amp;lt;tt&amp;gt;\045&amp;lt;/tt&amp;gt;&amp;quot; or &amp;quot;&amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;&amp;quot;. The byte number ranges from \000 to \255&lt;br /&gt;
If the byte number is reprecentable in ascii (and the nspire supports that char), it is allowed to just use the ascii version as byte, to lower the size of the image. For example, you can change &amp;quot;&amp;lt;tt&amp;gt;\046&amp;lt;/tt&amp;gt;&amp;quot; to &amp;quot;&amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A data section is a group of bytes used to represent some header data or a pixel.&lt;br /&gt;
For example, it might look like this: &amp;quot;&amp;lt;tt&amp;gt;\255\123&amp;lt;/tt&amp;gt;&amp;quot;.&lt;br /&gt;
What is very important to understand is that the data is not written logically, in fact, the position of the bytes is swapped.&lt;br /&gt;
For example, let's take a picture with the width 320, and you want to convert the width size to put in your header:&lt;br /&gt;
&lt;br /&gt;
1. You first convert the number to binary: &amp;lt;tt&amp;gt;320 --&amp;gt; 101000000&amp;lt;/tt&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
2.Then you have to add the extra zeros to make it fit in the header (width is 4 bytes):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;00000000000000000000000101000000&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
3.This is then splited in four (4 bytes):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;00000000 - 00000000 - 00000001 - 01000000&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
4.Then converted back to decimal:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;000 - 000 - 001 - 064&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You would expect to put this then as &amp;quot;&amp;lt;tt&amp;gt;\000\000\001\064&amp;lt;/tt&amp;gt;&amp;quot; in the header, but no, you have to swap it: &amp;quot;&amp;lt;tt&amp;gt;\064\001\000\000&amp;lt;/tt&amp;gt;&amp;quot;&amp;lt;br&amp;gt;(Little Endian)&amp;lt;br&amp;gt;&lt;br /&gt;
You can also change the &amp;quot;&amp;lt;tt&amp;gt;\064&amp;lt;/tt&amp;gt;&amp;quot; in the header to &amp;quot;&amp;lt;tt&amp;gt;@&amp;lt;/tt&amp;gt;&amp;quot;, since that is its ASCII representation.&lt;br /&gt;
Finally, the data would look like this: &amp;quot;&amp;lt;tt&amp;gt;@\001\000\000&amp;lt;/tt&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Header==&lt;br /&gt;
The header is 20 &amp;quot;bytes&amp;quot; long, and can be devided in the following 6 data sections:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;[IMAGE WIDTH, 4 bytes][IMAGE HEIGHT, 4 bytes][EMPTY, 4 bytes][IMAGE BUFFER SIZE, 4 bytes][IMAGE DEPTH, 2 bytes][OTHER, 2 bytes]&amp;lt;/tt&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The header is the first data of the Ti.image format.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;tt&amp;gt;[IMAGE WIDTH, 4 bytes]&amp;lt;/tt&amp;gt;	:	This is the width of your image, and is four bytes long.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;[IMAGE HEIGHT, 4 bytes]&amp;lt;/tt&amp;gt;	:	This is the height of your image, and is four bytes long.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;[EMPTY, 4 bytes]&amp;lt;/tt&amp;gt;	:	This space is just filled with zeroes (&amp;quot;\000\000\000\000&amp;quot;), and is four bytes long&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;[IMAGE BUFFER SIZE, 4 bytes]&amp;lt;/tt&amp;gt;	:	Amount of bytes in one buffer row , this is normally 2*width. 4 bytes long.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;[IMAGE DEPTH, 2 bytes]&amp;lt;/tt&amp;gt;	:	This is the image, normally just 16 ,two bytes long (actaully the image is 15 bit, but if you count the alpha channel it is 16)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;[UNKNOWN, 2 bytes]&amp;lt;/tt&amp;gt;	:	Unknown, maybe compression type? Two bytes long, and has 1 as default value.&amp;lt;bt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example header and description:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;.\000\000\000\018\000\000\000\000\000\000\000\092\000\000\000\016\000\001\000&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first four bytes (&amp;quot;&amp;lt;tt&amp;gt;.\000\000\000&amp;lt;/tt&amp;gt;&amp;quot;) shows that the width is 46px.&amp;lt;br&amp;gt;&lt;br /&gt;
The next four bytes (&amp;quot;&amp;lt;tt&amp;gt;\018\000\000\000&amp;lt;/tt&amp;gt;&amp;quot;) shows that the height 18px.&amp;lt;br&amp;gt;&lt;br /&gt;
The next four bytes is empty.&amp;lt;br&amp;gt;&lt;br /&gt;
The four bytes (&amp;quot;&amp;lt;tt&amp;gt;\092\000\000\000&amp;lt;/tt&amp;gt;&amp;quot;) after this is the buffer row size (2*width)&amp;lt;br&amp;gt;&lt;br /&gt;
The next two bytes (&amp;quot;&amp;lt;tt&amp;gt;\016\000&amp;lt;/tt&amp;gt;&amp;quot;) is the image depth.&lt;br /&gt;
The next two bytes (&amp;quot;&amp;lt;tt&amp;gt;\001\000&amp;lt;/tt&amp;gt;&amp;quot;) are unkown.&lt;br /&gt;
&lt;br /&gt;
==Pixel data==&lt;br /&gt;
The pixel data comes directly after the header.&lt;br /&gt;
Pixels are arranged in rows.&lt;br /&gt;
Each pixel has a data section of two bytes.&lt;br /&gt;
It contains the rgb values, and the alpha channel.&lt;br /&gt;
 &lt;br /&gt;
Here is how it is structured (in binary):&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;tt&amp;gt;A - RRRRR - GGGGG - BBBBB&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Example : &amp;lt;tt&amp;gt;1 - 11111 - 10001 - 00000&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
A is the alpha channel, 1 for not transparent, 0 for fully transparent. R, G, and B or the color levels.&lt;br /&gt;
 &lt;br /&gt;
To convert this to valid pixel data it has to be cut in two:&lt;br /&gt;
 &lt;br /&gt;
 ARRRRRGG - GGGBBBBB&lt;br /&gt;
 11111110 - 00100000&lt;br /&gt;
 &lt;br /&gt;
    ||          || Converter to decimal&lt;br /&gt;
    \/          \/&lt;br /&gt;
 	&lt;br /&gt;
    254        032&lt;br /&gt;
 &lt;br /&gt;
 And finally, swapped:&lt;br /&gt;
 &lt;br /&gt;
 &amp;quot;\032\254&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
This is then added to the data buffer.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;'''str = &amp;quot;\007\000\000\000\008\000\000\000\000\000\000\000\014\000\000\000\016\000\001\000'''alalalalalalalal\000\244\000\244al\000\244\000\244al\000\244\000\244\000\244\000\244\000\244\000\244\000\244\000\244\000\244\000\244\000\244\000\244\000\244\000\244al\000\244\000\244\000\244\000\244\000\244alalal\000\244\000\244\000\244alalalalal\000\244alalalalalalalalalal5&amp;quot;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You then need to use the function ''[[image.new]](str)''.&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[[User:Adriweb|Adriweb]] made [http://www.youtube.com/watch?v=YQhrMHNkL3A a video] showing some direct manipulations of the TI-Image, in order to understand better the format in general. &lt;br /&gt;
&lt;br /&gt;
[[User:jimbauwens|Jimbauwens]] made [http://bwns.be/jim/tiviewer.html a image previewer], [http://bwns.be/jim/sprite.html a sprite creator] and a basic [http://bwns.be/jim/convert.py python image converter] (you need PythonMagick to run this)&lt;br /&gt;
&lt;br /&gt;
These tools are not official and we'll update this as soon as we can / are allowed to.&lt;br /&gt;
&lt;br /&gt;
In the official Nspire Lua toolkit, TI included in their software a feature that converts an image (with a common format such as jpg, png etc.) into a TI.Image format.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
http://en.wikipedia.org/wiki/Highcolor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:image]]&lt;/div&gt;</summary>
		<author><name>Jonius7</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.inspired-lua.org/index.php?title=Overview_of_the_API&amp;diff=1014</id>
		<title>Overview of the API</title>
		<link rel="alternate" type="text/html" href="https://wiki.inspired-lua.org/index.php?title=Overview_of_the_API&amp;diff=1014"/>
		<updated>2013-06-30T06:02:40Z</updated>

		<summary type="html">&lt;p&gt;Jonius7: /* Events */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note: Neither the ''io'' nor ''os'' libraries are present for the TI-Nspire, which seems to be running a light version of Lua 5.1.4. &lt;br /&gt;
&lt;br /&gt;
== Standard Library  ==&lt;br /&gt;
&lt;br /&gt;
( This has been taken from [http://www.wowwiki.com/Lua_functions a WoWWiki page] - See the full, official documentation [http://www.lua.org/manual/5.1/manual.html here] )&lt;br /&gt;
&lt;br /&gt;
=== Basic Library Functions ===&lt;br /&gt;
&lt;br /&gt;
*'''[[G]]''' - Global Variable - A global variable (not a function) that holds the global environment (that is, _G._G = _G). Lua itself does not use this variable; changing its value does not affect any environment, nor vice-versa. (Use setfenv to change environments.) - taken from Lua docs &lt;br /&gt;
*'''[[assert]]'''(value[, errormsg]) - asserts a value evaluates to true. If it is, returns value, otherwise causes a Lua error to be thrown. &lt;br /&gt;
*'''[[collectgarbage]]'''&lt;br /&gt;
*'''[[error]]'''&lt;br /&gt;
*'''[[getfenv]]'''(function or integer) - Returns the table representing the stack frame of the given function or stack level. &lt;br /&gt;
*'''[[getmetatable]]'''(obj, mtable) - Returns the metatable of the given table or userdata object. &lt;br /&gt;
*'''[[next]]'''(table, index) - Returns the next key, value pair of the table, allowing you to walk over the table. &lt;br /&gt;
*'''[[newproxy]]'''(boolean or proxy) - Creates a userdata with a sharable metatable. &lt;br /&gt;
*'''[[print]]''' - print (···) - Receives any number of arguments, and prints their values to stdout, using the tostring function to convert them to strings. print is not intended for formatted output, but only as a quick way to show a value, typically for debugging. For formatted output, use string.format. - taken from Lua Docs &lt;br /&gt;
*'''[[select]]'''(index, list) - Returns the number of items in list or the value of the item in list at index. &lt;br /&gt;
*'''[[setfenv]]'''(function or integer, table) - Sets the table representing the stack frame of the given function or stack level. &lt;br /&gt;
*'''[[setmetatable]]'''(obj, mtable) - Sets the metatable of the given table or userdata object. &lt;br /&gt;
*'''[[tostring]]''' - tostring (e) - Receives an argument of any type and converts it to a string in a reasonable format. For complete control of how numbers are converted, use string.format. If the metatable of e has a &amp;quot;__tostring&amp;quot; field, then tostring calls the corresponding value with e as argument, and uses the result of the call as its result. - taken from Lua Docs. &lt;br /&gt;
*'''[[tonumber]]''' - tonumber (e) - Receives an argument of the string type and converts it to a number when possible. If the metatable of e has a &amp;quot;__tonumber&amp;quot; field, then tonumber calls the corresponding value with e as argument, and uses the result of the call as its result. - taken from Lua Docs. &lt;br /&gt;
&lt;br /&gt;
*'''[[type]]'''(var) - Returns the type of variable as a string, &amp;quot;number&amp;quot;, &amp;quot;string&amp;quot;, &amp;quot;table&amp;quot;, &amp;quot;function&amp;quot; or &amp;quot;userdata&amp;quot;. &lt;br /&gt;
*'''[[unpack]]'''(table[, start][, end]) - Returns the contents of its argument as separate values. &lt;br /&gt;
*'''[[xpcall]]'''(func, err) - Returns a boolean indicating successful execution of func and calls err on failure, additionally returning func's or err's results.&lt;br /&gt;
&lt;br /&gt;
=== String Library ===&lt;br /&gt;
byte char dump find format gmatch gsub len lower match rep reverse sub upper&lt;br /&gt;
&lt;br /&gt;
=== Math Library ===&lt;br /&gt;
abs acos asin atan atan2 ceil cos cosh deg exp  oor fmod frexp huge ldexp log log10 max min modf pi pow rad random randomseed sin sinh sqrt tan tanh&lt;br /&gt;
&lt;br /&gt;
More information about the other libraries can be found on the [[Extended Standard Library]] Page&lt;br /&gt;
&lt;br /&gt;
== Concepts and Basics  ==&lt;br /&gt;
&lt;br /&gt;
This part will explain you how the Lua actually works inside the OS and help you to figure out what you're doing when you write a script for the TI-Nspire. Before reading this, you have to know all about the Lua basics. &lt;br /&gt;
&lt;br /&gt;
The Lua is an interpreted script language which means that it isn't as fast as ASM/C programs, but is still better than the TI-BASIC. One good thing is that this language is in a complete harmony with the OS with basic events and a powerfull graphic context. First, we have to understand how this works. Basicly the script is launched before the executive engine. This means that we can neither evaluate expressions nor use some of the standard API (like platform, var) until the engine is launched. Here is a call summary&amp;amp;nbsp;: &lt;br /&gt;
&lt;br /&gt;
*Launch string library &lt;br /&gt;
*Launch math library &lt;br /&gt;
*... &lt;br /&gt;
*Open and launch User's Lua script &lt;br /&gt;
*... &lt;br /&gt;
*Launch var API (store, recall, ...) &lt;br /&gt;
*Launch platform API (window, gc, ...) &lt;br /&gt;
*... &lt;br /&gt;
*Link events (pseudo code)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;while(Exit)&lt;br /&gt;
 	------- Some OS routines here&lt;br /&gt;
 &lt;br /&gt;
  	---- Begin of Event link&lt;br /&gt;
 	buffer:captureDataFromKeyPad() 	 	 	--  (N) some underground routines to catch events&lt;br /&gt;
 	if buffer.charInput ~= &amp;quot;&amp;quot; then 	 	 	--  (N)&lt;br /&gt;
 		on.charIn(buffer.charInput)&lt;br /&gt;
 		buffer.charInput= &amp;quot;&amp;quot; 	 	 	--  (N)&lt;br /&gt;
 	end&lt;br /&gt;
 	if buffer.arrowKey ~= &amp;quot;&amp;quot; then 	 	 	--  (N)&lt;br /&gt;
 		on.arrowKey(buffer.arrowKey)&lt;br /&gt;
 		buffer.arrowKey = &amp;quot;&amp;quot; 	 	 	--  (N)&lt;br /&gt;
 	end&lt;br /&gt;
 	----- etc ... 	&lt;br /&gt;
 	if platform.window.isInvalidate then &lt;br /&gt;
 	 	platform.gc():purge()	 	 	--  (N) Empty buffer before starting to draw&lt;br /&gt;
 		on.paint(platform.gc()) 	  	-- save all the things we have to draw&lt;br /&gt;
 	 	platform:paint() 	 	  	--  (N) draw all those things&lt;br /&gt;
 		platform.window.isInvalidate = false 	-- say that the window has been drawn&lt;br /&gt;
 	end&lt;br /&gt;
 	----- End of Event link&lt;br /&gt;
end''&lt;br /&gt;
Note : the (N) commented line only indicates the meaning of the routine. Those functions don't really exist.&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can understand how everything is linked, just by a main loop. This helps you to understand that you don't have to code a loop yourself, because the screen wouldn't be refreshed. This also helps to see when the screen gets refreshed. In other words, we cannot use niether '''gc''' nor '''platform.gc()''' (which are the same) in order to draw somthing on the screen if we are outside of '''on.paint()''' (except if your outside function is called within on.paint() ). This also means that we don't need to pass '''gc''' as parameter, because we can rather use '''platform.gc()''' for any functions called within on.paint(). This is exactly what [https://github.com/adriweb/BetterLuaAPI-for-TI-Nspire/blob/master/BetterLuaAPI.lua the BetterLuaAPI library for Nspire] does. &lt;br /&gt;
&lt;br /&gt;
Here is an example of a simple Lua program that displays a message only when a key is pressed (and let the screen blank otherwise). &lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt; function on.paint(gc)&lt;br /&gt;
 	if message then&lt;br /&gt;
 	 	gc:setFont(&amp;quot;sansserif&amp;quot;, &amp;quot;r&amp;quot;, 10)	-- initialize font drawing&lt;br /&gt;
 	 	gc:drawString(message, 0, 0, &amp;quot;top&amp;quot;)	-- display the message at (0, 0) coordinates&lt;br /&gt;
 	 	message = nil 				-- erase the message&lt;br /&gt;
 	 	timer.start(1) 	 	 	-- start a timer to exit on.paint() but keep in mind that we have to redraw the screen&lt;br /&gt;
 	end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.timer()&lt;br /&gt;
 	timer.stop()&lt;br /&gt;
 	platform.window:invalidate()&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.charIn(ch)&lt;br /&gt;
 	message = &amp;quot;Hello World !&amp;quot;		-- store a message&lt;br /&gt;
 	platform.window:invalidate()		-- force display&lt;br /&gt;
 end&amp;lt;/source&amp;gt;&lt;br /&gt;
When you open the document, the script is read once. It initializes and overwrites all the functions and globals with the ones you defined. Thus, '''message''' is nil. Once the '''on.paint()''' event is called, '''message''' is nil, thus, nothing is done. When you press a key that calls '''on.charIn()''' (see below for more information), '''message''' is now &amp;quot;Hello World&amp;quot; and we tell the '''platform''' that the screen has to be refreshed. Then, '''on.paint()''' is called again, '''message''' is not nil then we display it, erase '''message''' and launch a timer. Why is that&amp;amp;nbsp;? Because if we call '''platform.window:invalidate()''' right there, we won't refresh the screen. Why again&amp;amp;nbsp;? Just look at the pseudo-code above. We set the window as drawn after each call of on.paint(). Thus a timer is necessary to manually recall '''on.paint()''' and exit the '''on.paint()''' function to draw the screen. When the timer is ended, '''on.timer()''' is called and we refresh the screen. The screen is then redrawn but there is nothing to draw because '''message''' is nil. Thus, the graphic context lets the screen blank. &lt;br /&gt;
&lt;br /&gt;
== gc (as in Graphics Context)  ==&lt;br /&gt;
&lt;br /&gt;
Note: You need to add “gc:” before each of these commands in order to use them. ex. '''gc:setAlpha(...)'''. You can also call gc like this&amp;amp;nbsp;: '''platform.gc():setAlpha(...)'''. Then you can use the gc library in a function where gc is not passed as an argument. but this function *has* to be called within '''on.paint(gc)''' &lt;br /&gt;
&lt;br /&gt;
The maximum screen resolution available to Lua programs is 318 by 212 pixels. &lt;br /&gt;
&lt;br /&gt;
*'''[[gc:begin]]''' - &lt;br /&gt;
*'''[[gc:clipRect]]''' - &lt;br /&gt;
*'''[[gc:drawArc]]'''(x, y, width, height, start angle, finish angle) Note, to draw a circle, use drawArc(x - diameter/2, y - diameter/2, diameter,diameter,0,360) where x and y are the coordinates of the middle. &lt;br /&gt;
*'''[[gc:drawImage]]'''(image,x,y) First argument in format “[[TI.Image]]”, x and y the coords. &lt;br /&gt;
*'''[[gc:drawLine]]'''(xstart, ystart, xend, yend) Draws a line starting at the point (xstart,ystart) and ending at the point (xend, yend) &lt;br /&gt;
*'''[[gc:drawPolyLine]]'''(int list1 [,int list2, .., int listN]) Draws a shape from a list contaning successively the x and y coordinates of each point the line have to draw.&lt;br /&gt;
&lt;br /&gt;
*'''[[gc:drawRect]]'''(x, y, xwidth, yheight) Draws a rectangle at (x,y) with the “x” side being “xwidth” long and the “y” side being “yheight” long &lt;br /&gt;
*'''[[gc:drawString]]'''(string, x, y, PositionString) PositionString is the string’s anchor point and can be “bottom”, “middle”, or “top”. &lt;br /&gt;
*'''[[gc:fillArc]]'''(x, y, width, height, start angle, finish angle) see drawArc &lt;br /&gt;
*'''[[gc:fillPolygon]]'''(int list1 [,int list2, .., int listN]) see drawPolyLine &lt;br /&gt;
*'''[[gc:fillRect]]'''(x, y, width, height) see drawRect &lt;br /&gt;
*'''[[gc:finish]]''' - &lt;br /&gt;
*'''[[gc:getStringHeight]]'''(string) &lt;br /&gt;
*'''[[gc:getStringWidth]]'''(string) &lt;br /&gt;
*'''[[gc:isColorDisplay]]''' Bool (Read-only) Returns 1 if color, 0 if not. &lt;br /&gt;
*'''[[gc:setAlpha]]'''(int) - where the argument is an int between 0 and 255. Sets the transparency. &lt;br /&gt;
*'''[[gc:setColorRGB]]'''(red, green, blue) RGB values are integers, from 0 to 255. &lt;br /&gt;
*'''[[gc:setFont]]'''(font, type, size), with font&amp;amp;nbsp;: {“sansserif”, &amp;quot;serif&amp;quot;, ..}, type {“b”, “r”, “i”}, size(int) &lt;br /&gt;
*'''[[gc:setPen]]'''(size, smooth) size {“thin”, “medium”, &amp;quot;thick&amp;quot;}, smooth {“smooth”, &amp;quot;dotted&amp;quot;, &amp;quot;dashed&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
== platform  ==&lt;br /&gt;
&lt;br /&gt;
These are mainly read-only. These work by writing &amp;quot;'''platform.'''&amp;quot; in front of them. Example&amp;amp;nbsp;: &amp;quot;'''platform.window:invalidate()'''&amp;quot; &lt;br /&gt;
&lt;br /&gt;
*'''[[platform.apilevel]]'''&amp;amp;nbsp;: Returns the version of the API. Currently (OS 3.0.1) returns 1.0.0. &lt;br /&gt;
*'''[[platform.window]]'''&lt;br /&gt;
&lt;br /&gt;
:*'''[[platform.window:width]]''' - Returns the width of the window. Ex&amp;amp;nbsp;: ''platform.window:height()'' &lt;br /&gt;
:*'''[[platform.window:height]]''' - Returns the height of the window &lt;br /&gt;
:*'''[[platform.window:invalidate]]''' - Repaints the window (it calls '''on.paint(gc)''')&lt;br /&gt;
&lt;br /&gt;
*'''[[platform.isDeviceModeRendering]]''' Returns true or false whether the unit is &amp;quot;rendering&amp;quot; or not &lt;br /&gt;
*'''[[platform.gc]]''' - Other way to call '''gc'''. Use it like that&amp;amp;nbsp;: '''platform.gc():setAlpha(...)''' for example. This is useful when you're in a function outside '''on.paint(gc)''' (but this function has to be called within [[on.paint]](gc).) &lt;br /&gt;
*'''[[platform.isColorDisplay]]''' Returns ''true'' if the unit the code is being run on has a color display (-&amp;amp;gt; Nspire CX), and ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
== cursor  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[cursor.hide]]'''() - hides the cursor (mouse pointer) &lt;br /&gt;
*'''[[cursor.set]]'''(string) - string can be one of those&amp;amp;nbsp;: (interrogation, crosshair, text, pointer, link select, diag resize, wait busy, hollow pointer, rotation, pencil, zoom box, arrow, zoom out, dotted arrow, clear, animate, excel plus, mod label, writing, unavailable, resize row, resize column, drag grab, hand open, hand closed, hand pointer, zoom in, dilation, translation). &lt;br /&gt;
*'''[[cursor.show]]'''() - Shows the cursor on screen&lt;br /&gt;
&lt;br /&gt;
== document  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[document.markChanged]]'''() - Flag the document as &amp;quot;changed&amp;quot; so the user has to save it after using it.&lt;br /&gt;
&lt;br /&gt;
== clipboard  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[clipboard.addText]]'''() &lt;br /&gt;
*'''[[clipboard.getText]]'''()&lt;br /&gt;
&lt;br /&gt;
== locale  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[locale.name]]'''() - Returns the current language the calculator is set in, formatted as ISO-639 (i.e&amp;amp;nbsp;: &amp;quot;fr&amp;quot;, &amp;quot;en&amp;quot;, &amp;quot;it&amp;quot; ...).&lt;br /&gt;
&lt;br /&gt;
== image  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[image.copy]]'''(image, width, height) - returns a new Image which has a new scale. Width is the final width, Heigth, the final height of the image. &lt;br /&gt;
*'''[[image.height]]'''(image) - returns the height of the image given in parameter &lt;br /&gt;
*'''[[image.new]]'''(string) - Creates a new image from the string given in parameter (see TI.Image).&lt;br /&gt;
*'''[[image.width]]'''(image) - returns the width of the image given in parameter&lt;br /&gt;
&lt;br /&gt;
== timer  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[timer.getMilliSecCounter]]'''() - Returns the amount of milliseconds elapsed since last calculator reboot. (in TI's Computer software, returns an absolute negative time) &lt;br /&gt;
*'''[[timer.start]]'''(int) - Starts a timer with 1 second. &lt;br /&gt;
*'''[[timer.stop]]'''() - Stops a timer&lt;br /&gt;
&lt;br /&gt;
== toolpalette  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[toolpalette.enable]]'''(string) &lt;br /&gt;
*'''[[toolpalette.enableCopy]]'''() &lt;br /&gt;
*'''[[toolpalette.enableCut]]'''() &lt;br /&gt;
*'''[[toolpalette.enablePaste]]'''() &lt;br /&gt;
*'''[[toolpalette.register]]'''(table)&lt;br /&gt;
&lt;br /&gt;
== var  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[var.list]]'''() - returns a list of all the variables in the entire Activity &lt;br /&gt;
*'''[[var.monitor]]'''() -&amp;amp;nbsp;? &lt;br /&gt;
*'''[[var.recall]]'''(string) - returns the variable value which name is given in parameter &lt;br /&gt;
*'''[[var.recallstr]]'''(string) - returns the variable value converted to string which name is given in parameter &lt;br /&gt;
*'''[[var.store]]'''(string, value) - store in the variable, which name is given in parameter, the value &lt;br /&gt;
*'''[[var.unmonitor]]'''() -&amp;amp;nbsp;?&lt;br /&gt;
&lt;br /&gt;
== Events  ==&lt;br /&gt;
*'''[[on.create]]'''() function called when script application is created. Removed in OS 3.2 (API v2.0)&lt;br /&gt;
*'''[[on.construction]]'''() function that is guaranteed to run first before any other function. New in OS 3.2 (API v2.0)&lt;br /&gt;
*'''[[on.paint]]'''(gc) is called when the GUI is painted. 'gc' is the Graphics Context (see above) &lt;br /&gt;
*'''[[on.resize]]'''() is called when the window is rezised &lt;br /&gt;
*'''[[on.timer]]'''() is called when the timer has been finished. Here an example of using timer to play an animation&amp;amp;nbsp;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt; x = 1&lt;br /&gt;
 animating = false&lt;br /&gt;
 function on.paint(gc)&lt;br /&gt;
 	gc:setFont(&amp;quot;sansserif&amp;quot;, &amp;quot;r&amp;quot;, 10)&lt;br /&gt;
 	gc:drawString(tostring(x), 0, 0, &amp;quot;top&amp;quot;)&lt;br /&gt;
 	if animating then&lt;br /&gt;
 		x = x + 1&lt;br /&gt;
 		timer.start(0.5)&lt;br /&gt;
 	end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.charIn(ch)&lt;br /&gt;
 	animating = not animating -- switch state&lt;br /&gt;
 	platform.window:invalidate() -- recall graph engine&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.timer()&lt;br /&gt;
 	timer.stop()&lt;br /&gt;
 	platform.window:invalidate() -- recall graph engine&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.arrowKey]]'''(key) is called when an '''arrow key''' from the clickPad/TouchPad is pressed (right, left, up, down) &lt;br /&gt;
*'''[[on.arrowLeft]]'''() is called when the '''left''' arrow is pressed &lt;br /&gt;
*'''[[on.arrowRight]]'''() is called when the '''right''' arrow is pressed &lt;br /&gt;
*'''[[on.arrowUp]]'''() is called when the up '''arrow''' is pressed &lt;br /&gt;
*'''[[on.arrowDown]]'''() is called when the '''down''' arrow is pressed&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.up]]'''() -- probably for the touchpad up motion &lt;br /&gt;
*'''[[on.down]]'''() -- probably for the touchpad down motion&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.enterKey]]'''() is called when the '''enter''' key is pressed. &lt;br /&gt;
*'''[[on.escapeKey]]'''() is called when the '''escape''' key is pressed. &lt;br /&gt;
*'''[[on.tabKey]]'''() is called when the '''tab''' key is pressed. &lt;br /&gt;
*'''[[on.deleteKey]]'''() is called when the '''delete''' key is pressed. &lt;br /&gt;
*'''[[on.backspaceKey]]'''() is called when the '''clear''' key is pressed. &lt;br /&gt;
*'''[[on.returnKey]]'''() is called when the '''return''' key is pressed. &lt;br /&gt;
*'''[[on.contextMenu]]'''() is called when the combo-key '''Ctrl Menu''' is pressed. &lt;br /&gt;
*'''[[on.backtabKey]]'''() is called when the combo-key '''Maj Tab''' is pressed. &lt;br /&gt;
*'''[[on.clearKey]]'''() is called when the combo-key '''Ctrl Clear''' is pressed. &lt;br /&gt;
*'''[[on.help]]'''() is called when the combo-key '''Ctrl H''' is pressed.&lt;br /&gt;
&lt;br /&gt;
*'''[[on.charIn]]'''(string) is called when the Nspire detects a non arrow key being pressed. ch is the character it detect. If you want to auto start an event in the file linked to key r(like a reset) put on.charIn(“r”) where you want.&lt;br /&gt;
&lt;br /&gt;
*'''[[on.blink]]'''()&amp;amp;nbsp;? is called when the focus is lost on the page (like launching the document, changing page etc...)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.deactivate]]'''()&amp;amp;nbsp;? is called when the focus is lost on the page (like launching the document, changing page etc...) &lt;br /&gt;
*'''[[on.activate]]'''()&amp;amp;nbsp;? is called when the focus is on the page (like launching the document, changing page etc...)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.mouseDown]]'''(x, y) is called when we press the left mouse button. X and Y are the pressed point coordinates. &lt;br /&gt;
*'''[[on.mouseUp]]'''() is called when we release the left mouse button. &lt;br /&gt;
*'''[[on.mouseMove]]'''() is called when the mouse moves &lt;br /&gt;
*'''[[on.grabDown]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.grabMove]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.grabUp]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.rightMouseDown]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.rightMouseUp]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.cutEnabled]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.copyEnabled]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.pasteEnabled]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.cut]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.copy]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.paste]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== D2Editor  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[D2Editor.newRichText]]'''() creates a new RichText object (default values&amp;amp;nbsp;: x, y, width, height = 0) &lt;br /&gt;
*'''[[D2Editor.resize]]'''(width, height) &lt;br /&gt;
*'''[[D2Editor.move]]'''(x, y) &lt;br /&gt;
*'''[[D2Editor.setText]]'''(string) &lt;br /&gt;
*'''[[D2Editor.getText]]'''() returns the RichText value &lt;br /&gt;
*'''[[D2Editor.setReadOnly]]'''(bool) bool&amp;amp;nbsp;: true/false&amp;amp;nbsp;: If true, the content becomes read-only, i.e. non-editable. &lt;br /&gt;
*'''[[D2Editor.setFormattedText]]'''() - ?&lt;br /&gt;
&lt;br /&gt;
Example of a valid function using the D2Editor &lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
 function createRichTextBox&lt;br /&gt;
 	box = D2Editor.newRichText()&lt;br /&gt;
 	box:move(50, 50)&lt;br /&gt;
 	box:resize(50, 50)&lt;br /&gt;
 	box:setText(&amp;quot;Hello World !&amp;quot;)&lt;br /&gt;
 end&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External Links  ==&lt;br /&gt;
&lt;br /&gt;
An interesting page about LUA code optimization, that can be really useful, especially for calculators&amp;amp;nbsp;: [http://trac.caspring.org/wiki/LuaPerformance Lua Performance] &lt;br /&gt;
&lt;br /&gt;
== Online Demo  ==&lt;br /&gt;
&lt;br /&gt;
[[Document Player]]&lt;/div&gt;</summary>
		<author><name>Jonius7</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.inspired-lua.org/index.php?title=Overview_of_the_API&amp;diff=1013</id>
		<title>Overview of the API</title>
		<link rel="alternate" type="text/html" href="https://wiki.inspired-lua.org/index.php?title=Overview_of_the_API&amp;diff=1013"/>
		<updated>2013-06-30T06:01:55Z</updated>

		<summary type="html">&lt;p&gt;Jonius7: /* Events */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note: Neither the ''io'' nor ''os'' libraries are present for the TI-Nspire, which seems to be running a light version of Lua 5.1.4. &lt;br /&gt;
&lt;br /&gt;
== Standard Library  ==&lt;br /&gt;
&lt;br /&gt;
( This has been taken from [http://www.wowwiki.com/Lua_functions a WoWWiki page] - See the full, official documentation [http://www.lua.org/manual/5.1/manual.html here] )&lt;br /&gt;
&lt;br /&gt;
=== Basic Library Functions ===&lt;br /&gt;
&lt;br /&gt;
*'''[[G]]''' - Global Variable - A global variable (not a function) that holds the global environment (that is, _G._G = _G). Lua itself does not use this variable; changing its value does not affect any environment, nor vice-versa. (Use setfenv to change environments.) - taken from Lua docs &lt;br /&gt;
*'''[[assert]]'''(value[, errormsg]) - asserts a value evaluates to true. If it is, returns value, otherwise causes a Lua error to be thrown. &lt;br /&gt;
*'''[[collectgarbage]]'''&lt;br /&gt;
*'''[[error]]'''&lt;br /&gt;
*'''[[getfenv]]'''(function or integer) - Returns the table representing the stack frame of the given function or stack level. &lt;br /&gt;
*'''[[getmetatable]]'''(obj, mtable) - Returns the metatable of the given table or userdata object. &lt;br /&gt;
*'''[[next]]'''(table, index) - Returns the next key, value pair of the table, allowing you to walk over the table. &lt;br /&gt;
*'''[[newproxy]]'''(boolean or proxy) - Creates a userdata with a sharable metatable. &lt;br /&gt;
*'''[[print]]''' - print (···) - Receives any number of arguments, and prints their values to stdout, using the tostring function to convert them to strings. print is not intended for formatted output, but only as a quick way to show a value, typically for debugging. For formatted output, use string.format. - taken from Lua Docs &lt;br /&gt;
*'''[[select]]'''(index, list) - Returns the number of items in list or the value of the item in list at index. &lt;br /&gt;
*'''[[setfenv]]'''(function or integer, table) - Sets the table representing the stack frame of the given function or stack level. &lt;br /&gt;
*'''[[setmetatable]]'''(obj, mtable) - Sets the metatable of the given table or userdata object. &lt;br /&gt;
*'''[[tostring]]''' - tostring (e) - Receives an argument of any type and converts it to a string in a reasonable format. For complete control of how numbers are converted, use string.format. If the metatable of e has a &amp;quot;__tostring&amp;quot; field, then tostring calls the corresponding value with e as argument, and uses the result of the call as its result. - taken from Lua Docs. &lt;br /&gt;
*'''[[tonumber]]''' - tonumber (e) - Receives an argument of the string type and converts it to a number when possible. If the metatable of e has a &amp;quot;__tonumber&amp;quot; field, then tonumber calls the corresponding value with e as argument, and uses the result of the call as its result. - taken from Lua Docs. &lt;br /&gt;
&lt;br /&gt;
*'''[[type]]'''(var) - Returns the type of variable as a string, &amp;quot;number&amp;quot;, &amp;quot;string&amp;quot;, &amp;quot;table&amp;quot;, &amp;quot;function&amp;quot; or &amp;quot;userdata&amp;quot;. &lt;br /&gt;
*'''[[unpack]]'''(table[, start][, end]) - Returns the contents of its argument as separate values. &lt;br /&gt;
*'''[[xpcall]]'''(func, err) - Returns a boolean indicating successful execution of func and calls err on failure, additionally returning func's or err's results.&lt;br /&gt;
&lt;br /&gt;
=== String Library ===&lt;br /&gt;
byte char dump find format gmatch gsub len lower match rep reverse sub upper&lt;br /&gt;
&lt;br /&gt;
=== Math Library ===&lt;br /&gt;
abs acos asin atan atan2 ceil cos cosh deg exp  oor fmod frexp huge ldexp log log10 max min modf pi pow rad random randomseed sin sinh sqrt tan tanh&lt;br /&gt;
&lt;br /&gt;
More information about the other libraries can be found on the [[Extended Standard Library]] Page&lt;br /&gt;
&lt;br /&gt;
== Concepts and Basics  ==&lt;br /&gt;
&lt;br /&gt;
This part will explain you how the Lua actually works inside the OS and help you to figure out what you're doing when you write a script for the TI-Nspire. Before reading this, you have to know all about the Lua basics. &lt;br /&gt;
&lt;br /&gt;
The Lua is an interpreted script language which means that it isn't as fast as ASM/C programs, but is still better than the TI-BASIC. One good thing is that this language is in a complete harmony with the OS with basic events and a powerfull graphic context. First, we have to understand how this works. Basicly the script is launched before the executive engine. This means that we can neither evaluate expressions nor use some of the standard API (like platform, var) until the engine is launched. Here is a call summary&amp;amp;nbsp;: &lt;br /&gt;
&lt;br /&gt;
*Launch string library &lt;br /&gt;
*Launch math library &lt;br /&gt;
*... &lt;br /&gt;
*Open and launch User's Lua script &lt;br /&gt;
*... &lt;br /&gt;
*Launch var API (store, recall, ...) &lt;br /&gt;
*Launch platform API (window, gc, ...) &lt;br /&gt;
*... &lt;br /&gt;
*Link events (pseudo code)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;while(Exit)&lt;br /&gt;
 	------- Some OS routines here&lt;br /&gt;
 &lt;br /&gt;
  	---- Begin of Event link&lt;br /&gt;
 	buffer:captureDataFromKeyPad() 	 	 	--  (N) some underground routines to catch events&lt;br /&gt;
 	if buffer.charInput ~= &amp;quot;&amp;quot; then 	 	 	--  (N)&lt;br /&gt;
 		on.charIn(buffer.charInput)&lt;br /&gt;
 		buffer.charInput= &amp;quot;&amp;quot; 	 	 	--  (N)&lt;br /&gt;
 	end&lt;br /&gt;
 	if buffer.arrowKey ~= &amp;quot;&amp;quot; then 	 	 	--  (N)&lt;br /&gt;
 		on.arrowKey(buffer.arrowKey)&lt;br /&gt;
 		buffer.arrowKey = &amp;quot;&amp;quot; 	 	 	--  (N)&lt;br /&gt;
 	end&lt;br /&gt;
 	----- etc ... 	&lt;br /&gt;
 	if platform.window.isInvalidate then &lt;br /&gt;
 	 	platform.gc():purge()	 	 	--  (N) Empty buffer before starting to draw&lt;br /&gt;
 		on.paint(platform.gc()) 	  	-- save all the things we have to draw&lt;br /&gt;
 	 	platform:paint() 	 	  	--  (N) draw all those things&lt;br /&gt;
 		platform.window.isInvalidate = false 	-- say that the window has been drawn&lt;br /&gt;
 	end&lt;br /&gt;
 	----- End of Event link&lt;br /&gt;
end''&lt;br /&gt;
Note : the (N) commented line only indicates the meaning of the routine. Those functions don't really exist.&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can understand how everything is linked, just by a main loop. This helps you to understand that you don't have to code a loop yourself, because the screen wouldn't be refreshed. This also helps to see when the screen gets refreshed. In other words, we cannot use niether '''gc''' nor '''platform.gc()''' (which are the same) in order to draw somthing on the screen if we are outside of '''on.paint()''' (except if your outside function is called within on.paint() ). This also means that we don't need to pass '''gc''' as parameter, because we can rather use '''platform.gc()''' for any functions called within on.paint(). This is exactly what [https://github.com/adriweb/BetterLuaAPI-for-TI-Nspire/blob/master/BetterLuaAPI.lua the BetterLuaAPI library for Nspire] does. &lt;br /&gt;
&lt;br /&gt;
Here is an example of a simple Lua program that displays a message only when a key is pressed (and let the screen blank otherwise). &lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt; function on.paint(gc)&lt;br /&gt;
 	if message then&lt;br /&gt;
 	 	gc:setFont(&amp;quot;sansserif&amp;quot;, &amp;quot;r&amp;quot;, 10)	-- initialize font drawing&lt;br /&gt;
 	 	gc:drawString(message, 0, 0, &amp;quot;top&amp;quot;)	-- display the message at (0, 0) coordinates&lt;br /&gt;
 	 	message = nil 				-- erase the message&lt;br /&gt;
 	 	timer.start(1) 	 	 	-- start a timer to exit on.paint() but keep in mind that we have to redraw the screen&lt;br /&gt;
 	end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.timer()&lt;br /&gt;
 	timer.stop()&lt;br /&gt;
 	platform.window:invalidate()&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.charIn(ch)&lt;br /&gt;
 	message = &amp;quot;Hello World !&amp;quot;		-- store a message&lt;br /&gt;
 	platform.window:invalidate()		-- force display&lt;br /&gt;
 end&amp;lt;/source&amp;gt;&lt;br /&gt;
When you open the document, the script is read once. It initializes and overwrites all the functions and globals with the ones you defined. Thus, '''message''' is nil. Once the '''on.paint()''' event is called, '''message''' is nil, thus, nothing is done. When you press a key that calls '''on.charIn()''' (see below for more information), '''message''' is now &amp;quot;Hello World&amp;quot; and we tell the '''platform''' that the screen has to be refreshed. Then, '''on.paint()''' is called again, '''message''' is not nil then we display it, erase '''message''' and launch a timer. Why is that&amp;amp;nbsp;? Because if we call '''platform.window:invalidate()''' right there, we won't refresh the screen. Why again&amp;amp;nbsp;? Just look at the pseudo-code above. We set the window as drawn after each call of on.paint(). Thus a timer is necessary to manually recall '''on.paint()''' and exit the '''on.paint()''' function to draw the screen. When the timer is ended, '''on.timer()''' is called and we refresh the screen. The screen is then redrawn but there is nothing to draw because '''message''' is nil. Thus, the graphic context lets the screen blank. &lt;br /&gt;
&lt;br /&gt;
== gc (as in Graphics Context)  ==&lt;br /&gt;
&lt;br /&gt;
Note: You need to add “gc:” before each of these commands in order to use them. ex. '''gc:setAlpha(...)'''. You can also call gc like this&amp;amp;nbsp;: '''platform.gc():setAlpha(...)'''. Then you can use the gc library in a function where gc is not passed as an argument. but this function *has* to be called within '''on.paint(gc)''' &lt;br /&gt;
&lt;br /&gt;
The maximum screen resolution available to Lua programs is 318 by 212 pixels. &lt;br /&gt;
&lt;br /&gt;
*'''[[gc:begin]]''' - &lt;br /&gt;
*'''[[gc:clipRect]]''' - &lt;br /&gt;
*'''[[gc:drawArc]]'''(x, y, width, height, start angle, finish angle) Note, to draw a circle, use drawArc(x - diameter/2, y - diameter/2, diameter,diameter,0,360) where x and y are the coordinates of the middle. &lt;br /&gt;
*'''[[gc:drawImage]]'''(image,x,y) First argument in format “[[TI.Image]]”, x and y the coords. &lt;br /&gt;
*'''[[gc:drawLine]]'''(xstart, ystart, xend, yend) Draws a line starting at the point (xstart,ystart) and ending at the point (xend, yend) &lt;br /&gt;
*'''[[gc:drawPolyLine]]'''(int list1 [,int list2, .., int listN]) Draws a shape from a list contaning successively the x and y coordinates of each point the line have to draw.&lt;br /&gt;
&lt;br /&gt;
*'''[[gc:drawRect]]'''(x, y, xwidth, yheight) Draws a rectangle at (x,y) with the “x” side being “xwidth” long and the “y” side being “yheight” long &lt;br /&gt;
*'''[[gc:drawString]]'''(string, x, y, PositionString) PositionString is the string’s anchor point and can be “bottom”, “middle”, or “top”. &lt;br /&gt;
*'''[[gc:fillArc]]'''(x, y, width, height, start angle, finish angle) see drawArc &lt;br /&gt;
*'''[[gc:fillPolygon]]'''(int list1 [,int list2, .., int listN]) see drawPolyLine &lt;br /&gt;
*'''[[gc:fillRect]]'''(x, y, width, height) see drawRect &lt;br /&gt;
*'''[[gc:finish]]''' - &lt;br /&gt;
*'''[[gc:getStringHeight]]'''(string) &lt;br /&gt;
*'''[[gc:getStringWidth]]'''(string) &lt;br /&gt;
*'''[[gc:isColorDisplay]]''' Bool (Read-only) Returns 1 if color, 0 if not. &lt;br /&gt;
*'''[[gc:setAlpha]]'''(int) - where the argument is an int between 0 and 255. Sets the transparency. &lt;br /&gt;
*'''[[gc:setColorRGB]]'''(red, green, blue) RGB values are integers, from 0 to 255. &lt;br /&gt;
*'''[[gc:setFont]]'''(font, type, size), with font&amp;amp;nbsp;: {“sansserif”, &amp;quot;serif&amp;quot;, ..}, type {“b”, “r”, “i”}, size(int) &lt;br /&gt;
*'''[[gc:setPen]]'''(size, smooth) size {“thin”, “medium”, &amp;quot;thick&amp;quot;}, smooth {“smooth”, &amp;quot;dotted&amp;quot;, &amp;quot;dashed&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
== platform  ==&lt;br /&gt;
&lt;br /&gt;
These are mainly read-only. These work by writing &amp;quot;'''platform.'''&amp;quot; in front of them. Example&amp;amp;nbsp;: &amp;quot;'''platform.window:invalidate()'''&amp;quot; &lt;br /&gt;
&lt;br /&gt;
*'''[[platform.apilevel]]'''&amp;amp;nbsp;: Returns the version of the API. Currently (OS 3.0.1) returns 1.0.0. &lt;br /&gt;
*'''[[platform.window]]'''&lt;br /&gt;
&lt;br /&gt;
:*'''[[platform.window:width]]''' - Returns the width of the window. Ex&amp;amp;nbsp;: ''platform.window:height()'' &lt;br /&gt;
:*'''[[platform.window:height]]''' - Returns the height of the window &lt;br /&gt;
:*'''[[platform.window:invalidate]]''' - Repaints the window (it calls '''on.paint(gc)''')&lt;br /&gt;
&lt;br /&gt;
*'''[[platform.isDeviceModeRendering]]''' Returns true or false whether the unit is &amp;quot;rendering&amp;quot; or not &lt;br /&gt;
*'''[[platform.gc]]''' - Other way to call '''gc'''. Use it like that&amp;amp;nbsp;: '''platform.gc():setAlpha(...)''' for example. This is useful when you're in a function outside '''on.paint(gc)''' (but this function has to be called within [[on.paint]](gc).) &lt;br /&gt;
*'''[[platform.isColorDisplay]]''' Returns ''true'' if the unit the code is being run on has a color display (-&amp;amp;gt; Nspire CX), and ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
== cursor  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[cursor.hide]]'''() - hides the cursor (mouse pointer) &lt;br /&gt;
*'''[[cursor.set]]'''(string) - string can be one of those&amp;amp;nbsp;: (interrogation, crosshair, text, pointer, link select, diag resize, wait busy, hollow pointer, rotation, pencil, zoom box, arrow, zoom out, dotted arrow, clear, animate, excel plus, mod label, writing, unavailable, resize row, resize column, drag grab, hand open, hand closed, hand pointer, zoom in, dilation, translation). &lt;br /&gt;
*'''[[cursor.show]]'''() - Shows the cursor on screen&lt;br /&gt;
&lt;br /&gt;
== document  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[document.markChanged]]'''() - Flag the document as &amp;quot;changed&amp;quot; so the user has to save it after using it.&lt;br /&gt;
&lt;br /&gt;
== clipboard  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[clipboard.addText]]'''() &lt;br /&gt;
*'''[[clipboard.getText]]'''()&lt;br /&gt;
&lt;br /&gt;
== locale  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[locale.name]]'''() - Returns the current language the calculator is set in, formatted as ISO-639 (i.e&amp;amp;nbsp;: &amp;quot;fr&amp;quot;, &amp;quot;en&amp;quot;, &amp;quot;it&amp;quot; ...).&lt;br /&gt;
&lt;br /&gt;
== image  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[image.copy]]'''(image, width, height) - returns a new Image which has a new scale. Width is the final width, Heigth, the final height of the image. &lt;br /&gt;
*'''[[image.height]]'''(image) - returns the height of the image given in parameter &lt;br /&gt;
*'''[[image.new]]'''(string) - Creates a new image from the string given in parameter (see TI.Image).&lt;br /&gt;
*'''[[image.width]]'''(image) - returns the width of the image given in parameter&lt;br /&gt;
&lt;br /&gt;
== timer  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[timer.getMilliSecCounter]]'''() - Returns the amount of milliseconds elapsed since last calculator reboot. (in TI's Computer software, returns an absolute negative time) &lt;br /&gt;
*'''[[timer.start]]'''(int) - Starts a timer with 1 second. &lt;br /&gt;
*'''[[timer.stop]]'''() - Stops a timer&lt;br /&gt;
&lt;br /&gt;
== toolpalette  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[toolpalette.enable]]'''(string) &lt;br /&gt;
*'''[[toolpalette.enableCopy]]'''() &lt;br /&gt;
*'''[[toolpalette.enableCut]]'''() &lt;br /&gt;
*'''[[toolpalette.enablePaste]]'''() &lt;br /&gt;
*'''[[toolpalette.register]]'''(table)&lt;br /&gt;
&lt;br /&gt;
== var  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[var.list]]'''() - returns a list of all the variables in the entire Activity &lt;br /&gt;
*'''[[var.monitor]]'''() -&amp;amp;nbsp;? &lt;br /&gt;
*'''[[var.recall]]'''(string) - returns the variable value which name is given in parameter &lt;br /&gt;
*'''[[var.recallstr]]'''(string) - returns the variable value converted to string which name is given in parameter &lt;br /&gt;
*'''[[var.store]]'''(string, value) - store in the variable, which name is given in parameter, the value &lt;br /&gt;
*'''[[var.unmonitor]]'''() -&amp;amp;nbsp;?&lt;br /&gt;
&lt;br /&gt;
== Events  ==&lt;br /&gt;
*'''[[on.create]]''' function called when script application is created. Removed in OS 3.2 (API v2.0)&lt;br /&gt;
*'''[[on.construction]]''' function that is guaranteed to run first before any other function. New in OS 3.2 (API v2.0)&lt;br /&gt;
*'''[[on.paint]]'''(gc) is called when the GUI is painted. 'gc' is the Graphics Context (see above) &lt;br /&gt;
*'''[[on.resize]]'''() is called when the window is rezised &lt;br /&gt;
*'''[[on.timer]]'''() is called when the timer has been finished. Here an example of using timer to play an animation&amp;amp;nbsp;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt; x = 1&lt;br /&gt;
 animating = false&lt;br /&gt;
 function on.paint(gc)&lt;br /&gt;
 	gc:setFont(&amp;quot;sansserif&amp;quot;, &amp;quot;r&amp;quot;, 10)&lt;br /&gt;
 	gc:drawString(tostring(x), 0, 0, &amp;quot;top&amp;quot;)&lt;br /&gt;
 	if animating then&lt;br /&gt;
 		x = x + 1&lt;br /&gt;
 		timer.start(0.5)&lt;br /&gt;
 	end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.charIn(ch)&lt;br /&gt;
 	animating = not animating -- switch state&lt;br /&gt;
 	platform.window:invalidate() -- recall graph engine&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.timer()&lt;br /&gt;
 	timer.stop()&lt;br /&gt;
 	platform.window:invalidate() -- recall graph engine&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.arrowKey]]'''(key) is called when an '''arrow key''' from the clickPad/TouchPad is pressed (right, left, up, down) &lt;br /&gt;
*'''[[on.arrowLeft]]'''() is called when the '''left''' arrow is pressed &lt;br /&gt;
*'''[[on.arrowRight]]'''() is called when the '''right''' arrow is pressed &lt;br /&gt;
*'''[[on.arrowUp]]'''() is called when the up '''arrow''' is pressed &lt;br /&gt;
*'''[[on.arrowDown]]'''() is called when the '''down''' arrow is pressed&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.up]]'''() -- probably for the touchpad up motion &lt;br /&gt;
*'''[[on.down]]'''() -- probably for the touchpad down motion&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.enterKey]]'''() is called when the '''enter''' key is pressed. &lt;br /&gt;
*'''[[on.escapeKey]]'''() is called when the '''escape''' key is pressed. &lt;br /&gt;
*'''[[on.tabKey]]'''() is called when the '''tab''' key is pressed. &lt;br /&gt;
*'''[[on.deleteKey]]'''() is called when the '''delete''' key is pressed. &lt;br /&gt;
*'''[[on.backspaceKey]]'''() is called when the '''clear''' key is pressed. &lt;br /&gt;
*'''[[on.returnKey]]'''() is called when the '''return''' key is pressed. &lt;br /&gt;
*'''[[on.contextMenu]]'''() is called when the combo-key '''Ctrl Menu''' is pressed. &lt;br /&gt;
*'''[[on.backtabKey]]'''() is called when the combo-key '''Maj Tab''' is pressed. &lt;br /&gt;
*'''[[on.clearKey]]'''() is called when the combo-key '''Ctrl Clear''' is pressed. &lt;br /&gt;
*'''[[on.help]]'''() is called when the combo-key '''Ctrl H''' is pressed.&lt;br /&gt;
&lt;br /&gt;
*'''[[on.charIn]]'''(string) is called when the Nspire detects a non arrow key being pressed. ch is the character it detect. If you want to auto start an event in the file linked to key r(like a reset) put on.charIn(“r”) where you want.&lt;br /&gt;
&lt;br /&gt;
*'''[[on.blink]]'''()&amp;amp;nbsp;? is called when the focus is lost on the page (like launching the document, changing page etc...)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.deactivate]]'''()&amp;amp;nbsp;? is called when the focus is lost on the page (like launching the document, changing page etc...) &lt;br /&gt;
*'''[[on.activate]]'''()&amp;amp;nbsp;? is called when the focus is on the page (like launching the document, changing page etc...)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.mouseDown]]'''(x, y) is called when we press the left mouse button. X and Y are the pressed point coordinates. &lt;br /&gt;
*'''[[on.mouseUp]]'''() is called when we release the left mouse button. &lt;br /&gt;
*'''[[on.mouseMove]]'''() is called when the mouse moves &lt;br /&gt;
*'''[[on.grabDown]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.grabMove]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.grabUp]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.rightMouseDown]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.rightMouseUp]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.cutEnabled]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.copyEnabled]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.pasteEnabled]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.cut]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.copy]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.paste]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== D2Editor  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[D2Editor.newRichText]]'''() creates a new RichText object (default values&amp;amp;nbsp;: x, y, width, height = 0) &lt;br /&gt;
*'''[[D2Editor.resize]]'''(width, height) &lt;br /&gt;
*'''[[D2Editor.move]]'''(x, y) &lt;br /&gt;
*'''[[D2Editor.setText]]'''(string) &lt;br /&gt;
*'''[[D2Editor.getText]]'''() returns the RichText value &lt;br /&gt;
*'''[[D2Editor.setReadOnly]]'''(bool) bool&amp;amp;nbsp;: true/false&amp;amp;nbsp;: If true, the content becomes read-only, i.e. non-editable. &lt;br /&gt;
*'''[[D2Editor.setFormattedText]]'''() - ?&lt;br /&gt;
&lt;br /&gt;
Example of a valid function using the D2Editor &lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
 function createRichTextBox&lt;br /&gt;
 	box = D2Editor.newRichText()&lt;br /&gt;
 	box:move(50, 50)&lt;br /&gt;
 	box:resize(50, 50)&lt;br /&gt;
 	box:setText(&amp;quot;Hello World !&amp;quot;)&lt;br /&gt;
 end&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External Links  ==&lt;br /&gt;
&lt;br /&gt;
An interesting page about LUA code optimization, that can be really useful, especially for calculators&amp;amp;nbsp;: [http://trac.caspring.org/wiki/LuaPerformance Lua Performance] &lt;br /&gt;
&lt;br /&gt;
== Online Demo  ==&lt;br /&gt;
&lt;br /&gt;
[[Document Player]]&lt;/div&gt;</summary>
		<author><name>Jonius7</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.inspired-lua.org/index.php?title=Overview_of_the_API&amp;diff=1011</id>
		<title>Overview of the API</title>
		<link rel="alternate" type="text/html" href="https://wiki.inspired-lua.org/index.php?title=Overview_of_the_API&amp;diff=1011"/>
		<updated>2013-06-29T09:46:40Z</updated>

		<summary type="html">&lt;p&gt;Jonius7: /* Standard Library */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note: Neither the ''io'' nor ''os'' libraries are present for the TI-Nspire, which seems to be running a light version of Lua 5.1.4. &lt;br /&gt;
&lt;br /&gt;
== Standard Library  ==&lt;br /&gt;
&lt;br /&gt;
( This has been taken from [http://www.wowwiki.com/Lua_functions a WoWWiki page] - See the full, official documentation [http://www.lua.org/manual/5.1/manual.html here] )&lt;br /&gt;
&lt;br /&gt;
=== Basic Library Functions ===&lt;br /&gt;
&lt;br /&gt;
*'''[[G]]''' - Global Variable - A global variable (not a function) that holds the global environment (that is, _G._G = _G). Lua itself does not use this variable; changing its value does not affect any environment, nor vice-versa. (Use setfenv to change environments.) - taken from Lua docs &lt;br /&gt;
*'''[[assert]]'''(value[, errormsg]) - asserts a value evaluates to true. If it is, returns value, otherwise causes a Lua error to be thrown. &lt;br /&gt;
*'''[[collectgarbage]]'''&lt;br /&gt;
*'''[[error]]'''&lt;br /&gt;
*'''[[getfenv]]'''(function or integer) - Returns the table representing the stack frame of the given function or stack level. &lt;br /&gt;
*'''[[getmetatable]]'''(obj, mtable) - Returns the metatable of the given table or userdata object. &lt;br /&gt;
*'''[[next]]'''(table, index) - Returns the next key, value pair of the table, allowing you to walk over the table. &lt;br /&gt;
*'''[[newproxy]]'''(boolean or proxy) - Creates a userdata with a sharable metatable. &lt;br /&gt;
*'''[[print]]''' - print (···) - Receives any number of arguments, and prints their values to stdout, using the tostring function to convert them to strings. print is not intended for formatted output, but only as a quick way to show a value, typically for debugging. For formatted output, use string.format. - taken from Lua Docs &lt;br /&gt;
*'''[[select]]'''(index, list) - Returns the number of items in list or the value of the item in list at index. &lt;br /&gt;
*'''[[setfenv]]'''(function or integer, table) - Sets the table representing the stack frame of the given function or stack level. &lt;br /&gt;
*'''[[setmetatable]]'''(obj, mtable) - Sets the metatable of the given table or userdata object. &lt;br /&gt;
*'''[[tostring]]''' - tostring (e) - Receives an argument of any type and converts it to a string in a reasonable format. For complete control of how numbers are converted, use string.format. If the metatable of e has a &amp;quot;__tostring&amp;quot; field, then tostring calls the corresponding value with e as argument, and uses the result of the call as its result. - taken from Lua Docs. &lt;br /&gt;
*'''[[tonumber]]''' - tonumber (e) - Receives an argument of the string type and converts it to a number when possible. If the metatable of e has a &amp;quot;__tonumber&amp;quot; field, then tonumber calls the corresponding value with e as argument, and uses the result of the call as its result. - taken from Lua Docs. &lt;br /&gt;
&lt;br /&gt;
*'''[[type]]'''(var) - Returns the type of variable as a string, &amp;quot;number&amp;quot;, &amp;quot;string&amp;quot;, &amp;quot;table&amp;quot;, &amp;quot;function&amp;quot; or &amp;quot;userdata&amp;quot;. &lt;br /&gt;
*'''[[unpack]]'''(table[, start][, end]) - Returns the contents of its argument as separate values. &lt;br /&gt;
*'''[[xpcall]]'''(func, err) - Returns a boolean indicating successful execution of func and calls err on failure, additionally returning func's or err's results.&lt;br /&gt;
&lt;br /&gt;
=== String Library ===&lt;br /&gt;
byte char dump find format gmatch gsub len lower match rep reverse sub upper&lt;br /&gt;
&lt;br /&gt;
=== Math Library ===&lt;br /&gt;
abs acos asin atan atan2 ceil cos cosh deg exp  oor fmod frexp huge ldexp log log10 max min modf pi pow rad random randomseed sin sinh sqrt tan tanh&lt;br /&gt;
&lt;br /&gt;
More information about the other libraries can be found on the [[Extended Standard Library]] Page&lt;br /&gt;
&lt;br /&gt;
== Concepts and Basics  ==&lt;br /&gt;
&lt;br /&gt;
This part will explain you how the Lua actually works inside the OS and help you to figure out what you're doing when you write a script for the TI-Nspire. Before reading this, you have to know all about the Lua basics. &lt;br /&gt;
&lt;br /&gt;
The Lua is an interpreted script language which means that it isn't as fast as ASM/C programs, but is still better than the TI-BASIC. One good thing is that this language is in a complete harmony with the OS with basic events and a powerfull graphic context. First, we have to understand how this works. Basicly the script is launched before the executive engine. This means that we can neither evaluate expressions nor use some of the standard API (like platform, var) until the engine is launched. Here is a call summary&amp;amp;nbsp;: &lt;br /&gt;
&lt;br /&gt;
*Launch string library &lt;br /&gt;
*Launch math library &lt;br /&gt;
*... &lt;br /&gt;
*Open and launch User's Lua script &lt;br /&gt;
*... &lt;br /&gt;
*Launch var API (store, recall, ...) &lt;br /&gt;
*Launch platform API (window, gc, ...) &lt;br /&gt;
*... &lt;br /&gt;
*Link events (pseudo code)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;while(Exit)&lt;br /&gt;
 	------- Some OS routines here&lt;br /&gt;
 &lt;br /&gt;
  	---- Begin of Event link&lt;br /&gt;
 	buffer:captureDataFromKeyPad() 	 	 	--  (N) some underground routines to catch events&lt;br /&gt;
 	if buffer.charInput ~= &amp;quot;&amp;quot; then 	 	 	--  (N)&lt;br /&gt;
 		on.charIn(buffer.charInput)&lt;br /&gt;
 		buffer.charInput= &amp;quot;&amp;quot; 	 	 	--  (N)&lt;br /&gt;
 	end&lt;br /&gt;
 	if buffer.arrowKey ~= &amp;quot;&amp;quot; then 	 	 	--  (N)&lt;br /&gt;
 		on.arrowKey(buffer.arrowKey)&lt;br /&gt;
 		buffer.arrowKey = &amp;quot;&amp;quot; 	 	 	--  (N)&lt;br /&gt;
 	end&lt;br /&gt;
 	----- etc ... 	&lt;br /&gt;
 	if platform.window.isInvalidate then &lt;br /&gt;
 	 	platform.gc():purge()	 	 	--  (N) Empty buffer before starting to draw&lt;br /&gt;
 		on.paint(platform.gc()) 	  	-- save all the things we have to draw&lt;br /&gt;
 	 	platform:paint() 	 	  	--  (N) draw all those things&lt;br /&gt;
 		platform.window.isInvalidate = false 	-- say that the window has been drawn&lt;br /&gt;
 	end&lt;br /&gt;
 	----- End of Event link&lt;br /&gt;
end''&lt;br /&gt;
Note : the (N) commented line only indicates the meaning of the routine. Those functions don't really exist.&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can understand how everything is linked, just by a main loop. This helps you to understand that you don't have to code a loop yourself, because the screen wouldn't be refreshed. This also helps to see when the screen gets refreshed. In other words, we cannot use niether '''gc''' nor '''platform.gc()''' (which are the same) in order to draw somthing on the screen if we are outside of '''on.paint()''' (except if your outside function is called within on.paint() ). This also means that we don't need to pass '''gc''' as parameter, because we can rather use '''platform.gc()''' for any functions called within on.paint(). This is exactly what [https://github.com/adriweb/BetterLuaAPI-for-TI-Nspire/blob/master/BetterLuaAPI.lua the BetterLuaAPI library for Nspire] does. &lt;br /&gt;
&lt;br /&gt;
Here is an example of a simple Lua program that displays a message only when a key is pressed (and let the screen blank otherwise). &lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt; function on.paint(gc)&lt;br /&gt;
 	if message then&lt;br /&gt;
 	 	gc:setFont(&amp;quot;sansserif&amp;quot;, &amp;quot;r&amp;quot;, 10)	-- initialize font drawing&lt;br /&gt;
 	 	gc:drawString(message, 0, 0, &amp;quot;top&amp;quot;)	-- display the message at (0, 0) coordinates&lt;br /&gt;
 	 	message = nil 				-- erase the message&lt;br /&gt;
 	 	timer.start(1) 	 	 	-- start a timer to exit on.paint() but keep in mind that we have to redraw the screen&lt;br /&gt;
 	end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.timer()&lt;br /&gt;
 	timer.stop()&lt;br /&gt;
 	platform.window:invalidate()&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.charIn(ch)&lt;br /&gt;
 	message = &amp;quot;Hello World !&amp;quot;		-- store a message&lt;br /&gt;
 	platform.window:invalidate()		-- force display&lt;br /&gt;
 end&amp;lt;/source&amp;gt;&lt;br /&gt;
When you open the document, the script is read once. It initializes and overwrites all the functions and globals with the ones you defined. Thus, '''message''' is nil. Once the '''on.paint()''' event is called, '''message''' is nil, thus, nothing is done. When you press a key that calls '''on.charIn()''' (see below for more information), '''message''' is now &amp;quot;Hello World&amp;quot; and we tell the '''platform''' that the screen has to be refreshed. Then, '''on.paint()''' is called again, '''message''' is not nil then we display it, erase '''message''' and launch a timer. Why is that&amp;amp;nbsp;? Because if we call '''platform.window:invalidate()''' right there, we won't refresh the screen. Why again&amp;amp;nbsp;? Just look at the pseudo-code above. We set the window as drawn after each call of on.paint(). Thus a timer is necessary to manually recall '''on.paint()''' and exit the '''on.paint()''' function to draw the screen. When the timer is ended, '''on.timer()''' is called and we refresh the screen. The screen is then redrawn but there is nothing to draw because '''message''' is nil. Thus, the graphic context lets the screen blank. &lt;br /&gt;
&lt;br /&gt;
== gc (as in Graphics Context)  ==&lt;br /&gt;
&lt;br /&gt;
Note: You need to add “gc:” before each of these commands in order to use them. ex. '''gc:setAlpha(...)'''. You can also call gc like this&amp;amp;nbsp;: '''platform.gc():setAlpha(...)'''. Then you can use the gc library in a function where gc is not passed as an argument. but this function *has* to be called within '''on.paint(gc)''' &lt;br /&gt;
&lt;br /&gt;
The maximum screen resolution available to Lua programs is 318 by 212 pixels. &lt;br /&gt;
&lt;br /&gt;
*'''[[gc:begin]]''' - &lt;br /&gt;
*'''[[gc:clipRect]]''' - &lt;br /&gt;
*'''[[gc:drawArc]]'''(x, y, width, height, start angle, finish angle) Note, to draw a circle, use drawArc(x - diameter/2, y - diameter/2, diameter,diameter,0,360) where x and y are the coordinates of the middle. &lt;br /&gt;
*'''[[gc:drawImage]]'''(image,x,y) First argument in format “[[TI.Image]]”, x and y the coords. &lt;br /&gt;
*'''[[gc:drawLine]]'''(xstart, ystart, xend, yend) Draws a line starting at the point (xstart,ystart) and ending at the point (xend, yend) &lt;br /&gt;
*'''[[gc:drawPolyLine]]'''(int list1 [,int list2, .., int listN]) Draws a shape from a list contaning successively the x and y coordinates of each point the line have to draw.&lt;br /&gt;
&lt;br /&gt;
*'''[[gc:drawRect]]'''(x, y, xwidth, yheight) Draws a rectangle at (x,y) with the “x” side being “xwidth” long and the “y” side being “yheight” long &lt;br /&gt;
*'''[[gc:drawString]]'''(string, x, y, PositionString) PositionString is the string’s anchor point and can be “bottom”, “middle”, or “top”. &lt;br /&gt;
*'''[[gc:fillArc]]'''(x, y, width, height, start angle, finish angle) see drawArc &lt;br /&gt;
*'''[[gc:fillPolygon]]'''(int list1 [,int list2, .., int listN]) see drawPolyLine &lt;br /&gt;
*'''[[gc:fillRect]]'''(x, y, width, height) see drawRect &lt;br /&gt;
*'''[[gc:finish]]''' - &lt;br /&gt;
*'''[[gc:getStringHeight]]'''(string) &lt;br /&gt;
*'''[[gc:getStringWidth]]'''(string) &lt;br /&gt;
*'''[[gc:isColorDisplay]]''' Bool (Read-only) Returns 1 if color, 0 if not. &lt;br /&gt;
*'''[[gc:setAlpha]]'''(int) - where the argument is an int between 0 and 255. Sets the transparency. &lt;br /&gt;
*'''[[gc:setColorRGB]]'''(red, green, blue) RGB values are integers, from 0 to 255. &lt;br /&gt;
*'''[[gc:setFont]]'''(font, type, size), with font&amp;amp;nbsp;: {“sansserif”, &amp;quot;serif&amp;quot;, ..}, type {“b”, “r”, “i”}, size(int) &lt;br /&gt;
*'''[[gc:setPen]]'''(size, smooth) size {“thin”, “medium”, &amp;quot;thick&amp;quot;}, smooth {“smooth”, &amp;quot;dotted&amp;quot;, &amp;quot;dashed&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
== platform  ==&lt;br /&gt;
&lt;br /&gt;
These are mainly read-only. These work by writing &amp;quot;'''platform.'''&amp;quot; in front of them. Example&amp;amp;nbsp;: &amp;quot;'''platform.window:invalidate()'''&amp;quot; &lt;br /&gt;
&lt;br /&gt;
*'''[[platform.apilevel]]'''&amp;amp;nbsp;: Returns the version of the API. Currently (OS 3.0.1) returns 1.0.0. &lt;br /&gt;
*'''[[platform.window]]'''&lt;br /&gt;
&lt;br /&gt;
:*'''[[platform.window:width]]''' - Returns the width of the window. Ex&amp;amp;nbsp;: ''platform.window:height()'' &lt;br /&gt;
:*'''[[platform.window:height]]''' - Returns the height of the window &lt;br /&gt;
:*'''[[platform.window:invalidate]]''' - Repaints the window (it calls '''on.paint(gc)''')&lt;br /&gt;
&lt;br /&gt;
*'''[[platform.isDeviceModeRendering]]''' Returns true or false whether the unit is &amp;quot;rendering&amp;quot; or not &lt;br /&gt;
*'''[[platform.gc]]''' - Other way to call '''gc'''. Use it like that&amp;amp;nbsp;: '''platform.gc():setAlpha(...)''' for example. This is useful when you're in a function outside '''on.paint(gc)''' (but this function has to be called within [[on.paint]](gc).) &lt;br /&gt;
*'''[[platform.isColorDisplay]]''' Returns ''true'' if the unit the code is being run on has a color display (-&amp;amp;gt; Nspire CX), and ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
== cursor  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[cursor.hide]]'''() - hides the cursor (mouse pointer) &lt;br /&gt;
*'''[[cursor.set]]'''(string) - string can be one of those&amp;amp;nbsp;: (interrogation, crosshair, text, pointer, link select, diag resize, wait busy, hollow pointer, rotation, pencil, zoom box, arrow, zoom out, dotted arrow, clear, animate, excel plus, mod label, writing, unavailable, resize row, resize column, drag grab, hand open, hand closed, hand pointer, zoom in, dilation, translation). &lt;br /&gt;
*'''[[cursor.show]]'''() - Shows the cursor on screen&lt;br /&gt;
&lt;br /&gt;
== document  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[document.markChanged]]'''() - Flag the document as &amp;quot;changed&amp;quot; so the user has to save it after using it.&lt;br /&gt;
&lt;br /&gt;
== clipboard  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[clipboard.addText]]'''() &lt;br /&gt;
*'''[[clipboard.getText]]'''()&lt;br /&gt;
&lt;br /&gt;
== locale  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[locale.name]]'''() - Returns the current language the calculator is set in, formatted as ISO-639 (i.e&amp;amp;nbsp;: &amp;quot;fr&amp;quot;, &amp;quot;en&amp;quot;, &amp;quot;it&amp;quot; ...).&lt;br /&gt;
&lt;br /&gt;
== image  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[image.copy]]'''(image, width, height) - returns a new Image which has a new scale. Width is the final width, Heigth, the final height of the image. &lt;br /&gt;
*'''[[image.height]]'''(image) - returns the height of the image given in parameter &lt;br /&gt;
*'''[[image.new]]'''(string) - Creates a new image from the string given in parameter (see TI.Image).&lt;br /&gt;
*'''[[image.width]]'''(image) - returns the width of the image given in parameter&lt;br /&gt;
&lt;br /&gt;
== timer  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[timer.getMilliSecCounter]]'''() - Returns the amount of milliseconds elapsed since last calculator reboot. (in TI's Computer software, returns an absolute negative time) &lt;br /&gt;
*'''[[timer.start]]'''(int) - Starts a timer with 1 second. &lt;br /&gt;
*'''[[timer.stop]]'''() - Stops a timer&lt;br /&gt;
&lt;br /&gt;
== toolpalette  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[toolpalette.enable]]'''(string) &lt;br /&gt;
*'''[[toolpalette.enableCopy]]'''() &lt;br /&gt;
*'''[[toolpalette.enableCut]]'''() &lt;br /&gt;
*'''[[toolpalette.enablePaste]]'''() &lt;br /&gt;
*'''[[toolpalette.register]]'''(table)&lt;br /&gt;
&lt;br /&gt;
== var  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[var.list]]'''() - returns a list of all the variables in the entire Activity &lt;br /&gt;
*'''[[var.monitor]]'''() -&amp;amp;nbsp;? &lt;br /&gt;
*'''[[var.recall]]'''(string) - returns the variable value which name is given in parameter &lt;br /&gt;
*'''[[var.recallstr]]'''(string) - returns the variable value converted to string which name is given in parameter &lt;br /&gt;
*'''[[var.store]]'''(string, value) - store in the variable, which name is given in parameter, the value &lt;br /&gt;
*'''[[var.unmonitor]]'''() -&amp;amp;nbsp;?&lt;br /&gt;
&lt;br /&gt;
== Events  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[on.paint]]'''(gc) is called when the GUI is painted. 'gc' is the Graphics Context (see above) &lt;br /&gt;
*'''[[on.resize]]'''() is called when the window is rezised &lt;br /&gt;
*'''[[on.timer]]'''() is called when the timer has been finished. Here an example of using timer to play an animation&amp;amp;nbsp;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt; x = 1&lt;br /&gt;
 animating = false&lt;br /&gt;
 function on.paint(gc)&lt;br /&gt;
 	gc:setFont(&amp;quot;sansserif&amp;quot;, &amp;quot;r&amp;quot;, 10)&lt;br /&gt;
 	gc:drawString(tostring(x), 0, 0, &amp;quot;top&amp;quot;)&lt;br /&gt;
 	if animating then&lt;br /&gt;
 		x = x + 1&lt;br /&gt;
 		timer.start(0.5)&lt;br /&gt;
 	end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.charIn(ch)&lt;br /&gt;
 	animating = not animating -- switch state&lt;br /&gt;
 	platform.window:invalidate() -- recall graph engine&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.timer()&lt;br /&gt;
 	timer.stop()&lt;br /&gt;
 	platform.window:invalidate() -- recall graph engine&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.arrowKey]]'''(key) is called when an '''arrow key''' from the clickPad/TouchPad is pressed (right, left, up, down) &lt;br /&gt;
*'''[[on.arrowLeft]]'''() is called when the '''left''' arrow is pressed &lt;br /&gt;
*'''[[on.arrowRight]]'''() is called when the '''right''' arrow is pressed &lt;br /&gt;
*'''[[on.arrowUp]]'''() is called when the up '''arrow''' is pressed &lt;br /&gt;
*'''[[on.arrowDown]]'''() is called when the '''down''' arrow is pressed&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.up]]'''() -- probably for the touchpad up motion &lt;br /&gt;
*'''[[on.down]]'''() -- probably for the touchpad down motion&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.enterKey]]'''() is called when the '''enter''' key is pressed. &lt;br /&gt;
*'''[[on.escapeKey]]'''() is called when the '''escape''' key is pressed. &lt;br /&gt;
*'''[[on.tabKey]]'''() is called when the '''tab''' key is pressed. &lt;br /&gt;
*'''[[on.deleteKey]]'''() is called when the '''delete''' key is pressed. &lt;br /&gt;
*'''[[on.backspaceKey]]'''() is called when the '''clear''' key is pressed. &lt;br /&gt;
*'''[[on.returnKey]]'''() is called when the '''return''' key is pressed. &lt;br /&gt;
*'''[[on.contextMenu]]'''() is called when the combo-key '''Ctrl Menu''' is pressed. &lt;br /&gt;
*'''[[on.backtabKey]]'''() is called when the combo-key '''Maj Tab''' is pressed. &lt;br /&gt;
*'''[[on.clearKey]]'''() is called when the combo-key '''Ctrl Clear''' is pressed. &lt;br /&gt;
*'''[[on.help]]'''() is called when the combo-key '''Ctrl H''' is pressed.&lt;br /&gt;
&lt;br /&gt;
*'''[[on.charIn]]'''(string) is called when the Nspire detects a non arrow key being pressed. ch is the character it detect. If you want to auto start an event in the file linked to key r(like a reset) put on.charIn(“r”) where you want.&lt;br /&gt;
&lt;br /&gt;
*'''[[on.blink]]'''()&amp;amp;nbsp;? is called when the focus is lost on the page (like launching the document, changing page etc...)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.deactivate]]'''()&amp;amp;nbsp;? is called when the focus is lost on the page (like launching the document, changing page etc...) &lt;br /&gt;
*'''[[on.activate]]'''()&amp;amp;nbsp;? is called when the focus is on the page (like launching the document, changing page etc...)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.mouseDown]]'''(x, y) is called when we press the left mouse button. X and Y are the pressed point coordinates. &lt;br /&gt;
*'''[[on.mouseUp]]'''() is called when we release the left mouse button. &lt;br /&gt;
*'''[[on.mouseMove]]'''() is called when the mouse moves &lt;br /&gt;
*'''[[on.grabDown]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.grabMove]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.grabUp]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.rightMouseDown]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.rightMouseUp]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.cutEnabled]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.copyEnabled]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.pasteEnabled]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.cut]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.copy]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.paste]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== D2Editor  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[D2Editor.newRichText]]'''() creates a new RichText object (default values&amp;amp;nbsp;: x, y, width, height = 0) &lt;br /&gt;
*'''[[D2Editor.resize]]'''(width, height) &lt;br /&gt;
*'''[[D2Editor.move]]'''(x, y) &lt;br /&gt;
*'''[[D2Editor.setText]]'''(string) &lt;br /&gt;
*'''[[D2Editor.getText]]'''() returns the RichText value &lt;br /&gt;
*'''[[D2Editor.setReadOnly]]'''(bool) bool&amp;amp;nbsp;: true/false&amp;amp;nbsp;: If true, the content becomes read-only, i.e. non-editable. &lt;br /&gt;
*'''[[D2Editor.setFormattedText]]'''() - ?&lt;br /&gt;
&lt;br /&gt;
Example of a valid function using the D2Editor &lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
 function createRichTextBox&lt;br /&gt;
 	box = D2Editor.newRichText()&lt;br /&gt;
 	box:move(50, 50)&lt;br /&gt;
 	box:resize(50, 50)&lt;br /&gt;
 	box:setText(&amp;quot;Hello World !&amp;quot;)&lt;br /&gt;
 end&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External Links  ==&lt;br /&gt;
&lt;br /&gt;
An interesting page about LUA code optimization, that can be really useful, especially for calculators&amp;amp;nbsp;: [http://trac.caspring.org/wiki/LuaPerformance Lua Performance] &lt;br /&gt;
&lt;br /&gt;
== Online Demo  ==&lt;br /&gt;
&lt;br /&gt;
[[Document Player]]&lt;/div&gt;</summary>
		<author><name>Jonius7</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.inspired-lua.org/index.php?title=Overview_of_the_API&amp;diff=1010</id>
		<title>Overview of the API</title>
		<link rel="alternate" type="text/html" href="https://wiki.inspired-lua.org/index.php?title=Overview_of_the_API&amp;diff=1010"/>
		<updated>2013-06-29T09:42:57Z</updated>

		<summary type="html">&lt;p&gt;Jonius7: /* Standard Library */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note: Neither the ''io'' nor ''os'' libraries are present for the TI-Nspire, which seems to be running a light version of Lua 5.1.4. &lt;br /&gt;
&lt;br /&gt;
== Standard Library  ==&lt;br /&gt;
&lt;br /&gt;
( This has been taken from [http://www.wowwiki.com/Lua_functions a WoWWiki page] - See the full, official documentation [http://www.lua.org/manual/5.1/manual.html here] )&lt;br /&gt;
&lt;br /&gt;
=== Basic Library Functions ===&lt;br /&gt;
&lt;br /&gt;
*'''[[G]]''' - Global Variable - A global variable (not a function) that holds the global environment (that is, _G._G = _G). Lua itself does not use this variable; changing its value does not affect any environment, nor vice-versa. (Use setfenv to change environments.) - taken from Lua docs &lt;br /&gt;
*'''[[assert]]'''(value[, errormsg]) - asserts a value evaluates to true. If it is, returns value, otherwise causes a Lua error to be thrown. &lt;br /&gt;
*'''[[collectgarbage]]'''&lt;br /&gt;
*'''[[error]]'''&lt;br /&gt;
*'''[[getfenv]]'''(function or integer) - Returns the table representing the stack frame of the given function or stack level. &lt;br /&gt;
*'''[[getmetatable]]'''(obj, mtable) - Returns the metatable of the given table or userdata object. &lt;br /&gt;
*'''[[next]]'''(table, index) - Returns the next key, value pair of the table, allowing you to walk over the table. &lt;br /&gt;
*'''[[newproxy]]'''(boolean or proxy) - Creates a userdata with a sharable metatable. &lt;br /&gt;
*'''[[print]]''' - print (···) - Receives any number of arguments, and prints their values to stdout, using the tostring function to convert them to strings. print is not intended for formatted output, but only as a quick way to show a value, typically for debugging. For formatted output, use string.format. - taken from Lua Docs &lt;br /&gt;
*'''[[select]]'''(index, list) - Returns the number of items in list or the value of the item in list at index. &lt;br /&gt;
*'''[[setfenv]]'''(function or integer, table) - Sets the table representing the stack frame of the given function or stack level. &lt;br /&gt;
*'''[[setmetatable]]'''(obj, mtable) - Sets the metatable of the given table or userdata object. &lt;br /&gt;
*'''[[tostring]]''' - tostring (e) - Receives an argument of any type and converts it to a string in a reasonable format. For complete control of how numbers are converted, use string.format. If the metatable of e has a &amp;quot;__tostring&amp;quot; field, then tostring calls the corresponding value with e as argument, and uses the result of the call as its result. - taken from Lua Docs. &lt;br /&gt;
*'''[[tonumber]]''' - tonumber (e) - Receives an argument of the string type and converts it to a number when possible. If the metatable of e has a &amp;quot;__tonumber&amp;quot; field, then tonumber calls the corresponding value with e as argument, and uses the result of the call as its result. - taken from Lua Docs. &lt;br /&gt;
&lt;br /&gt;
*'''[[type]]'''(var) - Returns the type of variable as a string, &amp;quot;number&amp;quot;, &amp;quot;string&amp;quot;, &amp;quot;table&amp;quot;, &amp;quot;function&amp;quot; or &amp;quot;userdata&amp;quot;. &lt;br /&gt;
*'''[[unpack]]'''(table[, start][, end]) - Returns the contents of its argument as separate values. &lt;br /&gt;
*'''[[xpcall]]'''(func, err) - Returns a boolean indicating successful execution of func and calls err on failure, additionally returning func's or err's results.&lt;br /&gt;
&lt;br /&gt;
=== String Library ===&lt;br /&gt;
byte char dump �nd format gmatch gsub len lower match rep reverse sub upper&lt;br /&gt;
&lt;br /&gt;
=== Math Library ===&lt;br /&gt;
abs acos asin atan atan2 ceil cos cosh deg exp  oor fmod frexp huge ldexp log log10 max min modf pi pow rad random randomseed sin sinh sqrt tan tanh&lt;br /&gt;
&lt;br /&gt;
== Concepts and Basics  ==&lt;br /&gt;
&lt;br /&gt;
This part will explain you how the Lua actually works inside the OS and help you to figure out what you're doing when you write a script for the TI-Nspire. Before reading this, you have to know all about the Lua basics. &lt;br /&gt;
&lt;br /&gt;
The Lua is an interpreted script language which means that it isn't as fast as ASM/C programs, but is still better than the TI-BASIC. One good thing is that this language is in a complete harmony with the OS with basic events and a powerfull graphic context. First, we have to understand how this works. Basicly the script is launched before the executive engine. This means that we can neither evaluate expressions nor use some of the standard API (like platform, var) until the engine is launched. Here is a call summary&amp;amp;nbsp;: &lt;br /&gt;
&lt;br /&gt;
*Launch string library &lt;br /&gt;
*Launch math library &lt;br /&gt;
*... &lt;br /&gt;
*Open and launch User's Lua script &lt;br /&gt;
*... &lt;br /&gt;
*Launch var API (store, recall, ...) &lt;br /&gt;
*Launch platform API (window, gc, ...) &lt;br /&gt;
*... &lt;br /&gt;
*Link events (pseudo code)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;while(Exit)&lt;br /&gt;
 	------- Some OS routines here&lt;br /&gt;
 &lt;br /&gt;
  	---- Begin of Event link&lt;br /&gt;
 	buffer:captureDataFromKeyPad() 	 	 	--  (N) some underground routines to catch events&lt;br /&gt;
 	if buffer.charInput ~= &amp;quot;&amp;quot; then 	 	 	--  (N)&lt;br /&gt;
 		on.charIn(buffer.charInput)&lt;br /&gt;
 		buffer.charInput= &amp;quot;&amp;quot; 	 	 	--  (N)&lt;br /&gt;
 	end&lt;br /&gt;
 	if buffer.arrowKey ~= &amp;quot;&amp;quot; then 	 	 	--  (N)&lt;br /&gt;
 		on.arrowKey(buffer.arrowKey)&lt;br /&gt;
 		buffer.arrowKey = &amp;quot;&amp;quot; 	 	 	--  (N)&lt;br /&gt;
 	end&lt;br /&gt;
 	----- etc ... 	&lt;br /&gt;
 	if platform.window.isInvalidate then &lt;br /&gt;
 	 	platform.gc():purge()	 	 	--  (N) Empty buffer before starting to draw&lt;br /&gt;
 		on.paint(platform.gc()) 	  	-- save all the things we have to draw&lt;br /&gt;
 	 	platform:paint() 	 	  	--  (N) draw all those things&lt;br /&gt;
 		platform.window.isInvalidate = false 	-- say that the window has been drawn&lt;br /&gt;
 	end&lt;br /&gt;
 	----- End of Event link&lt;br /&gt;
end''&lt;br /&gt;
Note : the (N) commented line only indicates the meaning of the routine. Those functions don't really exist.&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can understand how everything is linked, just by a main loop. This helps you to understand that you don't have to code a loop yourself, because the screen wouldn't be refreshed. This also helps to see when the screen gets refreshed. In other words, we cannot use niether '''gc''' nor '''platform.gc()''' (which are the same) in order to draw somthing on the screen if we are outside of '''on.paint()''' (except if your outside function is called within on.paint() ). This also means that we don't need to pass '''gc''' as parameter, because we can rather use '''platform.gc()''' for any functions called within on.paint(). This is exactly what [https://github.com/adriweb/BetterLuaAPI-for-TI-Nspire/blob/master/BetterLuaAPI.lua the BetterLuaAPI library for Nspire] does. &lt;br /&gt;
&lt;br /&gt;
Here is an example of a simple Lua program that displays a message only when a key is pressed (and let the screen blank otherwise). &lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt; function on.paint(gc)&lt;br /&gt;
 	if message then&lt;br /&gt;
 	 	gc:setFont(&amp;quot;sansserif&amp;quot;, &amp;quot;r&amp;quot;, 10)	-- initialize font drawing&lt;br /&gt;
 	 	gc:drawString(message, 0, 0, &amp;quot;top&amp;quot;)	-- display the message at (0, 0) coordinates&lt;br /&gt;
 	 	message = nil 				-- erase the message&lt;br /&gt;
 	 	timer.start(1) 	 	 	-- start a timer to exit on.paint() but keep in mind that we have to redraw the screen&lt;br /&gt;
 	end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.timer()&lt;br /&gt;
 	timer.stop()&lt;br /&gt;
 	platform.window:invalidate()&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.charIn(ch)&lt;br /&gt;
 	message = &amp;quot;Hello World !&amp;quot;		-- store a message&lt;br /&gt;
 	platform.window:invalidate()		-- force display&lt;br /&gt;
 end&amp;lt;/source&amp;gt;&lt;br /&gt;
When you open the document, the script is read once. It initializes and overwrites all the functions and globals with the ones you defined. Thus, '''message''' is nil. Once the '''on.paint()''' event is called, '''message''' is nil, thus, nothing is done. When you press a key that calls '''on.charIn()''' (see below for more information), '''message''' is now &amp;quot;Hello World&amp;quot; and we tell the '''platform''' that the screen has to be refreshed. Then, '''on.paint()''' is called again, '''message''' is not nil then we display it, erase '''message''' and launch a timer. Why is that&amp;amp;nbsp;? Because if we call '''platform.window:invalidate()''' right there, we won't refresh the screen. Why again&amp;amp;nbsp;? Just look at the pseudo-code above. We set the window as drawn after each call of on.paint(). Thus a timer is necessary to manually recall '''on.paint()''' and exit the '''on.paint()''' function to draw the screen. When the timer is ended, '''on.timer()''' is called and we refresh the screen. The screen is then redrawn but there is nothing to draw because '''message''' is nil. Thus, the graphic context lets the screen blank. &lt;br /&gt;
&lt;br /&gt;
== gc (as in Graphics Context)  ==&lt;br /&gt;
&lt;br /&gt;
Note: You need to add “gc:” before each of these commands in order to use them. ex. '''gc:setAlpha(...)'''. You can also call gc like this&amp;amp;nbsp;: '''platform.gc():setAlpha(...)'''. Then you can use the gc library in a function where gc is not passed as an argument. but this function *has* to be called within '''on.paint(gc)''' &lt;br /&gt;
&lt;br /&gt;
The maximum screen resolution available to Lua programs is 318 by 212 pixels. &lt;br /&gt;
&lt;br /&gt;
*'''[[gc:begin]]''' - &lt;br /&gt;
*'''[[gc:clipRect]]''' - &lt;br /&gt;
*'''[[gc:drawArc]]'''(x, y, width, height, start angle, finish angle) Note, to draw a circle, use drawArc(x - diameter/2, y - diameter/2, diameter,diameter,0,360) where x and y are the coordinates of the middle. &lt;br /&gt;
*'''[[gc:drawImage]]'''(image,x,y) First argument in format “[[TI.Image]]”, x and y the coords. &lt;br /&gt;
*'''[[gc:drawLine]]'''(xstart, ystart, xend, yend) Draws a line starting at the point (xstart,ystart) and ending at the point (xend, yend) &lt;br /&gt;
*'''[[gc:drawPolyLine]]'''(int list1 [,int list2, .., int listN]) Draws a shape from a list contaning successively the x and y coordinates of each point the line have to draw.&lt;br /&gt;
&lt;br /&gt;
*'''[[gc:drawRect]]'''(x, y, xwidth, yheight) Draws a rectangle at (x,y) with the “x” side being “xwidth” long and the “y” side being “yheight” long &lt;br /&gt;
*'''[[gc:drawString]]'''(string, x, y, PositionString) PositionString is the string’s anchor point and can be “bottom”, “middle”, or “top”. &lt;br /&gt;
*'''[[gc:fillArc]]'''(x, y, width, height, start angle, finish angle) see drawArc &lt;br /&gt;
*'''[[gc:fillPolygon]]'''(int list1 [,int list2, .., int listN]) see drawPolyLine &lt;br /&gt;
*'''[[gc:fillRect]]'''(x, y, width, height) see drawRect &lt;br /&gt;
*'''[[gc:finish]]''' - &lt;br /&gt;
*'''[[gc:getStringHeight]]'''(string) &lt;br /&gt;
*'''[[gc:getStringWidth]]'''(string) &lt;br /&gt;
*'''[[gc:isColorDisplay]]''' Bool (Read-only) Returns 1 if color, 0 if not. &lt;br /&gt;
*'''[[gc:setAlpha]]'''(int) - where the argument is an int between 0 and 255. Sets the transparency. &lt;br /&gt;
*'''[[gc:setColorRGB]]'''(red, green, blue) RGB values are integers, from 0 to 255. &lt;br /&gt;
*'''[[gc:setFont]]'''(font, type, size), with font&amp;amp;nbsp;: {“sansserif”, &amp;quot;serif&amp;quot;, ..}, type {“b”, “r”, “i”}, size(int) &lt;br /&gt;
*'''[[gc:setPen]]'''(size, smooth) size {“thin”, “medium”, &amp;quot;thick&amp;quot;}, smooth {“smooth”, &amp;quot;dotted&amp;quot;, &amp;quot;dashed&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
== platform  ==&lt;br /&gt;
&lt;br /&gt;
These are mainly read-only. These work by writing &amp;quot;'''platform.'''&amp;quot; in front of them. Example&amp;amp;nbsp;: &amp;quot;'''platform.window:invalidate()'''&amp;quot; &lt;br /&gt;
&lt;br /&gt;
*'''[[platform.apilevel]]'''&amp;amp;nbsp;: Returns the version of the API. Currently (OS 3.0.1) returns 1.0.0. &lt;br /&gt;
*'''[[platform.window]]'''&lt;br /&gt;
&lt;br /&gt;
:*'''[[platform.window:width]]''' - Returns the width of the window. Ex&amp;amp;nbsp;: ''platform.window:height()'' &lt;br /&gt;
:*'''[[platform.window:height]]''' - Returns the height of the window &lt;br /&gt;
:*'''[[platform.window:invalidate]]''' - Repaints the window (it calls '''on.paint(gc)''')&lt;br /&gt;
&lt;br /&gt;
*'''[[platform.isDeviceModeRendering]]''' Returns true or false whether the unit is &amp;quot;rendering&amp;quot; or not &lt;br /&gt;
*'''[[platform.gc]]''' - Other way to call '''gc'''. Use it like that&amp;amp;nbsp;: '''platform.gc():setAlpha(...)''' for example. This is useful when you're in a function outside '''on.paint(gc)''' (but this function has to be called within [[on.paint]](gc).) &lt;br /&gt;
*'''[[platform.isColorDisplay]]''' Returns ''true'' if the unit the code is being run on has a color display (-&amp;amp;gt; Nspire CX), and ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
== cursor  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[cursor.hide]]'''() - hides the cursor (mouse pointer) &lt;br /&gt;
*'''[[cursor.set]]'''(string) - string can be one of those&amp;amp;nbsp;: (interrogation, crosshair, text, pointer, link select, diag resize, wait busy, hollow pointer, rotation, pencil, zoom box, arrow, zoom out, dotted arrow, clear, animate, excel plus, mod label, writing, unavailable, resize row, resize column, drag grab, hand open, hand closed, hand pointer, zoom in, dilation, translation). &lt;br /&gt;
*'''[[cursor.show]]'''() - Shows the cursor on screen&lt;br /&gt;
&lt;br /&gt;
== document  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[document.markChanged]]'''() - Flag the document as &amp;quot;changed&amp;quot; so the user has to save it after using it.&lt;br /&gt;
&lt;br /&gt;
== clipboard  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[clipboard.addText]]'''() &lt;br /&gt;
*'''[[clipboard.getText]]'''()&lt;br /&gt;
&lt;br /&gt;
== locale  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[locale.name]]'''() - Returns the current language the calculator is set in, formatted as ISO-639 (i.e&amp;amp;nbsp;: &amp;quot;fr&amp;quot;, &amp;quot;en&amp;quot;, &amp;quot;it&amp;quot; ...).&lt;br /&gt;
&lt;br /&gt;
== image  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[image.copy]]'''(image, width, height) - returns a new Image which has a new scale. Width is the final width, Heigth, the final height of the image. &lt;br /&gt;
*'''[[image.height]]'''(image) - returns the height of the image given in parameter &lt;br /&gt;
*'''[[image.new]]'''(string) - Creates a new image from the string given in parameter (see TI.Image).&lt;br /&gt;
*'''[[image.width]]'''(image) - returns the width of the image given in parameter&lt;br /&gt;
&lt;br /&gt;
== timer  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[timer.getMilliSecCounter]]'''() - Returns the amount of milliseconds elapsed since last calculator reboot. (in TI's Computer software, returns an absolute negative time) &lt;br /&gt;
*'''[[timer.start]]'''(int) - Starts a timer with 1 second. &lt;br /&gt;
*'''[[timer.stop]]'''() - Stops a timer&lt;br /&gt;
&lt;br /&gt;
== toolpalette  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[toolpalette.enable]]'''(string) &lt;br /&gt;
*'''[[toolpalette.enableCopy]]'''() &lt;br /&gt;
*'''[[toolpalette.enableCut]]'''() &lt;br /&gt;
*'''[[toolpalette.enablePaste]]'''() &lt;br /&gt;
*'''[[toolpalette.register]]'''(table)&lt;br /&gt;
&lt;br /&gt;
== var  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[var.list]]'''() - returns a list of all the variables in the entire Activity &lt;br /&gt;
*'''[[var.monitor]]'''() -&amp;amp;nbsp;? &lt;br /&gt;
*'''[[var.recall]]'''(string) - returns the variable value which name is given in parameter &lt;br /&gt;
*'''[[var.recallstr]]'''(string) - returns the variable value converted to string which name is given in parameter &lt;br /&gt;
*'''[[var.store]]'''(string, value) - store in the variable, which name is given in parameter, the value &lt;br /&gt;
*'''[[var.unmonitor]]'''() -&amp;amp;nbsp;?&lt;br /&gt;
&lt;br /&gt;
== Events  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[on.paint]]'''(gc) is called when the GUI is painted. 'gc' is the Graphics Context (see above) &lt;br /&gt;
*'''[[on.resize]]'''() is called when the window is rezised &lt;br /&gt;
*'''[[on.timer]]'''() is called when the timer has been finished. Here an example of using timer to play an animation&amp;amp;nbsp;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt; x = 1&lt;br /&gt;
 animating = false&lt;br /&gt;
 function on.paint(gc)&lt;br /&gt;
 	gc:setFont(&amp;quot;sansserif&amp;quot;, &amp;quot;r&amp;quot;, 10)&lt;br /&gt;
 	gc:drawString(tostring(x), 0, 0, &amp;quot;top&amp;quot;)&lt;br /&gt;
 	if animating then&lt;br /&gt;
 		x = x + 1&lt;br /&gt;
 		timer.start(0.5)&lt;br /&gt;
 	end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.charIn(ch)&lt;br /&gt;
 	animating = not animating -- switch state&lt;br /&gt;
 	platform.window:invalidate() -- recall graph engine&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.timer()&lt;br /&gt;
 	timer.stop()&lt;br /&gt;
 	platform.window:invalidate() -- recall graph engine&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.arrowKey]]'''(key) is called when an '''arrow key''' from the clickPad/TouchPad is pressed (right, left, up, down) &lt;br /&gt;
*'''[[on.arrowLeft]]'''() is called when the '''left''' arrow is pressed &lt;br /&gt;
*'''[[on.arrowRight]]'''() is called when the '''right''' arrow is pressed &lt;br /&gt;
*'''[[on.arrowUp]]'''() is called when the up '''arrow''' is pressed &lt;br /&gt;
*'''[[on.arrowDown]]'''() is called when the '''down''' arrow is pressed&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.up]]'''() -- probably for the touchpad up motion &lt;br /&gt;
*'''[[on.down]]'''() -- probably for the touchpad down motion&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.enterKey]]'''() is called when the '''enter''' key is pressed. &lt;br /&gt;
*'''[[on.escapeKey]]'''() is called when the '''escape''' key is pressed. &lt;br /&gt;
*'''[[on.tabKey]]'''() is called when the '''tab''' key is pressed. &lt;br /&gt;
*'''[[on.deleteKey]]'''() is called when the '''delete''' key is pressed. &lt;br /&gt;
*'''[[on.backspaceKey]]'''() is called when the '''clear''' key is pressed. &lt;br /&gt;
*'''[[on.returnKey]]'''() is called when the '''return''' key is pressed. &lt;br /&gt;
*'''[[on.contextMenu]]'''() is called when the combo-key '''Ctrl Menu''' is pressed. &lt;br /&gt;
*'''[[on.backtabKey]]'''() is called when the combo-key '''Maj Tab''' is pressed. &lt;br /&gt;
*'''[[on.clearKey]]'''() is called when the combo-key '''Ctrl Clear''' is pressed. &lt;br /&gt;
*'''[[on.help]]'''() is called when the combo-key '''Ctrl H''' is pressed.&lt;br /&gt;
&lt;br /&gt;
*'''[[on.charIn]]'''(string) is called when the Nspire detects a non arrow key being pressed. ch is the character it detect. If you want to auto start an event in the file linked to key r(like a reset) put on.charIn(“r”) where you want.&lt;br /&gt;
&lt;br /&gt;
*'''[[on.blink]]'''()&amp;amp;nbsp;? is called when the focus is lost on the page (like launching the document, changing page etc...)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.deactivate]]'''()&amp;amp;nbsp;? is called when the focus is lost on the page (like launching the document, changing page etc...) &lt;br /&gt;
*'''[[on.activate]]'''()&amp;amp;nbsp;? is called when the focus is on the page (like launching the document, changing page etc...)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.mouseDown]]'''(x, y) is called when we press the left mouse button. X and Y are the pressed point coordinates. &lt;br /&gt;
*'''[[on.mouseUp]]'''() is called when we release the left mouse button. &lt;br /&gt;
*'''[[on.mouseMove]]'''() is called when the mouse moves &lt;br /&gt;
*'''[[on.grabDown]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.grabMove]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.grabUp]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.rightMouseDown]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.rightMouseUp]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.cutEnabled]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.copyEnabled]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.pasteEnabled]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.cut]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.copy]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.paste]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== D2Editor  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[D2Editor.newRichText]]'''() creates a new RichText object (default values&amp;amp;nbsp;: x, y, width, height = 0) &lt;br /&gt;
*'''[[D2Editor.resize]]'''(width, height) &lt;br /&gt;
*'''[[D2Editor.move]]'''(x, y) &lt;br /&gt;
*'''[[D2Editor.setText]]'''(string) &lt;br /&gt;
*'''[[D2Editor.getText]]'''() returns the RichText value &lt;br /&gt;
*'''[[D2Editor.setReadOnly]]'''(bool) bool&amp;amp;nbsp;: true/false&amp;amp;nbsp;: If true, the content becomes read-only, i.e. non-editable. &lt;br /&gt;
*'''[[D2Editor.setFormattedText]]'''() - ?&lt;br /&gt;
&lt;br /&gt;
Example of a valid function using the D2Editor &lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
 function createRichTextBox&lt;br /&gt;
 	box = D2Editor.newRichText()&lt;br /&gt;
 	box:move(50, 50)&lt;br /&gt;
 	box:resize(50, 50)&lt;br /&gt;
 	box:setText(&amp;quot;Hello World !&amp;quot;)&lt;br /&gt;
 end&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External Links  ==&lt;br /&gt;
&lt;br /&gt;
An interesting page about LUA code optimization, that can be really useful, especially for calculators&amp;amp;nbsp;: [http://trac.caspring.org/wiki/LuaPerformance Lua Performance] &lt;br /&gt;
&lt;br /&gt;
== Online Demo  ==&lt;br /&gt;
&lt;br /&gt;
[[Document Player]]&lt;/div&gt;</summary>
		<author><name>Jonius7</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.inspired-lua.org/index.php?title=Overview_of_the_API&amp;diff=1009</id>
		<title>Overview of the API</title>
		<link rel="alternate" type="text/html" href="https://wiki.inspired-lua.org/index.php?title=Overview_of_the_API&amp;diff=1009"/>
		<updated>2013-06-29T09:40:42Z</updated>

		<summary type="html">&lt;p&gt;Jonius7: /* Standard Library */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note: Neither the ''io'' nor ''os'' libraries are present for the TI-Nspire, which seems to be running a light version of Lua 5.1.4. &lt;br /&gt;
&lt;br /&gt;
== Standard Library  ==&lt;br /&gt;
&lt;br /&gt;
( This has been taken from [http://www.wowwiki.com/Lua_functions a WoWWiki page] - See the full, official documentation [http://www.lua.org/manual/5.1/manual.html here] )&lt;br /&gt;
&lt;br /&gt;
Basic Library Functions&lt;br /&gt;
&lt;br /&gt;
*'''[[G]]''' - Global Variable - A global variable (not a function) that holds the global environment (that is, _G._G = _G). Lua itself does not use this variable; changing its value does not affect any environment, nor vice-versa. (Use setfenv to change environments.) - taken from Lua docs &lt;br /&gt;
*'''[[assert]]'''(value[, errormsg]) - asserts a value evaluates to true. If it is, returns value, otherwise causes a Lua error to be thrown. &lt;br /&gt;
*'''[[collectgarbage]]'''&lt;br /&gt;
*'''[[error]]'''&lt;br /&gt;
*'''[[getfenv]]'''(function or integer) - Returns the table representing the stack frame of the given function or stack level. &lt;br /&gt;
*'''[[getmetatable]]'''(obj, mtable) - Returns the metatable of the given table or userdata object. &lt;br /&gt;
*'''[[next]]'''(table, index) - Returns the next key, value pair of the table, allowing you to walk over the table. &lt;br /&gt;
*'''[[newproxy]]'''(boolean or proxy) - Creates a userdata with a sharable metatable. &lt;br /&gt;
*'''[[print]]''' - print (···) - Receives any number of arguments, and prints their values to stdout, using the tostring function to convert them to strings. print is not intended for formatted output, but only as a quick way to show a value, typically for debugging. For formatted output, use string.format. - taken from Lua Docs &lt;br /&gt;
*'''[[select]]'''(index, list) - Returns the number of items in list or the value of the item in list at index. &lt;br /&gt;
*'''[[setfenv]]'''(function or integer, table) - Sets the table representing the stack frame of the given function or stack level. &lt;br /&gt;
*'''[[setmetatable]]'''(obj, mtable) - Sets the metatable of the given table or userdata object. &lt;br /&gt;
*'''[[tostring]]''' - tostring (e) - Receives an argument of any type and converts it to a string in a reasonable format. For complete control of how numbers are converted, use string.format. If the metatable of e has a &amp;quot;__tostring&amp;quot; field, then tostring calls the corresponding value with e as argument, and uses the result of the call as its result. - taken from Lua Docs. &lt;br /&gt;
*'''[[tonumber]]''' - tonumber (e) - Receives an argument of the string type and converts it to a number when possible. If the metatable of e has a &amp;quot;__tonumber&amp;quot; field, then tonumber calls the corresponding value with e as argument, and uses the result of the call as its result. - taken from Lua Docs. &lt;br /&gt;
&lt;br /&gt;
*'''[[type]]'''(var) - Returns the type of variable as a string, &amp;quot;number&amp;quot;, &amp;quot;string&amp;quot;, &amp;quot;table&amp;quot;, &amp;quot;function&amp;quot; or &amp;quot;userdata&amp;quot;. &lt;br /&gt;
*'''[[unpack]]'''(table[, start][, end]) - Returns the contents of its argument as separate values. &lt;br /&gt;
*'''[[xpcall]]'''(func, err) - Returns a boolean indicating successful execution of func and calls err on failure, additionally returning func's or err's results.&lt;br /&gt;
&lt;br /&gt;
== Concepts and Basics  ==&lt;br /&gt;
&lt;br /&gt;
This part will explain you how the Lua actually works inside the OS and help you to figure out what you're doing when you write a script for the TI-Nspire. Before reading this, you have to know all about the Lua basics. &lt;br /&gt;
&lt;br /&gt;
The Lua is an interpreted script language which means that it isn't as fast as ASM/C programs, but is still better than the TI-BASIC. One good thing is that this language is in a complete harmony with the OS with basic events and a powerfull graphic context. First, we have to understand how this works. Basicly the script is launched before the executive engine. This means that we can neither evaluate expressions nor use some of the standard API (like platform, var) until the engine is launched. Here is a call summary&amp;amp;nbsp;: &lt;br /&gt;
&lt;br /&gt;
*Launch string library &lt;br /&gt;
*Launch math library &lt;br /&gt;
*... &lt;br /&gt;
*Open and launch User's Lua script &lt;br /&gt;
*... &lt;br /&gt;
*Launch var API (store, recall, ...) &lt;br /&gt;
*Launch platform API (window, gc, ...) &lt;br /&gt;
*... &lt;br /&gt;
*Link events (pseudo code)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;while(Exit)&lt;br /&gt;
 	------- Some OS routines here&lt;br /&gt;
 &lt;br /&gt;
  	---- Begin of Event link&lt;br /&gt;
 	buffer:captureDataFromKeyPad() 	 	 	--  (N) some underground routines to catch events&lt;br /&gt;
 	if buffer.charInput ~= &amp;quot;&amp;quot; then 	 	 	--  (N)&lt;br /&gt;
 		on.charIn(buffer.charInput)&lt;br /&gt;
 		buffer.charInput= &amp;quot;&amp;quot; 	 	 	--  (N)&lt;br /&gt;
 	end&lt;br /&gt;
 	if buffer.arrowKey ~= &amp;quot;&amp;quot; then 	 	 	--  (N)&lt;br /&gt;
 		on.arrowKey(buffer.arrowKey)&lt;br /&gt;
 		buffer.arrowKey = &amp;quot;&amp;quot; 	 	 	--  (N)&lt;br /&gt;
 	end&lt;br /&gt;
 	----- etc ... 	&lt;br /&gt;
 	if platform.window.isInvalidate then &lt;br /&gt;
 	 	platform.gc():purge()	 	 	--  (N) Empty buffer before starting to draw&lt;br /&gt;
 		on.paint(platform.gc()) 	  	-- save all the things we have to draw&lt;br /&gt;
 	 	platform:paint() 	 	  	--  (N) draw all those things&lt;br /&gt;
 		platform.window.isInvalidate = false 	-- say that the window has been drawn&lt;br /&gt;
 	end&lt;br /&gt;
 	----- End of Event link&lt;br /&gt;
end''&lt;br /&gt;
Note : the (N) commented line only indicates the meaning of the routine. Those functions don't really exist.&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can understand how everything is linked, just by a main loop. This helps you to understand that you don't have to code a loop yourself, because the screen wouldn't be refreshed. This also helps to see when the screen gets refreshed. In other words, we cannot use niether '''gc''' nor '''platform.gc()''' (which are the same) in order to draw somthing on the screen if we are outside of '''on.paint()''' (except if your outside function is called within on.paint() ). This also means that we don't need to pass '''gc''' as parameter, because we can rather use '''platform.gc()''' for any functions called within on.paint(). This is exactly what [https://github.com/adriweb/BetterLuaAPI-for-TI-Nspire/blob/master/BetterLuaAPI.lua the BetterLuaAPI library for Nspire] does. &lt;br /&gt;
&lt;br /&gt;
Here is an example of a simple Lua program that displays a message only when a key is pressed (and let the screen blank otherwise). &lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt; function on.paint(gc)&lt;br /&gt;
 	if message then&lt;br /&gt;
 	 	gc:setFont(&amp;quot;sansserif&amp;quot;, &amp;quot;r&amp;quot;, 10)	-- initialize font drawing&lt;br /&gt;
 	 	gc:drawString(message, 0, 0, &amp;quot;top&amp;quot;)	-- display the message at (0, 0) coordinates&lt;br /&gt;
 	 	message = nil 				-- erase the message&lt;br /&gt;
 	 	timer.start(1) 	 	 	-- start a timer to exit on.paint() but keep in mind that we have to redraw the screen&lt;br /&gt;
 	end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.timer()&lt;br /&gt;
 	timer.stop()&lt;br /&gt;
 	platform.window:invalidate()&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.charIn(ch)&lt;br /&gt;
 	message = &amp;quot;Hello World !&amp;quot;		-- store a message&lt;br /&gt;
 	platform.window:invalidate()		-- force display&lt;br /&gt;
 end&amp;lt;/source&amp;gt;&lt;br /&gt;
When you open the document, the script is read once. It initializes and overwrites all the functions and globals with the ones you defined. Thus, '''message''' is nil. Once the '''on.paint()''' event is called, '''message''' is nil, thus, nothing is done. When you press a key that calls '''on.charIn()''' (see below for more information), '''message''' is now &amp;quot;Hello World&amp;quot; and we tell the '''platform''' that the screen has to be refreshed. Then, '''on.paint()''' is called again, '''message''' is not nil then we display it, erase '''message''' and launch a timer. Why is that&amp;amp;nbsp;? Because if we call '''platform.window:invalidate()''' right there, we won't refresh the screen. Why again&amp;amp;nbsp;? Just look at the pseudo-code above. We set the window as drawn after each call of on.paint(). Thus a timer is necessary to manually recall '''on.paint()''' and exit the '''on.paint()''' function to draw the screen. When the timer is ended, '''on.timer()''' is called and we refresh the screen. The screen is then redrawn but there is nothing to draw because '''message''' is nil. Thus, the graphic context lets the screen blank. &lt;br /&gt;
&lt;br /&gt;
== gc (as in Graphics Context)  ==&lt;br /&gt;
&lt;br /&gt;
Note: You need to add “gc:” before each of these commands in order to use them. ex. '''gc:setAlpha(...)'''. You can also call gc like this&amp;amp;nbsp;: '''platform.gc():setAlpha(...)'''. Then you can use the gc library in a function where gc is not passed as an argument. but this function *has* to be called within '''on.paint(gc)''' &lt;br /&gt;
&lt;br /&gt;
The maximum screen resolution available to Lua programs is 318 by 212 pixels. &lt;br /&gt;
&lt;br /&gt;
*'''[[gc:begin]]''' - &lt;br /&gt;
*'''[[gc:clipRect]]''' - &lt;br /&gt;
*'''[[gc:drawArc]]'''(x, y, width, height, start angle, finish angle) Note, to draw a circle, use drawArc(x - diameter/2, y - diameter/2, diameter,diameter,0,360) where x and y are the coordinates of the middle. &lt;br /&gt;
*'''[[gc:drawImage]]'''(image,x,y) First argument in format “[[TI.Image]]”, x and y the coords. &lt;br /&gt;
*'''[[gc:drawLine]]'''(xstart, ystart, xend, yend) Draws a line starting at the point (xstart,ystart) and ending at the point (xend, yend) &lt;br /&gt;
*'''[[gc:drawPolyLine]]'''(int list1 [,int list2, .., int listN]) Draws a shape from a list contaning successively the x and y coordinates of each point the line have to draw.&lt;br /&gt;
&lt;br /&gt;
*'''[[gc:drawRect]]'''(x, y, xwidth, yheight) Draws a rectangle at (x,y) with the “x” side being “xwidth” long and the “y” side being “yheight” long &lt;br /&gt;
*'''[[gc:drawString]]'''(string, x, y, PositionString) PositionString is the string’s anchor point and can be “bottom”, “middle”, or “top”. &lt;br /&gt;
*'''[[gc:fillArc]]'''(x, y, width, height, start angle, finish angle) see drawArc &lt;br /&gt;
*'''[[gc:fillPolygon]]'''(int list1 [,int list2, .., int listN]) see drawPolyLine &lt;br /&gt;
*'''[[gc:fillRect]]'''(x, y, width, height) see drawRect &lt;br /&gt;
*'''[[gc:finish]]''' - &lt;br /&gt;
*'''[[gc:getStringHeight]]'''(string) &lt;br /&gt;
*'''[[gc:getStringWidth]]'''(string) &lt;br /&gt;
*'''[[gc:isColorDisplay]]''' Bool (Read-only) Returns 1 if color, 0 if not. &lt;br /&gt;
*'''[[gc:setAlpha]]'''(int) - where the argument is an int between 0 and 255. Sets the transparency. &lt;br /&gt;
*'''[[gc:setColorRGB]]'''(red, green, blue) RGB values are integers, from 0 to 255. &lt;br /&gt;
*'''[[gc:setFont]]'''(font, type, size), with font&amp;amp;nbsp;: {“sansserif”, &amp;quot;serif&amp;quot;, ..}, type {“b”, “r”, “i”}, size(int) &lt;br /&gt;
*'''[[gc:setPen]]'''(size, smooth) size {“thin”, “medium”, &amp;quot;thick&amp;quot;}, smooth {“smooth”, &amp;quot;dotted&amp;quot;, &amp;quot;dashed&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
== platform  ==&lt;br /&gt;
&lt;br /&gt;
These are mainly read-only. These work by writing &amp;quot;'''platform.'''&amp;quot; in front of them. Example&amp;amp;nbsp;: &amp;quot;'''platform.window:invalidate()'''&amp;quot; &lt;br /&gt;
&lt;br /&gt;
*'''[[platform.apilevel]]'''&amp;amp;nbsp;: Returns the version of the API. Currently (OS 3.0.1) returns 1.0.0. &lt;br /&gt;
*'''[[platform.window]]'''&lt;br /&gt;
&lt;br /&gt;
:*'''[[platform.window:width]]''' - Returns the width of the window. Ex&amp;amp;nbsp;: ''platform.window:height()'' &lt;br /&gt;
:*'''[[platform.window:height]]''' - Returns the height of the window &lt;br /&gt;
:*'''[[platform.window:invalidate]]''' - Repaints the window (it calls '''on.paint(gc)''')&lt;br /&gt;
&lt;br /&gt;
*'''[[platform.isDeviceModeRendering]]''' Returns true or false whether the unit is &amp;quot;rendering&amp;quot; or not &lt;br /&gt;
*'''[[platform.gc]]''' - Other way to call '''gc'''. Use it like that&amp;amp;nbsp;: '''platform.gc():setAlpha(...)''' for example. This is useful when you're in a function outside '''on.paint(gc)''' (but this function has to be called within [[on.paint]](gc).) &lt;br /&gt;
*'''[[platform.isColorDisplay]]''' Returns ''true'' if the unit the code is being run on has a color display (-&amp;amp;gt; Nspire CX), and ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
== cursor  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[cursor.hide]]'''() - hides the cursor (mouse pointer) &lt;br /&gt;
*'''[[cursor.set]]'''(string) - string can be one of those&amp;amp;nbsp;: (interrogation, crosshair, text, pointer, link select, diag resize, wait busy, hollow pointer, rotation, pencil, zoom box, arrow, zoom out, dotted arrow, clear, animate, excel plus, mod label, writing, unavailable, resize row, resize column, drag grab, hand open, hand closed, hand pointer, zoom in, dilation, translation). &lt;br /&gt;
*'''[[cursor.show]]'''() - Shows the cursor on screen&lt;br /&gt;
&lt;br /&gt;
== document  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[document.markChanged]]'''() - Flag the document as &amp;quot;changed&amp;quot; so the user has to save it after using it.&lt;br /&gt;
&lt;br /&gt;
== clipboard  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[clipboard.addText]]'''() &lt;br /&gt;
*'''[[clipboard.getText]]'''()&lt;br /&gt;
&lt;br /&gt;
== locale  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[locale.name]]'''() - Returns the current language the calculator is set in, formatted as ISO-639 (i.e&amp;amp;nbsp;: &amp;quot;fr&amp;quot;, &amp;quot;en&amp;quot;, &amp;quot;it&amp;quot; ...).&lt;br /&gt;
&lt;br /&gt;
== image  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[image.copy]]'''(image, width, height) - returns a new Image which has a new scale. Width is the final width, Heigth, the final height of the image. &lt;br /&gt;
*'''[[image.height]]'''(image) - returns the height of the image given in parameter &lt;br /&gt;
*'''[[image.new]]'''(string) - Creates a new image from the string given in parameter (see TI.Image).&lt;br /&gt;
*'''[[image.width]]'''(image) - returns the width of the image given in parameter&lt;br /&gt;
&lt;br /&gt;
== timer  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[timer.getMilliSecCounter]]'''() - Returns the amount of milliseconds elapsed since last calculator reboot. (in TI's Computer software, returns an absolute negative time) &lt;br /&gt;
*'''[[timer.start]]'''(int) - Starts a timer with 1 second. &lt;br /&gt;
*'''[[timer.stop]]'''() - Stops a timer&lt;br /&gt;
&lt;br /&gt;
== toolpalette  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[toolpalette.enable]]'''(string) &lt;br /&gt;
*'''[[toolpalette.enableCopy]]'''() &lt;br /&gt;
*'''[[toolpalette.enableCut]]'''() &lt;br /&gt;
*'''[[toolpalette.enablePaste]]'''() &lt;br /&gt;
*'''[[toolpalette.register]]'''(table)&lt;br /&gt;
&lt;br /&gt;
== var  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[var.list]]'''() - returns a list of all the variables in the entire Activity &lt;br /&gt;
*'''[[var.monitor]]'''() -&amp;amp;nbsp;? &lt;br /&gt;
*'''[[var.recall]]'''(string) - returns the variable value which name is given in parameter &lt;br /&gt;
*'''[[var.recallstr]]'''(string) - returns the variable value converted to string which name is given in parameter &lt;br /&gt;
*'''[[var.store]]'''(string, value) - store in the variable, which name is given in parameter, the value &lt;br /&gt;
*'''[[var.unmonitor]]'''() -&amp;amp;nbsp;?&lt;br /&gt;
&lt;br /&gt;
== Events  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[on.paint]]'''(gc) is called when the GUI is painted. 'gc' is the Graphics Context (see above) &lt;br /&gt;
*'''[[on.resize]]'''() is called when the window is rezised &lt;br /&gt;
*'''[[on.timer]]'''() is called when the timer has been finished. Here an example of using timer to play an animation&amp;amp;nbsp;:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt; x = 1&lt;br /&gt;
 animating = false&lt;br /&gt;
 function on.paint(gc)&lt;br /&gt;
 	gc:setFont(&amp;quot;sansserif&amp;quot;, &amp;quot;r&amp;quot;, 10)&lt;br /&gt;
 	gc:drawString(tostring(x), 0, 0, &amp;quot;top&amp;quot;)&lt;br /&gt;
 	if animating then&lt;br /&gt;
 		x = x + 1&lt;br /&gt;
 		timer.start(0.5)&lt;br /&gt;
 	end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.charIn(ch)&lt;br /&gt;
 	animating = not animating -- switch state&lt;br /&gt;
 	platform.window:invalidate() -- recall graph engine&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function on.timer()&lt;br /&gt;
 	timer.stop()&lt;br /&gt;
 	platform.window:invalidate() -- recall graph engine&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.arrowKey]]'''(key) is called when an '''arrow key''' from the clickPad/TouchPad is pressed (right, left, up, down) &lt;br /&gt;
*'''[[on.arrowLeft]]'''() is called when the '''left''' arrow is pressed &lt;br /&gt;
*'''[[on.arrowRight]]'''() is called when the '''right''' arrow is pressed &lt;br /&gt;
*'''[[on.arrowUp]]'''() is called when the up '''arrow''' is pressed &lt;br /&gt;
*'''[[on.arrowDown]]'''() is called when the '''down''' arrow is pressed&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.up]]'''() -- probably for the touchpad up motion &lt;br /&gt;
*'''[[on.down]]'''() -- probably for the touchpad down motion&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.enterKey]]'''() is called when the '''enter''' key is pressed. &lt;br /&gt;
*'''[[on.escapeKey]]'''() is called when the '''escape''' key is pressed. &lt;br /&gt;
*'''[[on.tabKey]]'''() is called when the '''tab''' key is pressed. &lt;br /&gt;
*'''[[on.deleteKey]]'''() is called when the '''delete''' key is pressed. &lt;br /&gt;
*'''[[on.backspaceKey]]'''() is called when the '''clear''' key is pressed. &lt;br /&gt;
*'''[[on.returnKey]]'''() is called when the '''return''' key is pressed. &lt;br /&gt;
*'''[[on.contextMenu]]'''() is called when the combo-key '''Ctrl Menu''' is pressed. &lt;br /&gt;
*'''[[on.backtabKey]]'''() is called when the combo-key '''Maj Tab''' is pressed. &lt;br /&gt;
*'''[[on.clearKey]]'''() is called when the combo-key '''Ctrl Clear''' is pressed. &lt;br /&gt;
*'''[[on.help]]'''() is called when the combo-key '''Ctrl H''' is pressed.&lt;br /&gt;
&lt;br /&gt;
*'''[[on.charIn]]'''(string) is called when the Nspire detects a non arrow key being pressed. ch is the character it detect. If you want to auto start an event in the file linked to key r(like a reset) put on.charIn(“r”) where you want.&lt;br /&gt;
&lt;br /&gt;
*'''[[on.blink]]'''()&amp;amp;nbsp;? is called when the focus is lost on the page (like launching the document, changing page etc...)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.deactivate]]'''()&amp;amp;nbsp;? is called when the focus is lost on the page (like launching the document, changing page etc...) &lt;br /&gt;
*'''[[on.activate]]'''()&amp;amp;nbsp;? is called when the focus is on the page (like launching the document, changing page etc...)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.mouseDown]]'''(x, y) is called when we press the left mouse button. X and Y are the pressed point coordinates. &lt;br /&gt;
*'''[[on.mouseUp]]'''() is called when we release the left mouse button. &lt;br /&gt;
*'''[[on.mouseMove]]'''() is called when the mouse moves &lt;br /&gt;
*'''[[on.grabDown]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.grabMove]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.grabUp]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.rightMouseDown]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.rightMouseUp]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
*'''[[on.cutEnabled]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.copyEnabled]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.pasteEnabled]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.cut]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.copy]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?) &lt;br /&gt;
*'''[[on.paste]]'''()&amp;amp;nbsp;? (software only&amp;amp;nbsp;?)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== D2Editor  ==&lt;br /&gt;
&lt;br /&gt;
*'''[[D2Editor.newRichText]]'''() creates a new RichText object (default values&amp;amp;nbsp;: x, y, width, height = 0) &lt;br /&gt;
*'''[[D2Editor.resize]]'''(width, height) &lt;br /&gt;
*'''[[D2Editor.move]]'''(x, y) &lt;br /&gt;
*'''[[D2Editor.setText]]'''(string) &lt;br /&gt;
*'''[[D2Editor.getText]]'''() returns the RichText value &lt;br /&gt;
*'''[[D2Editor.setReadOnly]]'''(bool) bool&amp;amp;nbsp;: true/false&amp;amp;nbsp;: If true, the content becomes read-only, i.e. non-editable. &lt;br /&gt;
*'''[[D2Editor.setFormattedText]]'''() - ?&lt;br /&gt;
&lt;br /&gt;
Example of a valid function using the D2Editor &lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
 function createRichTextBox&lt;br /&gt;
 	box = D2Editor.newRichText()&lt;br /&gt;
 	box:move(50, 50)&lt;br /&gt;
 	box:resize(50, 50)&lt;br /&gt;
 	box:setText(&amp;quot;Hello World !&amp;quot;)&lt;br /&gt;
 end&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External Links  ==&lt;br /&gt;
&lt;br /&gt;
An interesting page about LUA code optimization, that can be really useful, especially for calculators&amp;amp;nbsp;: [http://trac.caspring.org/wiki/LuaPerformance Lua Performance] &lt;br /&gt;
&lt;br /&gt;
== Online Demo  ==&lt;br /&gt;
&lt;br /&gt;
[[Document Player]]&lt;/div&gt;</summary>
		<author><name>Jonius7</name></author>
		
	</entry>
</feed>