Scripting Engine

From Hero of Allacrost

Jump to: navigation, search
(Updated introduction and existing text for reading operations to coincide with recent engine design changes)
(Reading and Executing Scripts)
Line 53: Line 53:
== Reading and Executing Scripts ==
== Reading and Executing Scripts ==
-
The API user must first understand that in reading/execution mode, C++ does not only read Lua data and execute Lua code, but Lua is allowed to read C++ data and execute C++ code. There is a communication barrier between C++ and Lua, as they are different languages with different constructs. For example, Lua is a typeless language while C++ is a strongly typed. Lua has a garbage collector while memory management in C++ is done by the programmer. We will first discuss how C++ can read Lua data and execute Lua code, and then explain how Lua can initiate communication with C++. Every ScriptDescriptor object maintains its own local Lua state. The ScriptManager singleton maintains a "global" Lua state, which all other Lua states inherit from. What this means is that the global state may be used to communication information to all other Lua states. The motivation for this will be explained when we discuss bindings between Lua and C++.
+
The API user must first understand that in reading/execution mode, C++ does not only read Lua data and execute Lua code, but Lua is allowed to read C++ data and execute C++ code. There is a communication barrier between C++ and Lua, as they are different languages with different constructs. For example, Lua is a typeless language while C++ is a strongly typed. Lua has a garbage collector while memory management in C++ is done by the programmer. We will first discuss how C++ can read Lua data and execute Lua code, and then explain how Lua can initiate communication with C++. Every ScriptDescriptor object maintains its own local Lua stack via a lua thread. The ScriptManager singleton maintains a "global" Lua state, which all other Lua states inherit from. What this means is that the global state may be used to communication information to all other Lua states. The motivation for this will be explained when we discuss bindings between Lua and C++.
Line 366: Line 366:
==== Advanced Topics ====
==== Advanced Topics ====
-
 
== Writing Script Files ==
== Writing Script Files ==

Revision as of 17:09, 30 October 2007

Personal tools