Lua Programming: Difference between revisions
Jump to navigation
Jump to search
(→Cursor) |
Jimbauwens (talk | contribs) No edit summary |
||
(45 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
The TI-Nspire allows, since OS v3.0, | The TI-Nspire allows, since OS v3.0, users to run Lua scripts. | ||
==Prerequisites== | |||
Lua is only supported starting from OS v3.0.1. You can create Lua applications using the built-in script editor in the TI-Nspire computer software or one of the following third-party tools: | |||
'''For any OS''': | |||
*[https://github.com/ndless-nspire/Luna Luna] (cross-platform) [[https://www.omnimaga.org/news/'luna'-is-here-and-converts-your-lua-files-into-3-0-2-compatible-tns-files/ forum thread]] | |||
'''For OS < 3.0.1''': these tools won't work with the OS 3.0.2 since the format used is now blocked | |||
*[http://www.ticalc.org/archives/files/fileinfo/437/43704.html LUAtoTNS.sh] (bash script, works on Linux, Mac OS and Unix, or Windows + Cygwin or Windows + MSYS). | *[http://www.ticalc.org/archives/files/fileinfo/437/43704.html LUAtoTNS.sh] (bash script, works on Linux, Mac OS and Unix, or Windows + Cygwin or Windows + MSYS). | ||
*[http://www.mirari.fr/KbOD maketns.py] (Python script, cross-platform) | *[http://www.mirari.fr/KbOD maketns.py] (Python script, cross-platform) | ||
*[ | *[https://www.omnimaga.org/files/User-Contributed-Calculator-Games-amp-Development-Tools/TI-Nspire-amp-TI-Nspire-CAS/TI-Nspire-Programming-Tools/lua2ti.zip lua2ti] (Windows + .NET Framework v4.0) | ||
*[ | *[https://www.omnimaga.org/files/User-Contributed-Calculator-Games-amp-Development-Tools/TI-Nspire-amp-TI-Nspire-CAS/TI-Nspire-Programming-Tools/lua2ti_linux.zip lua2ti_linux] (Linux (No longer requires Mono, it is now a native Linux binary!)) | ||
You may also want to install Lua [ | You may also want to install Lua [https://www.lua.org/download.html on your computer]: <tt>luac -p</tt> can be used to check the syntax of your script before running it on a TI-Nspire or an emulator. | ||
==API== | |||
The | The documentation is now maintained in the "[http://wiki.inspired-lua.org Inspired Lua Wiki]". | ||
Please go there in order to have a full detailed documentation based on TI's information. | |||
==XML== | |||
== | ===Basic structure=== | ||
== | <syntaxhighlight lang="xml"> | ||
<wdgt | |||
xmlns:sc="urn:TI.ScriptApp" type="TI.ScriptApp" ver="1.0"> | |||
<sc:mFlags>1024</sc:mFlags> | |||
<sc:value>8</sc:value> | |||
<sc:cry>0</sc:cry> | |||
<sc:legal>none</sc:legal> | |||
<sc:schk>false</sc:schk> | |||
== | <sc:md> | ||
<sc:mde name="_VER" prop="134217728">1:1</sc:mde> | |||
<sc:mde name="TITLE" prop="2147549184">Hello</sc:mde> | |||
<sc:mde name="TARAL" prop="134217728">2:5</sc:mde> | |||
</sc:md> | |||
== | <sc:script version="33882629" id="1"> | ||
-- Lua script, XML encoded | |||
</sc:script> | |||
<sc:state> | |||
return {} -- Lua save state | |||
</sc:state> | |||
</wdgt></syntaxhighlight> | |||
== | ===Script tags=== | ||
====sc:script==== | |||
{| class="wikitable" | |||
|- | |||
! scope="col"| attribute | |||
! scope="col"| description | |||
|- | |||
| version | |||
| taral and reqal versions, one byte per digit (for older OSes?) | |||
|- | |||
| id | |||
| 1 = normal script, 2 & 3 = Question and Answer | |||
|} | |||
===Script metadata configuration=== | |||
== | {| class="wikitable" | ||
|- | |||
! scope="col"| Name | |||
! scope="col"| Prop | |||
! scope="col"| Description | |||
! scope="col"| Example | |||
|- | |||
| TARAL | |||
| 134217728 | |||
| TARget ApiLevel | |||
| <code><nowiki><sc:mde name="TARAL" prop="134217728">2:2</sc:mde></nowiki></code> | |||
|- | |||
| REQAL | |||
| 134217728 | |||
| REQuired ApiLevel | |||
| <code><nowiki><sc:mde name="REQAL" prop="134217728">2:0</sc:mde></nowiki></code> | |||
|- | |||
| _VER | |||
| 134217728 | |||
| TNS Version | |||
| <code><nowiki><sc:mde name="_VER" prop="134217728">1:1</sc:mde></nowiki></code> | |||
|- | |||
| TITLE | |||
| 2147549184 | |||
| ScriptApp title | |||
| <code><nowiki><sc:mde name="TITLE" prop="2147549184">Hello</sc:mde></nowiki></code> | |||
|- | |||
| - | |||
| 270532608 | |||
| Lua meta script | |||
| <code><nowiki><sc:mde name="TEST" prop="270532608">--lua code</sc:mde></nowiki></code> | |||
|- | |||
| BLERQ | |||
| 134217728 | |||
| BLE ReQuire - require ble libs | |||
| <code><nowiki><sc:mde name="BLERQ" prop="134217728">1</sc:mde></nowiki></code> | |||
|- | |||
| _FFunc | |||
| - | |||
| FailMe function (error catching) | |||
| Not known | |||
|- | |||
| _TRACE | |||
| - | |||
| Trace/log? | |||
| Not known | |||
|} |
Latest revision as of 14:48, 21 June 2019
The TI-Nspire allows, since OS v3.0, users to run Lua scripts.
Prerequisites
Lua is only supported starting from OS v3.0.1. You can create Lua applications using the built-in script editor in the TI-Nspire computer software or one of the following third-party tools:
For any OS:
- Luna (cross-platform) [forum thread]
For OS < 3.0.1: these tools won't work with the OS 3.0.2 since the format used is now blocked
- LUAtoTNS.sh (bash script, works on Linux, Mac OS and Unix, or Windows + Cygwin or Windows + MSYS).
- maketns.py (Python script, cross-platform)
- lua2ti (Windows + .NET Framework v4.0)
- lua2ti_linux (Linux (No longer requires Mono, it is now a native Linux binary!))
You may also want to install Lua on your computer: luac -p can be used to check the syntax of your script before running it on a TI-Nspire or an emulator.
API
The documentation is now maintained in the "Inspired Lua Wiki". Please go there in order to have a full detailed documentation based on TI's information.
XML
Basic structure
<wdgt
xmlns:sc="urn:TI.ScriptApp" type="TI.ScriptApp" ver="1.0">
<sc:mFlags>1024</sc:mFlags>
<sc:value>8</sc:value>
<sc:cry>0</sc:cry>
<sc:legal>none</sc:legal>
<sc:schk>false</sc:schk>
<sc:md>
<sc:mde name="_VER" prop="134217728">1:1</sc:mde>
<sc:mde name="TITLE" prop="2147549184">Hello</sc:mde>
<sc:mde name="TARAL" prop="134217728">2:5</sc:mde>
</sc:md>
<sc:script version="33882629" id="1">
-- Lua script, XML encoded
</sc:script>
<sc:state>
return {} -- Lua save state
</sc:state>
</wdgt>
Script tags
sc:script
attribute | description |
---|---|
version | taral and reqal versions, one byte per digit (for older OSes?) |
id | 1 = normal script, 2 & 3 = Question and Answer |
Script metadata configuration
Name | Prop | Description | Example |
---|---|---|---|
TARAL | 134217728 | TARget ApiLevel | <sc:mde name="TARAL" prop="134217728">2:2</sc:mde>
|
REQAL | 134217728 | REQuired ApiLevel | <sc:mde name="REQAL" prop="134217728">2:0</sc:mde>
|
_VER | 134217728 | TNS Version | <sc:mde name="_VER" prop="134217728">1:1</sc:mde>
|
TITLE | 2147549184 | ScriptApp title | <sc:mde name="TITLE" prop="2147549184">Hello</sc:mde>
|
- | 270532608 | Lua meta script | <sc:mde name="TEST" prop="270532608">--lua code</sc:mde>
|
BLERQ | 134217728 | BLE ReQuire - require ble libs | <sc:mde name="BLERQ" prop="134217728">1</sc:mde>
|
_FFunc | - | FailMe function (error catching) | Not known |
_TRACE | - | Trace/log? | Not known |