Changes between Version 1 and Version 2 of documentation/LuaManual/EmbeddingScript

Show
Ignore:
Author:
gambini (IP: 96.38.104.126)
Timestamp:
05/20/12 04:38:20 (5 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • documentation/LuaManual/EmbeddingScript

    v1 v2  
    66== Inline event responses == 
    77 
    8 The Python plugin installs an event listener instancer to execute inline event responses as Python code. For example, in the following sample the element will run the print command when it is clicked: 
     8The Lua plugin installs an event listener instancer to execute inline event responses as Lua code. For example, in the following sample the element will run the print command when it is clicked: 
    99 
    1010{{{ 
    3131See the [wiki:documentation/LuaManual/Elements element], [wiki:documentation/LuaManual/Documents document] and [wiki:documentation/LuaManual/Events event] documentation for their full Lua interfaces. 
    3232 
    33 == Embedding Python into RML == 
     33== Embedding Lua into RML == 
    3434 
    35 Python code can be embedded into an RML document with the <script> tag. Similarly to Javascript, the script can be included from a separate file with the ''src'' attribute, or otherwise declared inline as loose content within the <script> tag. Any code embedded in this manner will be compiled with the document and will be available to inline event handlers in the RML. For example, the following document declares a Python function in the <script> tag and calls it from an element's ''onclick'' hander. 
     35Lua code can be embedded into an RML document with the <script> tag. Similarly to Javascript, the script can be included from a separate file with the ''src'' attribute, or otherwise declared inline as loose content within the <script> tag. Any code embedded in this manner will be compiled with the document and will be available to inline event handlers in the RML. For example, the following document declares a Lua function in the <script> tag and calls it from an element's ''onclick'' hander. 
    3636 
    3737{{{ 
    6464 
    6565A document can include multiple <script> tags. 
     66 
     67== Scope == 
     68The scope of the functions and variables created in the RML files is global. To avoid two functions or variables from having the same name, make sure to put them in a table that is uniquely named. In LuaInvaders, the table is named after the file, to see an example. Alternatively, be incredibly careful with naming everything. 
     69 
     70Because they are global, it is possible to call functions defined in other RML files, or any loose .lua files that have been loaded.