https://wiki.inspired-lua.org/api.php?action=feedcontributions&user=Technolapin&feedformat=atomInspired-Lua Wiki - User contributions [en]2024-03-28T17:36:45ZUser contributionsMediaWiki 1.33.0https://wiki.inspired-lua.org/index.php?title=User:Technolapin&diff=1231User:Technolapin2014-12-05T17:32:51Z<p>Technolapin: Created page with "Hi, im a troll. I know very well lua (but not enought) and I catched a strange curse when writing some crap in jen's scriptor near an indian Cemetery: I can't finish any program!..."</p>
<hr />
<div>Hi, im a troll.<br />
I know very well lua (but not enought) and I catched a strange curse when writing some crap in jen's scriptor near an indian Cemetery: I can't finish any program!<br />
I like to do some useless programs as my -very- famous "pig exploder" and to troll on the TI-planet's chat.<br />
I try to put more informations to this wiki, because it is too empty according to my tastes.</div>Technolapinhttps://wiki.inspired-lua.org/index.php?title=assert&diff=1229assert2014-11-08T19:57:22Z<p>Technolapin: </p>
<hr />
<div>The assert() function is a way to execute functions.<br />
<source lang="lua"><br />
assert(foo, errmsg)<br />
</source><br />
It will try to execute the function foo and will send errmsg as an error if it fail.</div>Technolapinhttps://wiki.inspired-lua.org/index.php?title=assert&diff=1228assert2014-11-08T19:55:24Z<p>Technolapin: </p>
<hr />
<div>The assert() function is a way to execute functions.<br />
<br />
assert(foo, errmsg)<br />
<br />
It will try to execute the function foo and will send errmsg as an error if it fail.</div>Technolapinhttps://wiki.inspired-lua.org/index.php?title=assert&diff=1227assert2014-11-08T19:55:11Z<p>Technolapin: Created page with "The assert() function is a way to execute functions. assert(foo, errmsg) It will try to execute the function foo and will send errmsg as an error if it fail."</p>
<hr />
<div>The assert() function is a way to execute functions.<br />
assert(foo, errmsg)<br />
It will try to execute the function foo and will send errmsg as an error if it fail.</div>Technolapinhttps://wiki.inspired-lua.org/index.php?title=Overview_of_the_API&diff=1226Overview of the API2014-11-08T19:40:37Z<p>Technolapin: /* Standard Library */</p>
<hr />
<div>Note: The Lua version that comes with OS 3.x is 5.1.4, without the ''io'' nor ''os'' libraries.<br />
<br />
Tutorials on Nspire Lua scripting in general are available here : http://inspired-lua.org/<br />
<br />
== Standard Library ==<br />
<br />
( 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] )<br />
<br />
=== Common Lua Functions ===<br />
<br />
*'''[[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 <br />
*'''[[assert]]'''(value[, errormsg]) - asserts a value evaluates to true. If it is, returns value, otherwise causes a Lua error to be thrown. <br />
*'''[[collectgarbage]]''' - among other things, force free unused memory.<br />
*'''[[error]]'''(str) - generates an error with the str message.<br />
*'''[[getfenv]]'''(function or integer) - Returns the table representing the stack frame of the given function or stack level. <br />
*'''[[getmetatable]]'''(obj, mtable) - Returns the metatable of the given table or userdata object. <br />
*'''[[next]]'''(table, index) - Returns the next key, value pair of the table, allowing you to walk over the table. <br />
*'''[[newproxy]]'''(boolean or proxy) - Creates a userdata with a sharable metatable. <br />
*'''[[print]]'''(...) - Receives any number of arguments, and prints their values. Not intended for formatted output, but only as a quick way to show a value, typically for debugging. For formatted output, use string.format.<br />
*'''[[select]]'''(index, list) - Returns the number of items in list or the value of the item in list at index. <br />
*'''[[setfenv]]'''(function or integer, table) - Sets the table representing the stack frame of the given function or stack level. <br />
*'''[[setmetatable]]'''(obj, mtable) - Sets the metatable of the given table or userdata object. <br />
*'''[[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 "__tostring" 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. <br />
*'''[[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 "__tonumber" 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. <br />
*'''[[type]]'''(var) - Returns the type of variable as a string, "number", "string", "table", "function" or "userdata". <br />
*'''[[unpack]]'''(table[, start][, end]) - Returns the contents of its argument as separate values. <br />
*'''[[xpcall]]'''(func, err) - Returns a boolean indicating successful execution of func and calls err on failure, additionally returning func's or err's results.<br />
<br />
=== Coroutines Library ===<br />
The coroutines are usefull tools to control the running of differents parts of a code.<br />
<br />
create, wrap, resume, yield, status, running<br />
<br />
More information can be fouded in the [[coroutines]] page.<br />
<br />
=== String Library ===<br />
byte, char, dump, find, format, gmatch, gsub, len, lower, match, rep, reverse, sub, upper<br />
<br />
=== Math Library ===<br />
abs, acos, asin, atan, atan2, ceil, cos, cosh, deg, exp, floor, fmod, frexp, huge, ldexp, log, log10, max, min, modf, pi, pow, rad, random, randomseed, sin, sinh, sqrt, tan, tanh<br />
More information about the other libraries can be found on the [[Extended Standard Library]] Page<br />
<br />
== [[:Category:D2Editor|D2Editor]] ==<br />
The Lua 2D editor bindings enable 2D rich text editors to be created and manipulated within scripts.<br />
* [[D2Editor:createChemBox]]() : Inserts a Chem Box in the current cursor position of the editor.<br />
* [[D2Editor:createMathBox]]() : Inserts a Math Box (Expression Box) in the current cursor position of the editor.<br />
* [[D2Editor:getExpression]]() : Returns the contents of the text editor as a UTF-8 encoded string.<br />
* [[D2Editor:getExpressionSelection]]() : Returns three values: the contents of the text editor (UTF-8 encoded string), the cursor position, and the selection start.<br />
* [[D2Editor:getText]]() : same as ''getExpression'' : Returns the contents of the text editor as a UTF-8 encoded string.<br />
* [[D2Editor:hasFocus]]() : Returns true if the editor has focus; otherwise returns false.<br />
* [[D2Editor:isVisible]]() : Returns true if the editor is visible; otherwise returns false.<br />
* [[D2Editor:move]]() : Sets the parent-relative location of the upper left corner of the text editor. Both x and y must be between -32767 and 32767.<br />
* [[D2Editor:newRichText]]() : Creates and returns a new 2D rich text editor.<br />
* [[D2Editor:registerFilter]](handlerTable) : This routine registers a table of handler functions that can alter events before they are sent to the 2D editor widget, or unregisters if nil is passed.<br />
* [[D2Editor:resize]](w, h) : Changes the width and height of the text editor. Both width and height must be > 0 and < 32768.<br />
* [[D2Editor:setBorder]](thickness) : Sets the editor's border thickness. The thickness value must be between 0 and 10.<br />
* [[D2Editor:setBorderColor]](color) : Sets the editor's border color. The color value must be between 0 and 16777215 (0x000000 and 0xFFFFFF).<br />
* [[D2Editor:setColorable]](true or false) : Makes the expression colorable or uncolorable.<br />
* [[D2Editor:setDisable2DinRT]](true or false) : Turns on/off 2D layout of math input to the text box.<br />
* [[D2Editor:setExpression]](...) : Sets the text content of the text editor.<br />
* [[D2Editor:setFocus]](true or false) : Sets the user input focus on the editor if true (the default). This is usually called from the [[on.getFocus]] event handler.<br />
* [[D2Editor:setFontSize]](size) : Sets the text font size in the editor. Only 7, 9, 10, 11, 12, or 24 for the handheld, any on the desktop software.<br />
* [[D2Editor:setMainFont]](family, style) : Sets the main font family ("serif" or "sansserif") and style ("r", "b", "i", "bi").<br />
* [[D2Editor:setReadOnly]](true or false) : Makes the text editor content modifiable (false) or unmodifiable (true) by the user. If a Boolean value is not specified, defaults to true.<br />
* [[D2Editor:setSelectable]](true or false) : Makes the text editor content selectable (true) or unselectable (false) by the user. If a Boolean value is not specified, defaults to true.<br />
* [[D2Editor:setSizeChangeListener]](function(editor, w, h)) : Sets the callback function for when the editor contents exceed the current editor size, when the contents fit on fewer lines, or when the contents fit on a single line of smaller width.<br />
* [[D2Editor:setTextChangeListener]](function(editor)) : Sets the callback function for when the text expression changes, which will be to the editor object. This allows for processing text input as it occurs.<br />
* [[D2Editor:setText]](...) : Same as setExpression : Sets the text content of the text editor.<br />
* [[D2Editor:setTextColor]](color) : Sets the editor text color. The color value must be between 0 and 16777215 (0x000000 and 0xFFFFFF).<br />
* [[D2Editor:setVisible]](true or false) : Sets the visibility of the text editor.<br />
* [[D2Editor:setWordWrapWidth]](width) : Sets the rich text editor word-wrapping width in pixels. Ignored if the editor is in 2D mode. To indicate widget width, sets to 0. To disable wrapping, sets to < 0. The width must be -32767 to 32767.<br />
<br />
== [[:Category:Events|Events]] ==<br />
Events are one of the most fundamental things to know about the Nspire Lua language.<br />
You can see how events are managed inside the Lua implementation [[Life Cycle|here]]. <br />
<br />
*'''[[on.paint]]'''(gc) is called when the GUI is painted. [[:Category:gc|'gc' is the Graphics Context]] <br />
*'''[[on.resize]]''' is called when the window is rezised<br />
*'''[[on.timer]]''' is called at each timer ticks. See [[:Category:timer|timer]].<br> <br />
*'''[[on.arrowKey]]''' is called when an '''arrow key''' from the clickPad/TouchPad is pressed (right, left, up, down) <br />
*'''[[on.arrowLeft]]''' is called when the '''left''' arrow is pressed <br />
*'''[[on.arrowRight]]''' is called when the '''right''' arrow is pressed <br />
*'''[[on.arrowUp]]''' is called when the up '''arrow''' is pressed <br />
*'''[[on.arrowDown]]''' is called when the '''down''' arrow is pressed<br />
*'''[[on.enterKey]]''' is called when the '''enter''' key is pressed. <br />
*'''[[on.escapeKey]]''' is called when the '''escape''' key is pressed. <br />
*'''[[on.tabKey]]''' is called when the '''tab''' key is pressed. <br />
*'''[[on.deleteKey]]''' is called when the '''delete''' key is pressed. <br />
*'''[[on.backspaceKey]]''' is called when the '''clear''' key is pressed. <br />
*'''[[on.returnKey]]''' is called when the '''return''' key is pressed. <br />
*'''[[on.contextMenu]]''' is called when the combo-key '''Ctrl Menu''' is pressed. <br />
*'''[[on.backtabKey]]''' is called when the combo-key '''Maj Tab''' is pressed. <br />
*'''[[on.clearKey]]''' is called when the combo-key '''Ctrl Clear''' is pressed. <br />
*'''[[on.help]]''' is called when the combo-key '''Ctrl ?''' is pressed.<br />
*'''[[on.charIn]]''' is called when the Nspire detects a non arrow key being pressed.<br />
*'''[[on.createMathBox]]''' called when there is a MathBox created. <br />
*'''[[on.create]]''' called when the script gets created. '''Deprecated in 3.2'''. See ''on.contruction''.<br />
*'''[[on.construction]]''' called when the script gets created. <br />
*'''[[on.deactivate]]''' called when the focus is lost on the page (like launching the document, changing page etc...) <br />
*'''[[on.activate]]''' called when the focus is on the page (like launching the document, changing page etc...) <br />
*'''[[on.destroy]]''' is called when the document is about to get closed (or cut)<br />
*'''[[on.getFocus]]''' is called when the script receives user input focus. <br />
*'''[[on.loseFocus]]''' is called when the script loses user input focus. <br />
*'''[[on.mouseDown]]''' is called when we press the left mouse button. X and Y are the pressed point coordinates. <br />
*'''[[on.mouseUp]]''' is called when we release the left mouse button. <br />
*'''[[on.mouseMove]]''' is called when the mouse moves <br />
*'''[[on.grabDown]]''' is called when the grabbing motion is detected<br />
*'''[[on.grabUp]]''' is called after the grabbing action.<br />
*'''[[on.rightMouseDown]]''' is called when the user pushes the "right click" button<br />
*'''[[on.rightMouseUp]]''' is called when the user releases the "right click" button<br />
*'''[[on.keyboardUp]]'''() which fires when the tablet's on-screen keyboard gets shown.<br />
*'''[[on.keyboardDown]]'''() which fires when the tablet's on-screen keyboard gets hidden.<br />
*'''[[on.varChange]]''' is called when a [[var.monitor|monitored variable]] gets changed.<br />
*'''[[on.getSymbolList]]''' is called when the script app symbol list is being serialized to the clipboard.<br />
*'''[[on.save]]''' is called when the script app is saved to the document or copied to the clipboard.<br />
*'''[[on.restore]]''' is called when the script application is restored from its saved state in a document or when the app is pasted into a document..<br />
*'''[[on.cut]]''' is called when the user cuts something.<br />
*'''[[on.copy]]''' is called when the user copies something.<br />
*'''[[on.paste]]''' is called when the user pastes something.<br />
<br />
== [[:Category:gc|Graphics Operations]] ==<br />
'''gc''' is the Nspire's ''graphic context''. A graphics context is a module that has a handle to the script’s graphics output window and a library of graphics routines that are used to draw on the window. A graphics context is supplied to the script ”on.paint” event handler each time the window needs to be redrawn. The graphics context employs a pixel-based coordinate system with the origin in the upper left corner of the drawing window.<br />
<br />
*'''[[gc:clipRect]]'''(op, x, y, width, height) - Sets the clipping rectangle for subsequent graphics operations.<br />
*'''[[gc:drawArc]]'''(x, y, width, height, start angle, finish angle).<br />
*'''[[gc:drawImage]]'''(image,x,y) First argument in format “[[TI.Image]]”, x and y the coords.<br />
*'''[[gc:drawLine]]'''(xstart, ystart, xend, yend) Draws a line starting at the point (xstart,ystart) and ending at the point (xend, yend)<br />
*'''[[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.<br />
*'''[[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<br />
*'''[[gc:drawString]]'''(string, x, y, position) position is the string’s anchor point and can be "baseline", “bottom”, “middle”, or “top”. <br />
*'''[[gc:fillArc]]'''(x, y, width, height, start angle, finish angle) see [[gc:drawArc]]<br />
*'''[[gc:fillPolygon]]'''(int list1 [,int list2, .., int listN]) see [[gc:drawPolyLine]]<br />
*'''[[gc:fillRect]]'''(x, y, width, height) see [[gc:drawRect]]<br />
*'''[[gc:getStringHeight]]'''(string) - Returns the string's height.<br />
*'''[[gc:getStringWidth]]'''(string) - Returns the string's width<br />
*'''[[gc:setAlpha]]'''(alpha) - where alpha is an integer between 0 and 255. Sets the transparency. '''''Not available anymore in 3.2+'''''<br />
*'''[[gc:setColorRGB]]'''(red, green, blue) RGB values are integers, from 0 to 255.<br />
*'''[[gc:setFont]]'''(font, type, size), with font : {“sansserif”, "serif", ..}, type {“b”, “r”, “i”}, size(int)<br />
*'''[[gc:setPen]]'''(thickness, smoothness) : thickness {“thin”, “medium”, "thick"}, smoothness {“smooth”, "dotted", "dashed"}<br />
<br />
== [[:Category:image|Images]] ==<br />
*'''[[image.copy]]'''(theImage, width, height) : Returns a copy of the input image scaled to fit the specified pixel width and height. <br />
*'''[[image.height]]'''(theImage) : Returns the height of the ''image''<br />
*'''[[image.new]]'''(theImage) : Allocates a new [[TI.Image]]<br />
*'''[[image.rotate]]'''(theImage, angle) : Returns a rotated copy of ''theImage'' by ''angle'' degrees<br />
*'''[[image.width]]'''(theImage) : Returns the width of the ''image''<br />
<br />
== [[:Category:Physics_Engine|Physics Engine]] ==<br />
A port of Chipmunk Physics 5.3 has been embedded as an optional module (you have to 'require' it at the beginning of your script, in order to use it)<br />
*Arbiters and Collision Pairs<br />
*Bodies<br />
*Bounding Boxes<br />
*Circle Shapes<br />
*Constraints<br />
*Misc<br />
*Polygon Shapes<br />
*Segment Shapes<br />
*SegmentQueryInfo<br />
*Shape Queries<br />
*Shapes<br />
*Space Queries<br />
*Spaces<br />
*Vectors<br />
<br />
== [[:Category:platform|Platform]] ==<br />
*[[platform.isColorDisplay]]() : Returns true if the display of the host platform is color-capable (Nspire CX and emulator). Returns false if the display is grayscale (Nspire non-CX). <br />
*[[platform.isDeviceModeRendering]]() : Returns true if the script is running on the hand-held device or in the emulator (with the calculator view), and false if the script is running in the normal view of the emulator.<br />
*[[platform.isTabletModeRendering]]() : Returns true if the script is running on a tablet device (iPad app) and false otherwise.<br />
*[[:Category:platform.window|platform.window]] : Returns the window object currently owned by the script application. The window object contains several other methods.<br />
*[[platform.withGC]](...) : executes a function which a passed dummy [[gc]].<br />
*[[platform.registerErrorHandler]](...) : A global error handler for the lua script.<br />
*[[platform.hw]]() : returns a number corresponding to the type of device the script is running on.<br />
<br />
== [[:Category:timer|Timer]] ==<br />
*'''[[timer.start]]'''(period) : Starts the timer with the given ''period'' (in seconds)<br /><br />
*'''[[timer.getMilliSecCounter]]'''() : Returns the value of the milliseconds elapsed since the calculator's last boot.<br /><br />
*'''[[timer.stop]]'''() : Stops the timer.<br />
<br />
== [[:Category:toolpalette|Toolpalette]] ==<br />
The tool palette provides a menu of commands, selectable by the user, that invoke functionality of the script app. The menu itself is accessible by pressing the "Menu" button. <br />
*'''[[toolpalette.register|register]]'''(menuStructure) : Registers the ''menuStructure'' table. <br />
*'''[[toolpalette.enable|enable]]'''(toolname, itemname, state) : Enables or disables a menu item in the tool palette. <br />
*'''[[toolpalette.enableCopy|enableCopy]]'''(state) : This routine enables / disables the Edit > Copy menu command.<br />
*'''[[toolpalette.enableCut|enableCut]]'''(state) : This routine enables / disables the Edit > Cut menu command.<br />
*'''[[toolpalette.enablePaste|enablePaste]]'''(state) : This routine enables / disables the Edit > Paste menu command.<br />
<br />
== [[:Category:var|var]] ==<br />
'var' functions allows the script to interact with BASIC variables.<br />
*[[var.list]]() - Lists of names of variables currently used. <br />
*[[var.monitor]](name) - Turns on monitoring of the math variable with given ''name''. <br />
*[[var.unmonitor]](name) - Turns off monitoring of the math variable with given ''name''. <br />
*[[var.makeNumericList]](name)&nbsp;: Creates a list in the symbol table with the given ''name'', which is optimized to hold numeric values.<br />
*[[var.recall]](name)&nbsp;: Returns the value of a math variable with the given ''name''. <br />
*[[var.recallAt]](name, col [,row])&nbsp;: Recalls a value from a cell of a list or matrix in the symbol table.<br />
*[[var.recallstr]](name)&nbsp;: Returns the value of a math variable with the given name as a string. <br />
*[[var.store]](name, value)&nbsp;: Stores ''value'' as a math variable with the given ''name''.<br />
*[[var.storeAt]](name, numericValue, col [,row])&nbsp;: Stores a numeric value into an element of a math list or matrix with the given ''name''.<br />
<br />
== Misc. ==<br />
*'''[[locale.name]]'''() : Returns the name of the current locale as an ISO-639 code.<br />
*'''[[clipboard.addText]]'''(string) : Add 'string' to the clipboard<br />
*'''[[clipboard.getText]]'''() : Get the current content of the clipboard<br />
*'''[[cursor.hide]]'''() : Hides the cursor on the screen <br />
*'''[[cursor.set]]'''(cursorname) : Sets the new shape of the cursor to ''cursorname'' (see full list in the specific article)<br />
*'''[[cursor.show]]'''() : Makes the cursor visible on the screen<br />
*'''[[document.markChanged]]'''()&nbsp;: Mark the current document as changed</div>Technolapinhttps://wiki.inspired-lua.org/index.php?title=Overview_of_the_API&diff=1225Overview of the API2014-11-08T19:40:01Z<p>Technolapin: /* Coroutines Library */</p>
<hr />
<div>Note: The Lua version that comes with OS 3.x is 5.1.4, without the ''io'' nor ''os'' libraries.<br />
<br />
Tutorials on Nspire Lua scripting in general are available here : http://inspired-lua.org/<br />
<br />
== Standard Library ==<br />
<br />
( 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] )<br />
<br />
=== Common Lua Functions ===<br />
<br />
*'''[[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 <br />
*'''[[assert]]'''(value[, errormsg]) - asserts a value evaluates to true. If it is, returns value, otherwise causes a Lua error to be thrown. <br />
*'''[[collectgarbage]]''' - among other things, force free unused memory.<br />
*'''[[error]]'''(str) - generates an error with the str message.<br />
*'''[[getfenv]]'''(function or integer) - Returns the table representing the stack frame of the given function or stack level. <br />
*'''[[getmetatable]]'''(obj, mtable) - Returns the metatable of the given table or userdata object. <br />
*'''[[next]]'''(table, index) - Returns the next key, value pair of the table, allowing you to walk over the table. <br />
*'''[[newproxy]]'''(boolean or proxy) - Creates a userdata with a sharable metatable. <br />
*'''[[print]]'''(...) - Receives any number of arguments, and prints their values. Not intended for formatted output, but only as a quick way to show a value, typically for debugging. For formatted output, use string.format.<br />
*'''[[select]]'''(index, list) - Returns the number of items in list or the value of the item in list at index. <br />
*'''[[setfenv]]'''(function or integer, table) - Sets the table representing the stack frame of the given function or stack level. <br />
*'''[[setmetatable]]'''(obj, mtable) - Sets the metatable of the given table or userdata object. <br />
*'''[[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 "__tostring" 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. <br />
*'''[[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 "__tonumber" 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. <br />
*'''[[type]]'''(var) - Returns the type of variable as a string, "number", "string", "table", "function" or "userdata". <br />
*'''[[unpack]]'''(table[, start][, end]) - Returns the contents of its argument as separate values. <br />
*'''[[xpcall]]'''(func, err) - Returns a boolean indicating successful execution of func and calls err on failure, additionally returning func's or err's results.<br />
<br />
=== Coroutines Library ===<br />
The coroutines are usefull tools to control the running of differents parts of a code.<br />
<br />
create, wrap, resume, yield, status, running<br />
<br />
More information can be fouded in the coroutine page.<br />
<br />
=== String Library ===<br />
byte, char, dump, find, format, gmatch, gsub, len, lower, match, rep, reverse, sub, upper<br />
<br />
=== Math Library ===<br />
abs, acos, asin, atan, atan2, ceil, cos, cosh, deg, exp, floor, fmod, frexp, huge, ldexp, log, log10, max, min, modf, pi, pow, rad, random, randomseed, sin, sinh, sqrt, tan, tanh<br />
More information about the other libraries can be found on the [[Extended Standard Library]] Page<br />
<br />
== [[:Category:D2Editor|D2Editor]] ==<br />
The Lua 2D editor bindings enable 2D rich text editors to be created and manipulated within scripts.<br />
* [[D2Editor:createChemBox]]() : Inserts a Chem Box in the current cursor position of the editor.<br />
* [[D2Editor:createMathBox]]() : Inserts a Math Box (Expression Box) in the current cursor position of the editor.<br />
* [[D2Editor:getExpression]]() : Returns the contents of the text editor as a UTF-8 encoded string.<br />
* [[D2Editor:getExpressionSelection]]() : Returns three values: the contents of the text editor (UTF-8 encoded string), the cursor position, and the selection start.<br />
* [[D2Editor:getText]]() : same as ''getExpression'' : Returns the contents of the text editor as a UTF-8 encoded string.<br />
* [[D2Editor:hasFocus]]() : Returns true if the editor has focus; otherwise returns false.<br />
* [[D2Editor:isVisible]]() : Returns true if the editor is visible; otherwise returns false.<br />
* [[D2Editor:move]]() : Sets the parent-relative location of the upper left corner of the text editor. Both x and y must be between -32767 and 32767.<br />
* [[D2Editor:newRichText]]() : Creates and returns a new 2D rich text editor.<br />
* [[D2Editor:registerFilter]](handlerTable) : This routine registers a table of handler functions that can alter events before they are sent to the 2D editor widget, or unregisters if nil is passed.<br />
* [[D2Editor:resize]](w, h) : Changes the width and height of the text editor. Both width and height must be > 0 and < 32768.<br />
* [[D2Editor:setBorder]](thickness) : Sets the editor's border thickness. The thickness value must be between 0 and 10.<br />
* [[D2Editor:setBorderColor]](color) : Sets the editor's border color. The color value must be between 0 and 16777215 (0x000000 and 0xFFFFFF).<br />
* [[D2Editor:setColorable]](true or false) : Makes the expression colorable or uncolorable.<br />
* [[D2Editor:setDisable2DinRT]](true or false) : Turns on/off 2D layout of math input to the text box.<br />
* [[D2Editor:setExpression]](...) : Sets the text content of the text editor.<br />
* [[D2Editor:setFocus]](true or false) : Sets the user input focus on the editor if true (the default). This is usually called from the [[on.getFocus]] event handler.<br />
* [[D2Editor:setFontSize]](size) : Sets the text font size in the editor. Only 7, 9, 10, 11, 12, or 24 for the handheld, any on the desktop software.<br />
* [[D2Editor:setMainFont]](family, style) : Sets the main font family ("serif" or "sansserif") and style ("r", "b", "i", "bi").<br />
* [[D2Editor:setReadOnly]](true or false) : Makes the text editor content modifiable (false) or unmodifiable (true) by the user. If a Boolean value is not specified, defaults to true.<br />
* [[D2Editor:setSelectable]](true or false) : Makes the text editor content selectable (true) or unselectable (false) by the user. If a Boolean value is not specified, defaults to true.<br />
* [[D2Editor:setSizeChangeListener]](function(editor, w, h)) : Sets the callback function for when the editor contents exceed the current editor size, when the contents fit on fewer lines, or when the contents fit on a single line of smaller width.<br />
* [[D2Editor:setTextChangeListener]](function(editor)) : Sets the callback function for when the text expression changes, which will be to the editor object. This allows for processing text input as it occurs.<br />
* [[D2Editor:setText]](...) : Same as setExpression : Sets the text content of the text editor.<br />
* [[D2Editor:setTextColor]](color) : Sets the editor text color. The color value must be between 0 and 16777215 (0x000000 and 0xFFFFFF).<br />
* [[D2Editor:setVisible]](true or false) : Sets the visibility of the text editor.<br />
* [[D2Editor:setWordWrapWidth]](width) : Sets the rich text editor word-wrapping width in pixels. Ignored if the editor is in 2D mode. To indicate widget width, sets to 0. To disable wrapping, sets to < 0. The width must be -32767 to 32767.<br />
<br />
== [[:Category:Events|Events]] ==<br />
Events are one of the most fundamental things to know about the Nspire Lua language.<br />
You can see how events are managed inside the Lua implementation [[Life Cycle|here]]. <br />
<br />
*'''[[on.paint]]'''(gc) is called when the GUI is painted. [[:Category:gc|'gc' is the Graphics Context]] <br />
*'''[[on.resize]]''' is called when the window is rezised<br />
*'''[[on.timer]]''' is called at each timer ticks. See [[:Category:timer|timer]].<br> <br />
*'''[[on.arrowKey]]''' is called when an '''arrow key''' from the clickPad/TouchPad is pressed (right, left, up, down) <br />
*'''[[on.arrowLeft]]''' is called when the '''left''' arrow is pressed <br />
*'''[[on.arrowRight]]''' is called when the '''right''' arrow is pressed <br />
*'''[[on.arrowUp]]''' is called when the up '''arrow''' is pressed <br />
*'''[[on.arrowDown]]''' is called when the '''down''' arrow is pressed<br />
*'''[[on.enterKey]]''' is called when the '''enter''' key is pressed. <br />
*'''[[on.escapeKey]]''' is called when the '''escape''' key is pressed. <br />
*'''[[on.tabKey]]''' is called when the '''tab''' key is pressed. <br />
*'''[[on.deleteKey]]''' is called when the '''delete''' key is pressed. <br />
*'''[[on.backspaceKey]]''' is called when the '''clear''' key is pressed. <br />
*'''[[on.returnKey]]''' is called when the '''return''' key is pressed. <br />
*'''[[on.contextMenu]]''' is called when the combo-key '''Ctrl Menu''' is pressed. <br />
*'''[[on.backtabKey]]''' is called when the combo-key '''Maj Tab''' is pressed. <br />
*'''[[on.clearKey]]''' is called when the combo-key '''Ctrl Clear''' is pressed. <br />
*'''[[on.help]]''' is called when the combo-key '''Ctrl ?''' is pressed.<br />
*'''[[on.charIn]]''' is called when the Nspire detects a non arrow key being pressed.<br />
*'''[[on.createMathBox]]''' called when there is a MathBox created. <br />
*'''[[on.create]]''' called when the script gets created. '''Deprecated in 3.2'''. See ''on.contruction''.<br />
*'''[[on.construction]]''' called when the script gets created. <br />
*'''[[on.deactivate]]''' called when the focus is lost on the page (like launching the document, changing page etc...) <br />
*'''[[on.activate]]''' called when the focus is on the page (like launching the document, changing page etc...) <br />
*'''[[on.destroy]]''' is called when the document is about to get closed (or cut)<br />
*'''[[on.getFocus]]''' is called when the script receives user input focus. <br />
*'''[[on.loseFocus]]''' is called when the script loses user input focus. <br />
*'''[[on.mouseDown]]''' is called when we press the left mouse button. X and Y are the pressed point coordinates. <br />
*'''[[on.mouseUp]]''' is called when we release the left mouse button. <br />
*'''[[on.mouseMove]]''' is called when the mouse moves <br />
*'''[[on.grabDown]]''' is called when the grabbing motion is detected<br />
*'''[[on.grabUp]]''' is called after the grabbing action.<br />
*'''[[on.rightMouseDown]]''' is called when the user pushes the "right click" button<br />
*'''[[on.rightMouseUp]]''' is called when the user releases the "right click" button<br />
*'''[[on.keyboardUp]]'''() which fires when the tablet's on-screen keyboard gets shown.<br />
*'''[[on.keyboardDown]]'''() which fires when the tablet's on-screen keyboard gets hidden.<br />
*'''[[on.varChange]]''' is called when a [[var.monitor|monitored variable]] gets changed.<br />
*'''[[on.getSymbolList]]''' is called when the script app symbol list is being serialized to the clipboard.<br />
*'''[[on.save]]''' is called when the script app is saved to the document or copied to the clipboard.<br />
*'''[[on.restore]]''' is called when the script application is restored from its saved state in a document or when the app is pasted into a document..<br />
*'''[[on.cut]]''' is called when the user cuts something.<br />
*'''[[on.copy]]''' is called when the user copies something.<br />
*'''[[on.paste]]''' is called when the user pastes something.<br />
<br />
== [[:Category:gc|Graphics Operations]] ==<br />
'''gc''' is the Nspire's ''graphic context''. A graphics context is a module that has a handle to the script’s graphics output window and a library of graphics routines that are used to draw on the window. A graphics context is supplied to the script ”on.paint” event handler each time the window needs to be redrawn. The graphics context employs a pixel-based coordinate system with the origin in the upper left corner of the drawing window.<br />
<br />
*'''[[gc:clipRect]]'''(op, x, y, width, height) - Sets the clipping rectangle for subsequent graphics operations.<br />
*'''[[gc:drawArc]]'''(x, y, width, height, start angle, finish angle).<br />
*'''[[gc:drawImage]]'''(image,x,y) First argument in format “[[TI.Image]]”, x and y the coords.<br />
*'''[[gc:drawLine]]'''(xstart, ystart, xend, yend) Draws a line starting at the point (xstart,ystart) and ending at the point (xend, yend)<br />
*'''[[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.<br />
*'''[[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<br />
*'''[[gc:drawString]]'''(string, x, y, position) position is the string’s anchor point and can be "baseline", “bottom”, “middle”, or “top”. <br />
*'''[[gc:fillArc]]'''(x, y, width, height, start angle, finish angle) see [[gc:drawArc]]<br />
*'''[[gc:fillPolygon]]'''(int list1 [,int list2, .., int listN]) see [[gc:drawPolyLine]]<br />
*'''[[gc:fillRect]]'''(x, y, width, height) see [[gc:drawRect]]<br />
*'''[[gc:getStringHeight]]'''(string) - Returns the string's height.<br />
*'''[[gc:getStringWidth]]'''(string) - Returns the string's width<br />
*'''[[gc:setAlpha]]'''(alpha) - where alpha is an integer between 0 and 255. Sets the transparency. '''''Not available anymore in 3.2+'''''<br />
*'''[[gc:setColorRGB]]'''(red, green, blue) RGB values are integers, from 0 to 255.<br />
*'''[[gc:setFont]]'''(font, type, size), with font : {“sansserif”, "serif", ..}, type {“b”, “r”, “i”}, size(int)<br />
*'''[[gc:setPen]]'''(thickness, smoothness) : thickness {“thin”, “medium”, "thick"}, smoothness {“smooth”, "dotted", "dashed"}<br />
<br />
== [[:Category:image|Images]] ==<br />
*'''[[image.copy]]'''(theImage, width, height) : Returns a copy of the input image scaled to fit the specified pixel width and height. <br />
*'''[[image.height]]'''(theImage) : Returns the height of the ''image''<br />
*'''[[image.new]]'''(theImage) : Allocates a new [[TI.Image]]<br />
*'''[[image.rotate]]'''(theImage, angle) : Returns a rotated copy of ''theImage'' by ''angle'' degrees<br />
*'''[[image.width]]'''(theImage) : Returns the width of the ''image''<br />
<br />
== [[:Category:Physics_Engine|Physics Engine]] ==<br />
A port of Chipmunk Physics 5.3 has been embedded as an optional module (you have to 'require' it at the beginning of your script, in order to use it)<br />
*Arbiters and Collision Pairs<br />
*Bodies<br />
*Bounding Boxes<br />
*Circle Shapes<br />
*Constraints<br />
*Misc<br />
*Polygon Shapes<br />
*Segment Shapes<br />
*SegmentQueryInfo<br />
*Shape Queries<br />
*Shapes<br />
*Space Queries<br />
*Spaces<br />
*Vectors<br />
<br />
== [[:Category:platform|Platform]] ==<br />
*[[platform.isColorDisplay]]() : Returns true if the display of the host platform is color-capable (Nspire CX and emulator). Returns false if the display is grayscale (Nspire non-CX). <br />
*[[platform.isDeviceModeRendering]]() : Returns true if the script is running on the hand-held device or in the emulator (with the calculator view), and false if the script is running in the normal view of the emulator.<br />
*[[platform.isTabletModeRendering]]() : Returns true if the script is running on a tablet device (iPad app) and false otherwise.<br />
*[[:Category:platform.window|platform.window]] : Returns the window object currently owned by the script application. The window object contains several other methods.<br />
*[[platform.withGC]](...) : executes a function which a passed dummy [[gc]].<br />
*[[platform.registerErrorHandler]](...) : A global error handler for the lua script.<br />
*[[platform.hw]]() : returns a number corresponding to the type of device the script is running on.<br />
<br />
== [[:Category:timer|Timer]] ==<br />
*'''[[timer.start]]'''(period) : Starts the timer with the given ''period'' (in seconds)<br /><br />
*'''[[timer.getMilliSecCounter]]'''() : Returns the value of the milliseconds elapsed since the calculator's last boot.<br /><br />
*'''[[timer.stop]]'''() : Stops the timer.<br />
<br />
== [[:Category:toolpalette|Toolpalette]] ==<br />
The tool palette provides a menu of commands, selectable by the user, that invoke functionality of the script app. The menu itself is accessible by pressing the "Menu" button. <br />
*'''[[toolpalette.register|register]]'''(menuStructure) : Registers the ''menuStructure'' table. <br />
*'''[[toolpalette.enable|enable]]'''(toolname, itemname, state) : Enables or disables a menu item in the tool palette. <br />
*'''[[toolpalette.enableCopy|enableCopy]]'''(state) : This routine enables / disables the Edit > Copy menu command.<br />
*'''[[toolpalette.enableCut|enableCut]]'''(state) : This routine enables / disables the Edit > Cut menu command.<br />
*'''[[toolpalette.enablePaste|enablePaste]]'''(state) : This routine enables / disables the Edit > Paste menu command.<br />
<br />
== [[:Category:var|var]] ==<br />
'var' functions allows the script to interact with BASIC variables.<br />
*[[var.list]]() - Lists of names of variables currently used. <br />
*[[var.monitor]](name) - Turns on monitoring of the math variable with given ''name''. <br />
*[[var.unmonitor]](name) - Turns off monitoring of the math variable with given ''name''. <br />
*[[var.makeNumericList]](name)&nbsp;: Creates a list in the symbol table with the given ''name'', which is optimized to hold numeric values.<br />
*[[var.recall]](name)&nbsp;: Returns the value of a math variable with the given ''name''. <br />
*[[var.recallAt]](name, col [,row])&nbsp;: Recalls a value from a cell of a list or matrix in the symbol table.<br />
*[[var.recallstr]](name)&nbsp;: Returns the value of a math variable with the given name as a string. <br />
*[[var.store]](name, value)&nbsp;: Stores ''value'' as a math variable with the given ''name''.<br />
*[[var.storeAt]](name, numericValue, col [,row])&nbsp;: Stores a numeric value into an element of a math list or matrix with the given ''name''.<br />
<br />
== Misc. ==<br />
*'''[[locale.name]]'''() : Returns the name of the current locale as an ISO-639 code.<br />
*'''[[clipboard.addText]]'''(string) : Add 'string' to the clipboard<br />
*'''[[clipboard.getText]]'''() : Get the current content of the clipboard<br />
*'''[[cursor.hide]]'''() : Hides the cursor on the screen <br />
*'''[[cursor.set]]'''(cursorname) : Sets the new shape of the cursor to ''cursorname'' (see full list in the specific article)<br />
*'''[[cursor.show]]'''() : Makes the cursor visible on the screen<br />
*'''[[document.markChanged]]'''()&nbsp;: Mark the current document as changed</div>Technolapinhttps://wiki.inspired-lua.org/index.php?title=Overview_of_the_API&diff=1224Overview of the API2014-11-08T19:39:11Z<p>Technolapin: /* Coroutines Library */</p>
<hr />
<div>Note: The Lua version that comes with OS 3.x is 5.1.4, without the ''io'' nor ''os'' libraries.<br />
<br />
Tutorials on Nspire Lua scripting in general are available here : http://inspired-lua.org/<br />
<br />
== Standard Library ==<br />
<br />
( 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] )<br />
<br />
=== Common Lua Functions ===<br />
<br />
*'''[[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 <br />
*'''[[assert]]'''(value[, errormsg]) - asserts a value evaluates to true. If it is, returns value, otherwise causes a Lua error to be thrown. <br />
*'''[[collectgarbage]]''' - among other things, force free unused memory.<br />
*'''[[error]]'''(str) - generates an error with the str message.<br />
*'''[[getfenv]]'''(function or integer) - Returns the table representing the stack frame of the given function or stack level. <br />
*'''[[getmetatable]]'''(obj, mtable) - Returns the metatable of the given table or userdata object. <br />
*'''[[next]]'''(table, index) - Returns the next key, value pair of the table, allowing you to walk over the table. <br />
*'''[[newproxy]]'''(boolean or proxy) - Creates a userdata with a sharable metatable. <br />
*'''[[print]]'''(...) - Receives any number of arguments, and prints their values. Not intended for formatted output, but only as a quick way to show a value, typically for debugging. For formatted output, use string.format.<br />
*'''[[select]]'''(index, list) - Returns the number of items in list or the value of the item in list at index. <br />
*'''[[setfenv]]'''(function or integer, table) - Sets the table representing the stack frame of the given function or stack level. <br />
*'''[[setmetatable]]'''(obj, mtable) - Sets the metatable of the given table or userdata object. <br />
*'''[[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 "__tostring" 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. <br />
*'''[[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 "__tonumber" 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. <br />
*'''[[type]]'''(var) - Returns the type of variable as a string, "number", "string", "table", "function" or "userdata". <br />
*'''[[unpack]]'''(table[, start][, end]) - Returns the contents of its argument as separate values. <br />
*'''[[xpcall]]'''(func, err) - Returns a boolean indicating successful execution of func and calls err on failure, additionally returning func's or err's results.<br />
<br />
=== Coroutines Library ===<br />
The coroutines are usefull tools to control the running of differents parts of a code.<br />
<br />
<br />
create, wrap, resume, yield, status, running<br />
<br />
=== String Library ===<br />
byte, char, dump, find, format, gmatch, gsub, len, lower, match, rep, reverse, sub, upper<br />
<br />
=== Math Library ===<br />
abs, acos, asin, atan, atan2, ceil, cos, cosh, deg, exp, floor, fmod, frexp, huge, ldexp, log, log10, max, min, modf, pi, pow, rad, random, randomseed, sin, sinh, sqrt, tan, tanh<br />
More information about the other libraries can be found on the [[Extended Standard Library]] Page<br />
<br />
== [[:Category:D2Editor|D2Editor]] ==<br />
The Lua 2D editor bindings enable 2D rich text editors to be created and manipulated within scripts.<br />
* [[D2Editor:createChemBox]]() : Inserts a Chem Box in the current cursor position of the editor.<br />
* [[D2Editor:createMathBox]]() : Inserts a Math Box (Expression Box) in the current cursor position of the editor.<br />
* [[D2Editor:getExpression]]() : Returns the contents of the text editor as a UTF-8 encoded string.<br />
* [[D2Editor:getExpressionSelection]]() : Returns three values: the contents of the text editor (UTF-8 encoded string), the cursor position, and the selection start.<br />
* [[D2Editor:getText]]() : same as ''getExpression'' : Returns the contents of the text editor as a UTF-8 encoded string.<br />
* [[D2Editor:hasFocus]]() : Returns true if the editor has focus; otherwise returns false.<br />
* [[D2Editor:isVisible]]() : Returns true if the editor is visible; otherwise returns false.<br />
* [[D2Editor:move]]() : Sets the parent-relative location of the upper left corner of the text editor. Both x and y must be between -32767 and 32767.<br />
* [[D2Editor:newRichText]]() : Creates and returns a new 2D rich text editor.<br />
* [[D2Editor:registerFilter]](handlerTable) : This routine registers a table of handler functions that can alter events before they are sent to the 2D editor widget, or unregisters if nil is passed.<br />
* [[D2Editor:resize]](w, h) : Changes the width and height of the text editor. Both width and height must be > 0 and < 32768.<br />
* [[D2Editor:setBorder]](thickness) : Sets the editor's border thickness. The thickness value must be between 0 and 10.<br />
* [[D2Editor:setBorderColor]](color) : Sets the editor's border color. The color value must be between 0 and 16777215 (0x000000 and 0xFFFFFF).<br />
* [[D2Editor:setColorable]](true or false) : Makes the expression colorable or uncolorable.<br />
* [[D2Editor:setDisable2DinRT]](true or false) : Turns on/off 2D layout of math input to the text box.<br />
* [[D2Editor:setExpression]](...) : Sets the text content of the text editor.<br />
* [[D2Editor:setFocus]](true or false) : Sets the user input focus on the editor if true (the default). This is usually called from the [[on.getFocus]] event handler.<br />
* [[D2Editor:setFontSize]](size) : Sets the text font size in the editor. Only 7, 9, 10, 11, 12, or 24 for the handheld, any on the desktop software.<br />
* [[D2Editor:setMainFont]](family, style) : Sets the main font family ("serif" or "sansserif") and style ("r", "b", "i", "bi").<br />
* [[D2Editor:setReadOnly]](true or false) : Makes the text editor content modifiable (false) or unmodifiable (true) by the user. If a Boolean value is not specified, defaults to true.<br />
* [[D2Editor:setSelectable]](true or false) : Makes the text editor content selectable (true) or unselectable (false) by the user. If a Boolean value is not specified, defaults to true.<br />
* [[D2Editor:setSizeChangeListener]](function(editor, w, h)) : Sets the callback function for when the editor contents exceed the current editor size, when the contents fit on fewer lines, or when the contents fit on a single line of smaller width.<br />
* [[D2Editor:setTextChangeListener]](function(editor)) : Sets the callback function for when the text expression changes, which will be to the editor object. This allows for processing text input as it occurs.<br />
* [[D2Editor:setText]](...) : Same as setExpression : Sets the text content of the text editor.<br />
* [[D2Editor:setTextColor]](color) : Sets the editor text color. The color value must be between 0 and 16777215 (0x000000 and 0xFFFFFF).<br />
* [[D2Editor:setVisible]](true or false) : Sets the visibility of the text editor.<br />
* [[D2Editor:setWordWrapWidth]](width) : Sets the rich text editor word-wrapping width in pixels. Ignored if the editor is in 2D mode. To indicate widget width, sets to 0. To disable wrapping, sets to < 0. The width must be -32767 to 32767.<br />
<br />
== [[:Category:Events|Events]] ==<br />
Events are one of the most fundamental things to know about the Nspire Lua language.<br />
You can see how events are managed inside the Lua implementation [[Life Cycle|here]]. <br />
<br />
*'''[[on.paint]]'''(gc) is called when the GUI is painted. [[:Category:gc|'gc' is the Graphics Context]] <br />
*'''[[on.resize]]''' is called when the window is rezised<br />
*'''[[on.timer]]''' is called at each timer ticks. See [[:Category:timer|timer]].<br> <br />
*'''[[on.arrowKey]]''' is called when an '''arrow key''' from the clickPad/TouchPad is pressed (right, left, up, down) <br />
*'''[[on.arrowLeft]]''' is called when the '''left''' arrow is pressed <br />
*'''[[on.arrowRight]]''' is called when the '''right''' arrow is pressed <br />
*'''[[on.arrowUp]]''' is called when the up '''arrow''' is pressed <br />
*'''[[on.arrowDown]]''' is called when the '''down''' arrow is pressed<br />
*'''[[on.enterKey]]''' is called when the '''enter''' key is pressed. <br />
*'''[[on.escapeKey]]''' is called when the '''escape''' key is pressed. <br />
*'''[[on.tabKey]]''' is called when the '''tab''' key is pressed. <br />
*'''[[on.deleteKey]]''' is called when the '''delete''' key is pressed. <br />
*'''[[on.backspaceKey]]''' is called when the '''clear''' key is pressed. <br />
*'''[[on.returnKey]]''' is called when the '''return''' key is pressed. <br />
*'''[[on.contextMenu]]''' is called when the combo-key '''Ctrl Menu''' is pressed. <br />
*'''[[on.backtabKey]]''' is called when the combo-key '''Maj Tab''' is pressed. <br />
*'''[[on.clearKey]]''' is called when the combo-key '''Ctrl Clear''' is pressed. <br />
*'''[[on.help]]''' is called when the combo-key '''Ctrl ?''' is pressed.<br />
*'''[[on.charIn]]''' is called when the Nspire detects a non arrow key being pressed.<br />
*'''[[on.createMathBox]]''' called when there is a MathBox created. <br />
*'''[[on.create]]''' called when the script gets created. '''Deprecated in 3.2'''. See ''on.contruction''.<br />
*'''[[on.construction]]''' called when the script gets created. <br />
*'''[[on.deactivate]]''' called when the focus is lost on the page (like launching the document, changing page etc...) <br />
*'''[[on.activate]]''' called when the focus is on the page (like launching the document, changing page etc...) <br />
*'''[[on.destroy]]''' is called when the document is about to get closed (or cut)<br />
*'''[[on.getFocus]]''' is called when the script receives user input focus. <br />
*'''[[on.loseFocus]]''' is called when the script loses user input focus. <br />
*'''[[on.mouseDown]]''' is called when we press the left mouse button. X and Y are the pressed point coordinates. <br />
*'''[[on.mouseUp]]''' is called when we release the left mouse button. <br />
*'''[[on.mouseMove]]''' is called when the mouse moves <br />
*'''[[on.grabDown]]''' is called when the grabbing motion is detected<br />
*'''[[on.grabUp]]''' is called after the grabbing action.<br />
*'''[[on.rightMouseDown]]''' is called when the user pushes the "right click" button<br />
*'''[[on.rightMouseUp]]''' is called when the user releases the "right click" button<br />
*'''[[on.keyboardUp]]'''() which fires when the tablet's on-screen keyboard gets shown.<br />
*'''[[on.keyboardDown]]'''() which fires when the tablet's on-screen keyboard gets hidden.<br />
*'''[[on.varChange]]''' is called when a [[var.monitor|monitored variable]] gets changed.<br />
*'''[[on.getSymbolList]]''' is called when the script app symbol list is being serialized to the clipboard.<br />
*'''[[on.save]]''' is called when the script app is saved to the document or copied to the clipboard.<br />
*'''[[on.restore]]''' is called when the script application is restored from its saved state in a document or when the app is pasted into a document..<br />
*'''[[on.cut]]''' is called when the user cuts something.<br />
*'''[[on.copy]]''' is called when the user copies something.<br />
*'''[[on.paste]]''' is called when the user pastes something.<br />
<br />
== [[:Category:gc|Graphics Operations]] ==<br />
'''gc''' is the Nspire's ''graphic context''. A graphics context is a module that has a handle to the script’s graphics output window and a library of graphics routines that are used to draw on the window. A graphics context is supplied to the script ”on.paint” event handler each time the window needs to be redrawn. The graphics context employs a pixel-based coordinate system with the origin in the upper left corner of the drawing window.<br />
<br />
*'''[[gc:clipRect]]'''(op, x, y, width, height) - Sets the clipping rectangle for subsequent graphics operations.<br />
*'''[[gc:drawArc]]'''(x, y, width, height, start angle, finish angle).<br />
*'''[[gc:drawImage]]'''(image,x,y) First argument in format “[[TI.Image]]”, x and y the coords.<br />
*'''[[gc:drawLine]]'''(xstart, ystart, xend, yend) Draws a line starting at the point (xstart,ystart) and ending at the point (xend, yend)<br />
*'''[[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.<br />
*'''[[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<br />
*'''[[gc:drawString]]'''(string, x, y, position) position is the string’s anchor point and can be "baseline", “bottom”, “middle”, or “top”. <br />
*'''[[gc:fillArc]]'''(x, y, width, height, start angle, finish angle) see [[gc:drawArc]]<br />
*'''[[gc:fillPolygon]]'''(int list1 [,int list2, .., int listN]) see [[gc:drawPolyLine]]<br />
*'''[[gc:fillRect]]'''(x, y, width, height) see [[gc:drawRect]]<br />
*'''[[gc:getStringHeight]]'''(string) - Returns the string's height.<br />
*'''[[gc:getStringWidth]]'''(string) - Returns the string's width<br />
*'''[[gc:setAlpha]]'''(alpha) - where alpha is an integer between 0 and 255. Sets the transparency. '''''Not available anymore in 3.2+'''''<br />
*'''[[gc:setColorRGB]]'''(red, green, blue) RGB values are integers, from 0 to 255.<br />
*'''[[gc:setFont]]'''(font, type, size), with font : {“sansserif”, "serif", ..}, type {“b”, “r”, “i”}, size(int)<br />
*'''[[gc:setPen]]'''(thickness, smoothness) : thickness {“thin”, “medium”, "thick"}, smoothness {“smooth”, "dotted", "dashed"}<br />
<br />
== [[:Category:image|Images]] ==<br />
*'''[[image.copy]]'''(theImage, width, height) : Returns a copy of the input image scaled to fit the specified pixel width and height. <br />
*'''[[image.height]]'''(theImage) : Returns the height of the ''image''<br />
*'''[[image.new]]'''(theImage) : Allocates a new [[TI.Image]]<br />
*'''[[image.rotate]]'''(theImage, angle) : Returns a rotated copy of ''theImage'' by ''angle'' degrees<br />
*'''[[image.width]]'''(theImage) : Returns the width of the ''image''<br />
<br />
== [[:Category:Physics_Engine|Physics Engine]] ==<br />
A port of Chipmunk Physics 5.3 has been embedded as an optional module (you have to 'require' it at the beginning of your script, in order to use it)<br />
*Arbiters and Collision Pairs<br />
*Bodies<br />
*Bounding Boxes<br />
*Circle Shapes<br />
*Constraints<br />
*Misc<br />
*Polygon Shapes<br />
*Segment Shapes<br />
*SegmentQueryInfo<br />
*Shape Queries<br />
*Shapes<br />
*Space Queries<br />
*Spaces<br />
*Vectors<br />
<br />
== [[:Category:platform|Platform]] ==<br />
*[[platform.isColorDisplay]]() : Returns true if the display of the host platform is color-capable (Nspire CX and emulator). Returns false if the display is grayscale (Nspire non-CX). <br />
*[[platform.isDeviceModeRendering]]() : Returns true if the script is running on the hand-held device or in the emulator (with the calculator view), and false if the script is running in the normal view of the emulator.<br />
*[[platform.isTabletModeRendering]]() : Returns true if the script is running on a tablet device (iPad app) and false otherwise.<br />
*[[:Category:platform.window|platform.window]] : Returns the window object currently owned by the script application. The window object contains several other methods.<br />
*[[platform.withGC]](...) : executes a function which a passed dummy [[gc]].<br />
*[[platform.registerErrorHandler]](...) : A global error handler for the lua script.<br />
*[[platform.hw]]() : returns a number corresponding to the type of device the script is running on.<br />
<br />
== [[:Category:timer|Timer]] ==<br />
*'''[[timer.start]]'''(period) : Starts the timer with the given ''period'' (in seconds)<br /><br />
*'''[[timer.getMilliSecCounter]]'''() : Returns the value of the milliseconds elapsed since the calculator's last boot.<br /><br />
*'''[[timer.stop]]'''() : Stops the timer.<br />
<br />
== [[:Category:toolpalette|Toolpalette]] ==<br />
The tool palette provides a menu of commands, selectable by the user, that invoke functionality of the script app. The menu itself is accessible by pressing the "Menu" button. <br />
*'''[[toolpalette.register|register]]'''(menuStructure) : Registers the ''menuStructure'' table. <br />
*'''[[toolpalette.enable|enable]]'''(toolname, itemname, state) : Enables or disables a menu item in the tool palette. <br />
*'''[[toolpalette.enableCopy|enableCopy]]'''(state) : This routine enables / disables the Edit > Copy menu command.<br />
*'''[[toolpalette.enableCut|enableCut]]'''(state) : This routine enables / disables the Edit > Cut menu command.<br />
*'''[[toolpalette.enablePaste|enablePaste]]'''(state) : This routine enables / disables the Edit > Paste menu command.<br />
<br />
== [[:Category:var|var]] ==<br />
'var' functions allows the script to interact with BASIC variables.<br />
*[[var.list]]() - Lists of names of variables currently used. <br />
*[[var.monitor]](name) - Turns on monitoring of the math variable with given ''name''. <br />
*[[var.unmonitor]](name) - Turns off monitoring of the math variable with given ''name''. <br />
*[[var.makeNumericList]](name)&nbsp;: Creates a list in the symbol table with the given ''name'', which is optimized to hold numeric values.<br />
*[[var.recall]](name)&nbsp;: Returns the value of a math variable with the given ''name''. <br />
*[[var.recallAt]](name, col [,row])&nbsp;: Recalls a value from a cell of a list or matrix in the symbol table.<br />
*[[var.recallstr]](name)&nbsp;: Returns the value of a math variable with the given name as a string. <br />
*[[var.store]](name, value)&nbsp;: Stores ''value'' as a math variable with the given ''name''.<br />
*[[var.storeAt]](name, numericValue, col [,row])&nbsp;: Stores a numeric value into an element of a math list or matrix with the given ''name''.<br />
<br />
== Misc. ==<br />
*'''[[locale.name]]'''() : Returns the name of the current locale as an ISO-639 code.<br />
*'''[[clipboard.addText]]'''(string) : Add 'string' to the clipboard<br />
*'''[[clipboard.getText]]'''() : Get the current content of the clipboard<br />
*'''[[cursor.hide]]'''() : Hides the cursor on the screen <br />
*'''[[cursor.set]]'''(cursorname) : Sets the new shape of the cursor to ''cursorname'' (see full list in the specific article)<br />
*'''[[cursor.show]]'''() : Makes the cursor visible on the screen<br />
*'''[[document.markChanged]]'''()&nbsp;: Mark the current document as changed</div>Technolapinhttps://wiki.inspired-lua.org/index.php?title=Overview_of_the_API&diff=1223Overview of the API2014-11-08T19:38:40Z<p>Technolapin: /* Standard Library */</p>
<hr />
<div>Note: The Lua version that comes with OS 3.x is 5.1.4, without the ''io'' nor ''os'' libraries.<br />
<br />
Tutorials on Nspire Lua scripting in general are available here : http://inspired-lua.org/<br />
<br />
== Standard Library ==<br />
<br />
( 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] )<br />
<br />
=== Common Lua Functions ===<br />
<br />
*'''[[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 <br />
*'''[[assert]]'''(value[, errormsg]) - asserts a value evaluates to true. If it is, returns value, otherwise causes a Lua error to be thrown. <br />
*'''[[collectgarbage]]''' - among other things, force free unused memory.<br />
*'''[[error]]'''(str) - generates an error with the str message.<br />
*'''[[getfenv]]'''(function or integer) - Returns the table representing the stack frame of the given function or stack level. <br />
*'''[[getmetatable]]'''(obj, mtable) - Returns the metatable of the given table or userdata object. <br />
*'''[[next]]'''(table, index) - Returns the next key, value pair of the table, allowing you to walk over the table. <br />
*'''[[newproxy]]'''(boolean or proxy) - Creates a userdata with a sharable metatable. <br />
*'''[[print]]'''(...) - Receives any number of arguments, and prints their values. Not intended for formatted output, but only as a quick way to show a value, typically for debugging. For formatted output, use string.format.<br />
*'''[[select]]'''(index, list) - Returns the number of items in list or the value of the item in list at index. <br />
*'''[[setfenv]]'''(function or integer, table) - Sets the table representing the stack frame of the given function or stack level. <br />
*'''[[setmetatable]]'''(obj, mtable) - Sets the metatable of the given table or userdata object. <br />
*'''[[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 "__tostring" 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. <br />
*'''[[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 "__tonumber" 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. <br />
*'''[[type]]'''(var) - Returns the type of variable as a string, "number", "string", "table", "function" or "userdata". <br />
*'''[[unpack]]'''(table[, start][, end]) - Returns the contents of its argument as separate values. <br />
*'''[[xpcall]]'''(func, err) - Returns a boolean indicating successful execution of func and calls err on failure, additionally returning func's or err's results.<br />
<br />
=== Coroutines Library ===<br />
The coroutines are usefull tools to control the running of differents parts of a code.<br />
create, wrap, resume, yield, status, running<br />
=== String Library ===<br />
byte, char, dump, find, format, gmatch, gsub, len, lower, match, rep, reverse, sub, upper<br />
<br />
=== Math Library ===<br />
abs, acos, asin, atan, atan2, ceil, cos, cosh, deg, exp, floor, fmod, frexp, huge, ldexp, log, log10, max, min, modf, pi, pow, rad, random, randomseed, sin, sinh, sqrt, tan, tanh<br />
More information about the other libraries can be found on the [[Extended Standard Library]] Page<br />
<br />
== [[:Category:D2Editor|D2Editor]] ==<br />
The Lua 2D editor bindings enable 2D rich text editors to be created and manipulated within scripts.<br />
* [[D2Editor:createChemBox]]() : Inserts a Chem Box in the current cursor position of the editor.<br />
* [[D2Editor:createMathBox]]() : Inserts a Math Box (Expression Box) in the current cursor position of the editor.<br />
* [[D2Editor:getExpression]]() : Returns the contents of the text editor as a UTF-8 encoded string.<br />
* [[D2Editor:getExpressionSelection]]() : Returns three values: the contents of the text editor (UTF-8 encoded string), the cursor position, and the selection start.<br />
* [[D2Editor:getText]]() : same as ''getExpression'' : Returns the contents of the text editor as a UTF-8 encoded string.<br />
* [[D2Editor:hasFocus]]() : Returns true if the editor has focus; otherwise returns false.<br />
* [[D2Editor:isVisible]]() : Returns true if the editor is visible; otherwise returns false.<br />
* [[D2Editor:move]]() : Sets the parent-relative location of the upper left corner of the text editor. Both x and y must be between -32767 and 32767.<br />
* [[D2Editor:newRichText]]() : Creates and returns a new 2D rich text editor.<br />
* [[D2Editor:registerFilter]](handlerTable) : This routine registers a table of handler functions that can alter events before they are sent to the 2D editor widget, or unregisters if nil is passed.<br />
* [[D2Editor:resize]](w, h) : Changes the width and height of the text editor. Both width and height must be > 0 and < 32768.<br />
* [[D2Editor:setBorder]](thickness) : Sets the editor's border thickness. The thickness value must be between 0 and 10.<br />
* [[D2Editor:setBorderColor]](color) : Sets the editor's border color. The color value must be between 0 and 16777215 (0x000000 and 0xFFFFFF).<br />
* [[D2Editor:setColorable]](true or false) : Makes the expression colorable or uncolorable.<br />
* [[D2Editor:setDisable2DinRT]](true or false) : Turns on/off 2D layout of math input to the text box.<br />
* [[D2Editor:setExpression]](...) : Sets the text content of the text editor.<br />
* [[D2Editor:setFocus]](true or false) : Sets the user input focus on the editor if true (the default). This is usually called from the [[on.getFocus]] event handler.<br />
* [[D2Editor:setFontSize]](size) : Sets the text font size in the editor. Only 7, 9, 10, 11, 12, or 24 for the handheld, any on the desktop software.<br />
* [[D2Editor:setMainFont]](family, style) : Sets the main font family ("serif" or "sansserif") and style ("r", "b", "i", "bi").<br />
* [[D2Editor:setReadOnly]](true or false) : Makes the text editor content modifiable (false) or unmodifiable (true) by the user. If a Boolean value is not specified, defaults to true.<br />
* [[D2Editor:setSelectable]](true or false) : Makes the text editor content selectable (true) or unselectable (false) by the user. If a Boolean value is not specified, defaults to true.<br />
* [[D2Editor:setSizeChangeListener]](function(editor, w, h)) : Sets the callback function for when the editor contents exceed the current editor size, when the contents fit on fewer lines, or when the contents fit on a single line of smaller width.<br />
* [[D2Editor:setTextChangeListener]](function(editor)) : Sets the callback function for when the text expression changes, which will be to the editor object. This allows for processing text input as it occurs.<br />
* [[D2Editor:setText]](...) : Same as setExpression : Sets the text content of the text editor.<br />
* [[D2Editor:setTextColor]](color) : Sets the editor text color. The color value must be between 0 and 16777215 (0x000000 and 0xFFFFFF).<br />
* [[D2Editor:setVisible]](true or false) : Sets the visibility of the text editor.<br />
* [[D2Editor:setWordWrapWidth]](width) : Sets the rich text editor word-wrapping width in pixels. Ignored if the editor is in 2D mode. To indicate widget width, sets to 0. To disable wrapping, sets to < 0. The width must be -32767 to 32767.<br />
<br />
== [[:Category:Events|Events]] ==<br />
Events are one of the most fundamental things to know about the Nspire Lua language.<br />
You can see how events are managed inside the Lua implementation [[Life Cycle|here]]. <br />
<br />
*'''[[on.paint]]'''(gc) is called when the GUI is painted. [[:Category:gc|'gc' is the Graphics Context]] <br />
*'''[[on.resize]]''' is called when the window is rezised<br />
*'''[[on.timer]]''' is called at each timer ticks. See [[:Category:timer|timer]].<br> <br />
*'''[[on.arrowKey]]''' is called when an '''arrow key''' from the clickPad/TouchPad is pressed (right, left, up, down) <br />
*'''[[on.arrowLeft]]''' is called when the '''left''' arrow is pressed <br />
*'''[[on.arrowRight]]''' is called when the '''right''' arrow is pressed <br />
*'''[[on.arrowUp]]''' is called when the up '''arrow''' is pressed <br />
*'''[[on.arrowDown]]''' is called when the '''down''' arrow is pressed<br />
*'''[[on.enterKey]]''' is called when the '''enter''' key is pressed. <br />
*'''[[on.escapeKey]]''' is called when the '''escape''' key is pressed. <br />
*'''[[on.tabKey]]''' is called when the '''tab''' key is pressed. <br />
*'''[[on.deleteKey]]''' is called when the '''delete''' key is pressed. <br />
*'''[[on.backspaceKey]]''' is called when the '''clear''' key is pressed. <br />
*'''[[on.returnKey]]''' is called when the '''return''' key is pressed. <br />
*'''[[on.contextMenu]]''' is called when the combo-key '''Ctrl Menu''' is pressed. <br />
*'''[[on.backtabKey]]''' is called when the combo-key '''Maj Tab''' is pressed. <br />
*'''[[on.clearKey]]''' is called when the combo-key '''Ctrl Clear''' is pressed. <br />
*'''[[on.help]]''' is called when the combo-key '''Ctrl ?''' is pressed.<br />
*'''[[on.charIn]]''' is called when the Nspire detects a non arrow key being pressed.<br />
*'''[[on.createMathBox]]''' called when there is a MathBox created. <br />
*'''[[on.create]]''' called when the script gets created. '''Deprecated in 3.2'''. See ''on.contruction''.<br />
*'''[[on.construction]]''' called when the script gets created. <br />
*'''[[on.deactivate]]''' called when the focus is lost on the page (like launching the document, changing page etc...) <br />
*'''[[on.activate]]''' called when the focus is on the page (like launching the document, changing page etc...) <br />
*'''[[on.destroy]]''' is called when the document is about to get closed (or cut)<br />
*'''[[on.getFocus]]''' is called when the script receives user input focus. <br />
*'''[[on.loseFocus]]''' is called when the script loses user input focus. <br />
*'''[[on.mouseDown]]''' is called when we press the left mouse button. X and Y are the pressed point coordinates. <br />
*'''[[on.mouseUp]]''' is called when we release the left mouse button. <br />
*'''[[on.mouseMove]]''' is called when the mouse moves <br />
*'''[[on.grabDown]]''' is called when the grabbing motion is detected<br />
*'''[[on.grabUp]]''' is called after the grabbing action.<br />
*'''[[on.rightMouseDown]]''' is called when the user pushes the "right click" button<br />
*'''[[on.rightMouseUp]]''' is called when the user releases the "right click" button<br />
*'''[[on.keyboardUp]]'''() which fires when the tablet's on-screen keyboard gets shown.<br />
*'''[[on.keyboardDown]]'''() which fires when the tablet's on-screen keyboard gets hidden.<br />
*'''[[on.varChange]]''' is called when a [[var.monitor|monitored variable]] gets changed.<br />
*'''[[on.getSymbolList]]''' is called when the script app symbol list is being serialized to the clipboard.<br />
*'''[[on.save]]''' is called when the script app is saved to the document or copied to the clipboard.<br />
*'''[[on.restore]]''' is called when the script application is restored from its saved state in a document or when the app is pasted into a document..<br />
*'''[[on.cut]]''' is called when the user cuts something.<br />
*'''[[on.copy]]''' is called when the user copies something.<br />
*'''[[on.paste]]''' is called when the user pastes something.<br />
<br />
== [[:Category:gc|Graphics Operations]] ==<br />
'''gc''' is the Nspire's ''graphic context''. A graphics context is a module that has a handle to the script’s graphics output window and a library of graphics routines that are used to draw on the window. A graphics context is supplied to the script ”on.paint” event handler each time the window needs to be redrawn. The graphics context employs a pixel-based coordinate system with the origin in the upper left corner of the drawing window.<br />
<br />
*'''[[gc:clipRect]]'''(op, x, y, width, height) - Sets the clipping rectangle for subsequent graphics operations.<br />
*'''[[gc:drawArc]]'''(x, y, width, height, start angle, finish angle).<br />
*'''[[gc:drawImage]]'''(image,x,y) First argument in format “[[TI.Image]]”, x and y the coords.<br />
*'''[[gc:drawLine]]'''(xstart, ystart, xend, yend) Draws a line starting at the point (xstart,ystart) and ending at the point (xend, yend)<br />
*'''[[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.<br />
*'''[[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<br />
*'''[[gc:drawString]]'''(string, x, y, position) position is the string’s anchor point and can be "baseline", “bottom”, “middle”, or “top”. <br />
*'''[[gc:fillArc]]'''(x, y, width, height, start angle, finish angle) see [[gc:drawArc]]<br />
*'''[[gc:fillPolygon]]'''(int list1 [,int list2, .., int listN]) see [[gc:drawPolyLine]]<br />
*'''[[gc:fillRect]]'''(x, y, width, height) see [[gc:drawRect]]<br />
*'''[[gc:getStringHeight]]'''(string) - Returns the string's height.<br />
*'''[[gc:getStringWidth]]'''(string) - Returns the string's width<br />
*'''[[gc:setAlpha]]'''(alpha) - where alpha is an integer between 0 and 255. Sets the transparency. '''''Not available anymore in 3.2+'''''<br />
*'''[[gc:setColorRGB]]'''(red, green, blue) RGB values are integers, from 0 to 255.<br />
*'''[[gc:setFont]]'''(font, type, size), with font : {“sansserif”, "serif", ..}, type {“b”, “r”, “i”}, size(int)<br />
*'''[[gc:setPen]]'''(thickness, smoothness) : thickness {“thin”, “medium”, "thick"}, smoothness {“smooth”, "dotted", "dashed"}<br />
<br />
== [[:Category:image|Images]] ==<br />
*'''[[image.copy]]'''(theImage, width, height) : Returns a copy of the input image scaled to fit the specified pixel width and height. <br />
*'''[[image.height]]'''(theImage) : Returns the height of the ''image''<br />
*'''[[image.new]]'''(theImage) : Allocates a new [[TI.Image]]<br />
*'''[[image.rotate]]'''(theImage, angle) : Returns a rotated copy of ''theImage'' by ''angle'' degrees<br />
*'''[[image.width]]'''(theImage) : Returns the width of the ''image''<br />
<br />
== [[:Category:Physics_Engine|Physics Engine]] ==<br />
A port of Chipmunk Physics 5.3 has been embedded as an optional module (you have to 'require' it at the beginning of your script, in order to use it)<br />
*Arbiters and Collision Pairs<br />
*Bodies<br />
*Bounding Boxes<br />
*Circle Shapes<br />
*Constraints<br />
*Misc<br />
*Polygon Shapes<br />
*Segment Shapes<br />
*SegmentQueryInfo<br />
*Shape Queries<br />
*Shapes<br />
*Space Queries<br />
*Spaces<br />
*Vectors<br />
<br />
== [[:Category:platform|Platform]] ==<br />
*[[platform.isColorDisplay]]() : Returns true if the display of the host platform is color-capable (Nspire CX and emulator). Returns false if the display is grayscale (Nspire non-CX). <br />
*[[platform.isDeviceModeRendering]]() : Returns true if the script is running on the hand-held device or in the emulator (with the calculator view), and false if the script is running in the normal view of the emulator.<br />
*[[platform.isTabletModeRendering]]() : Returns true if the script is running on a tablet device (iPad app) and false otherwise.<br />
*[[:Category:platform.window|platform.window]] : Returns the window object currently owned by the script application. The window object contains several other methods.<br />
*[[platform.withGC]](...) : executes a function which a passed dummy [[gc]].<br />
*[[platform.registerErrorHandler]](...) : A global error handler for the lua script.<br />
*[[platform.hw]]() : returns a number corresponding to the type of device the script is running on.<br />
<br />
== [[:Category:timer|Timer]] ==<br />
*'''[[timer.start]]'''(period) : Starts the timer with the given ''period'' (in seconds)<br /><br />
*'''[[timer.getMilliSecCounter]]'''() : Returns the value of the milliseconds elapsed since the calculator's last boot.<br /><br />
*'''[[timer.stop]]'''() : Stops the timer.<br />
<br />
== [[:Category:toolpalette|Toolpalette]] ==<br />
The tool palette provides a menu of commands, selectable by the user, that invoke functionality of the script app. The menu itself is accessible by pressing the "Menu" button. <br />
*'''[[toolpalette.register|register]]'''(menuStructure) : Registers the ''menuStructure'' table. <br />
*'''[[toolpalette.enable|enable]]'''(toolname, itemname, state) : Enables or disables a menu item in the tool palette. <br />
*'''[[toolpalette.enableCopy|enableCopy]]'''(state) : This routine enables / disables the Edit > Copy menu command.<br />
*'''[[toolpalette.enableCut|enableCut]]'''(state) : This routine enables / disables the Edit > Cut menu command.<br />
*'''[[toolpalette.enablePaste|enablePaste]]'''(state) : This routine enables / disables the Edit > Paste menu command.<br />
<br />
== [[:Category:var|var]] ==<br />
'var' functions allows the script to interact with BASIC variables.<br />
*[[var.list]]() - Lists of names of variables currently used. <br />
*[[var.monitor]](name) - Turns on monitoring of the math variable with given ''name''. <br />
*[[var.unmonitor]](name) - Turns off monitoring of the math variable with given ''name''. <br />
*[[var.makeNumericList]](name)&nbsp;: Creates a list in the symbol table with the given ''name'', which is optimized to hold numeric values.<br />
*[[var.recall]](name)&nbsp;: Returns the value of a math variable with the given ''name''. <br />
*[[var.recallAt]](name, col [,row])&nbsp;: Recalls a value from a cell of a list or matrix in the symbol table.<br />
*[[var.recallstr]](name)&nbsp;: Returns the value of a math variable with the given name as a string. <br />
*[[var.store]](name, value)&nbsp;: Stores ''value'' as a math variable with the given ''name''.<br />
*[[var.storeAt]](name, numericValue, col [,row])&nbsp;: Stores a numeric value into an element of a math list or matrix with the given ''name''.<br />
<br />
== Misc. ==<br />
*'''[[locale.name]]'''() : Returns the name of the current locale as an ISO-639 code.<br />
*'''[[clipboard.addText]]'''(string) : Add 'string' to the clipboard<br />
*'''[[clipboard.getText]]'''() : Get the current content of the clipboard<br />
*'''[[cursor.hide]]'''() : Hides the cursor on the screen <br />
*'''[[cursor.set]]'''(cursorname) : Sets the new shape of the cursor to ''cursorname'' (see full list in the specific article)<br />
*'''[[cursor.show]]'''() : Makes the cursor visible on the screen<br />
*'''[[document.markChanged]]'''()&nbsp;: Mark the current document as changed</div>Technolapinhttps://wiki.inspired-lua.org/index.php?title=coroutines&diff=1222coroutines2014-11-08T19:34:28Z<p>Technolapin: Created page with "The coroutines in lua are pieces of codes that can be execute or stoped easely. A coroutine is declared with a function: <source lang="lua"> function foo (a) print a+1 end loc..."</p>
<hr />
<div>The coroutines in lua are pieces of codes that can be execute or stoped easely.<br />
<br />
A coroutine is declared with a function:<br />
<br />
<source lang="lua"><br />
function foo (a)<br />
print a+1<br />
end<br />
local co = coroutine.create (foo)<br />
</source><br />
<br />
To run a coroutine, you must use coroutine.resume() : <br />
<br />
<source lang="lua"><br />
function foo (a)<br />
print a+1<br />
end<br />
local co = coroutine.create (foo)<br />
coroutine.resume (co, 2)<br />
</source><br />
<br />
The syntax is : <br />
coroutine.resume (coroutinetorun, arg1, arg2, arg3, ...)<br />
<br />
So now the code will return 3.<br />
<br />
<br />
But coroutines are much more usefull with using coroutine.yield.<br />
That function will stop the execution of the coroutine, that can be resumed with coroutine.resume.<br />
The coroutine.resume() will return all argument in the coroutine.yield()<br />
<br />
<br />
Example:<br />
<br />
<source lang="lua"><br />
function foo ()<br />
local a = 0<br />
while true do<br />
a=a+1<br />
coroutine.yield (a, "an useless string just to show that more than one value can be returned")<br />
end<br />
end<br />
local co = coroutine.create (foo)<br />
print (coroutine.resume (co)) -- return if the coroutine runed and the values in the coroutine.yield<br />
<br />
print (coroutine.resume (co)) -- one more time!<br />
print (coroutine.resume (co)) -- again<br />
print (coroutine.resume (co)) -- a last one to finish.<br />
</source><br />
<br />
The status of the coroutine can be returned with coroutine.status()<br />
The possible status are:<br />
- suspended -- the coroutine is suspended and can be resumed<br />
- dead -- the coroutine is terminated and wont do anything<br />
<br />
Instead of coroutine.create () you can use coroutine.wrap, that return a function wich contain the coroutine.resume() of the function.<br />
<br />
<br />
coroutine.running () will return the currently running coroutine. That can be usefull if you use several coroutines.</div>Technolapin