Difference between revisions of "Changes in OS 3.2"
Line 7: | Line 7: | ||
==Compatibility mode== | ==Compatibility mode== | ||
Let me first begin with the compatibility mode. TI has 2 "apiLevel's" in 3.2. apiLevel 1.0 provides backwards compatibility for <3.2 OS's by keeping the old API structure.<br /> | Let me first begin with the compatibility mode. TI has 2 "apiLevel's" in 3.2. apiLevel 1.0 provides backwards compatibility for <3.2 OS's by keeping the old API structure.<br /> | ||
− | '''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.<br /> 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. | + | '''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.<br /> 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 crash). Lua may get updated soon.<br /> |
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: | 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"'' | :''platform.apiLevel = "1.0"'' or ''platform.apiLevel = "2.0"'' | ||
<br /> | <br /> | ||
− | |||
==on.create== | ==on.create== |
Revision as of 12:41, 5 June 2012
In its TI-Nspire OS 3.2, TI updated the Lua scripting API.
Here are the changes made.
Compatibility mode
Let me first begin with the compatibility mode. TI has 2 "apiLevel's" in 3.2. apiLevel 1.0 provides backwards compatibility for <3.2 OS's 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 crash). Lua 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"
on.create
on.create is removed in apiLevel 2.0 and replaced with on.construction.
This event handler is guaranteed to run before all others.
Graphical operations
- Most graphical operations are now anti-aliased.
- gc:setColorRGB now supports one number as input (as well as the old style). For example, you can do gc:setColorRGB(0xFF00CC) or gc:setColorRGB(0)
- You can not use coordinates for drawing to the screen above/under (-) 32 000. (Be careful, some scripts might need to take that into account now, or they may crash)
- In apiLevel 2.0, platform.gc() is removed and replaced with platform.withGC(). An example of it:
function getStringWidth(gc, str)
return gc:getStringWidth(str)
end
function on.construction()
local strw = platform.withGC(getStringWidth, "The game")
end
So what it does it call the function you give as first argument and pass a dummy GC (Graphics Context) to it.
D2Editor
D2Editor has been greatly improved
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. (color.red (or color["red"]) will return the color code for red.)
We don't know what strict is or does.
Usage: require 'modulename'
Physics
Maybe the best part of it of. 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
Tutorials about it coming soon.
Image
image.rotate. Performs images rotation.
Math
New : math.evalStr, math.getEvalSettings and math.setEvalSettings.
Platform
- The already mentioned platform.withGC
- platform.registerErrorHandler, this allows you to take actions when an error occurs in your document.
- platform.window:setFocus, regain focus in your script.
Variable
- var.recallAt, fetch data from a certain spot in a list or matrix
- var.makeNumericList, create a list in the symbol table. The create list will work much more efficient with other var functions.