Changes in OS 3.2

From Inspired-Lua Wiki

Jump to: navigation, search

In its TI-Nspire OS 3.2, TI updated the Lua scripting API.

Here are the changes made.


[edit] Compatibility mode

TI has 2 "apilevels" in 3.2. apilevel 1.0 provides backwards compatibility for < 3.2 OSes by keeping the old API structure.
All documents created for 3.1 and previous will run in that apilevel by default. This is because some changes in the XML structure of the document. So most programs and games should run fine by default.
Then there is apilevel 2.0. This apilevel has some big changes to the API structure, so you will have to update some of your code in order to have some of they new 3.2 stuff. However, it is currently not possible to create apilevel 2.0 documents with Luna due to changes in the XML structure. Luna may get updated soon.
For the best support and guarantee that you are using the correct apilevel, you should add the following to the top of new Lua documents you create:

platform.apilevel = "1.0" ( or platform.apilevel = "2.0" depending on what you plan to use)

[edit] Events

[edit] Graphical operations

function getHeightWidth(str, gc)
    local width = gc:getStringWidth(str) -- Gets the pixel length of str
    local height = gc:getStringHeight(str) -- Gets the pixel height of str
    return height, width
height, width = platform.withGC(getHeightWidth, 'Hello World')

What it does is calling the function you give as first argument, and additionally passing a dummy GC (Graphics Context) to it.

[edit] D2Editor

D2Editor has been greatly improved ; Here are the new functions :

[edit] Require

There are three modules that you can 'require': physics, color, and strict.
The physics module is the chipmunk physics engine.
color is just a table containing colors. ( (or color["red"]) will return the color code for red.)
'strict' is a module (not tested) which, apparently, makes it so Lua checks uses of undeclared global variables. All global variables must be 'declared' through a regular assignment (even assigning nil will do) in a main chunk before being used anywhere or assigned to inside a function.
Usage: require 'modulename'

[edit] Physics

Maybe the best part of it : OS 3.2 now includes the Open Source Chipmunk Physics engine, and you can use it right from Lua!
This will allow some great games and applications
Find all the functions/categories here (WIP !).Tutorials about it coming soon.

[edit] Image

image.rotate. Performs images rotation. (Warning : The image changes size when you rotate it. So you need to figure where to draw it based on the middle of its rotated size.)

[edit] Math

[edit] Platform

[edit] Toolpalette

If the APILevel is set to '2.0', the names of toolpalette items may be changed dynamically while the program is running. Calling toolpalette.register(nil) deactivates the toolpalette.

[edit] Variable

Personal tools