Browse Source

More prototyping of LUA scripting changes.

sgrenier 11 years ago
parent
commit
31457c054e
59 changed files with 1748 additions and 824 deletions
  1. 4 0
      gameplay/gameplay.vcxproj
  2. 12 0
      gameplay/gameplay.vcxproj.filters
  3. 1 1
      gameplay/src/AIAgent.cpp
  4. 2 2
      gameplay/src/Control.cpp
  5. 7 0
      gameplay/src/Node.cpp
  6. 227 98
      gameplay/src/ScriptController.cpp
  7. 63 27
      gameplay/src/ScriptController.h
  8. 2 2
      gameplay/src/ScriptController.inl
  9. 105 110
      gameplay/src/ScriptTarget.cpp
  10. 150 30
      gameplay/src/ScriptTarget.h
  11. 13 5
      gameplay/src/Transform.cpp
  12. 26 28
      gameplay/src/lua/lua_AIAgent.cpp
  13. 2 2
      gameplay/src/lua/lua_AIAgent.h
  14. 26 28
      gameplay/src/lua/lua_AIState.cpp
  15. 2 2
      gameplay/src/lua/lua_AIState.h
  16. 26 28
      gameplay/src/lua/lua_Button.cpp
  17. 2 2
      gameplay/src/lua/lua_Button.h
  18. 26 28
      gameplay/src/lua/lua_CheckBox.cpp
  19. 2 2
      gameplay/src/lua/lua_CheckBox.h
  20. 67 28
      gameplay/src/lua/lua_Container.cpp
  21. 3 2
      gameplay/src/lua/lua_Container.h
  22. 51 0
      gameplay/src/lua/lua_ContainerDirection.cpp
  23. 15 0
      gameplay/src/lua/lua_ContainerDirection.h
  24. 26 28
      gameplay/src/lua/lua_Control.cpp
  25. 2 2
      gameplay/src/lua/lua_Control.h
  26. 96 29
      gameplay/src/lua/lua_Form.cpp
  27. 3 2
      gameplay/src/lua/lua_Form.h
  28. 120 0
      gameplay/src/lua/lua_Global.cpp
  29. 2 0
      gameplay/src/lua/lua_Global.h
  30. 26 28
      gameplay/src/lua/lua_ImageControl.cpp
  31. 2 2
      gameplay/src/lua/lua_ImageControl.h
  32. 26 28
      gameplay/src/lua/lua_Joint.cpp
  33. 2 2
      gameplay/src/lua/lua_Joint.h
  34. 26 28
      gameplay/src/lua/lua_JoystickControl.cpp
  35. 2 2
      gameplay/src/lua/lua_JoystickControl.h
  36. 26 28
      gameplay/src/lua/lua_Label.cpp
  37. 2 2
      gameplay/src/lua/lua_Label.h
  38. 26 28
      gameplay/src/lua/lua_Node.cpp
  39. 2 2
      gameplay/src/lua/lua_Node.h
  40. 26 28
      gameplay/src/lua/lua_PhysicsController.cpp
  41. 2 2
      gameplay/src/lua/lua_PhysicsController.h
  42. 26 28
      gameplay/src/lua/lua_RadioButton.cpp
  43. 2 2
      gameplay/src/lua/lua_RadioButton.h
  44. 115 7
      gameplay/src/lua/lua_ScriptController.cpp
  45. 2 0
      gameplay/src/lua/lua_ScriptController.h
  46. 26 28
      gameplay/src/lua/lua_ScriptTarget.cpp
  47. 2 2
      gameplay/src/lua/lua_ScriptTarget.h
  48. 197 0
      gameplay/src/lua/lua_ScriptTargetEventRegistryEvent.cpp
  49. 18 0
      gameplay/src/lua/lua_ScriptTargetEventRegistryEvent.h
  50. 26 28
      gameplay/src/lua/lua_Slider.cpp
  51. 2 2
      gameplay/src/lua/lua_Slider.h
  52. 26 28
      gameplay/src/lua/lua_TextBox.cpp
  53. 2 2
      gameplay/src/lua/lua_TextBox.h
  54. 22 1
      gameplay/src/lua/lua_Touch.cpp
  55. 1 0
      gameplay/src/lua/lua_Touch.h
  56. 26 28
      gameplay/src/lua/lua_Transform.cpp
  57. 2 2
      gameplay/src/lua/lua_Transform.h
  58. 1 0
      gameplay/src/lua/lua_all_bindings.cpp
  59. 1 0
      gameplay/src/lua/lua_all_bindings.h

+ 4 - 0
gameplay/gameplay.vcxproj

@@ -93,6 +93,7 @@
     <ClCompile Include="src\lua\lua_CameraType.cpp" />
     <ClCompile Include="src\lua\lua_CameraType.cpp" />
     <ClCompile Include="src\lua\lua_CheckBox.cpp" />
     <ClCompile Include="src\lua\lua_CheckBox.cpp" />
     <ClCompile Include="src\lua\lua_Container.cpp" />
     <ClCompile Include="src\lua\lua_Container.cpp" />
+    <ClCompile Include="src\lua\lua_ContainerDirection.cpp" />
     <ClCompile Include="src\lua\lua_ContainerScroll.cpp" />
     <ClCompile Include="src\lua\lua_ContainerScroll.cpp" />
     <ClCompile Include="src\lua\lua_Control.cpp" />
     <ClCompile Include="src\lua\lua_Control.cpp" />
     <ClCompile Include="src\lua\lua_ControlAlignment.cpp" />
     <ClCompile Include="src\lua\lua_ControlAlignment.cpp" />
@@ -207,6 +208,7 @@
     <ClCompile Include="src\lua\lua_ScreenDisplayer.cpp" />
     <ClCompile Include="src\lua\lua_ScreenDisplayer.cpp" />
     <ClCompile Include="src\lua\lua_ScriptController.cpp" />
     <ClCompile Include="src\lua\lua_ScriptController.cpp" />
     <ClCompile Include="src\lua\lua_ScriptTarget.cpp" />
     <ClCompile Include="src\lua\lua_ScriptTarget.cpp" />
+    <ClCompile Include="src\lua\lua_ScriptTargetEventRegistryEvent.cpp" />
     <ClCompile Include="src\lua\lua_Slider.cpp" />
     <ClCompile Include="src\lua\lua_Slider.cpp" />
     <ClCompile Include="src\lua\lua_SpriteBatch.cpp" />
     <ClCompile Include="src\lua\lua_SpriteBatch.cpp" />
     <ClCompile Include="src\lua\lua_Technique.cpp" />
     <ClCompile Include="src\lua\lua_Technique.cpp" />
@@ -380,6 +382,7 @@
     <ClInclude Include="src\lua\lua_CameraType.h" />
     <ClInclude Include="src\lua\lua_CameraType.h" />
     <ClInclude Include="src\lua\lua_CheckBox.h" />
     <ClInclude Include="src\lua\lua_CheckBox.h" />
     <ClInclude Include="src\lua\lua_Container.h" />
     <ClInclude Include="src\lua\lua_Container.h" />
+    <ClInclude Include="src\lua\lua_ContainerDirection.h" />
     <ClInclude Include="src\lua\lua_ContainerScroll.h" />
     <ClInclude Include="src\lua\lua_ContainerScroll.h" />
     <ClInclude Include="src\lua\lua_Control.h" />
     <ClInclude Include="src\lua\lua_Control.h" />
     <ClInclude Include="src\lua\lua_ControlAlignment.h" />
     <ClInclude Include="src\lua\lua_ControlAlignment.h" />
@@ -494,6 +497,7 @@
     <ClInclude Include="src\lua\lua_ScreenDisplayer.h" />
     <ClInclude Include="src\lua\lua_ScreenDisplayer.h" />
     <ClInclude Include="src\lua\lua_ScriptController.h" />
     <ClInclude Include="src\lua\lua_ScriptController.h" />
     <ClInclude Include="src\lua\lua_ScriptTarget.h" />
     <ClInclude Include="src\lua\lua_ScriptTarget.h" />
+    <ClInclude Include="src\lua\lua_ScriptTargetEventRegistryEvent.h" />
     <ClInclude Include="src\lua\lua_Slider.h" />
     <ClInclude Include="src\lua\lua_Slider.h" />
     <ClInclude Include="src\lua\lua_SpriteBatch.h" />
     <ClInclude Include="src\lua\lua_SpriteBatch.h" />
     <ClInclude Include="src\lua\lua_Technique.h" />
     <ClInclude Include="src\lua\lua_Technique.h" />

+ 12 - 0
gameplay/gameplay.vcxproj.filters

@@ -873,6 +873,12 @@
     <ClCompile Include="src\lua\lua_JoystickControl.cpp">
     <ClCompile Include="src\lua\lua_JoystickControl.cpp">
       <Filter>src\lua</Filter>
       <Filter>src\lua</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="src\lua\lua_ScriptTargetEventRegistryEvent.cpp">
+      <Filter>src\lua</Filter>
+    </ClCompile>
+    <ClCompile Include="src\lua\lua_ContainerDirection.cpp">
+      <Filter>src\lua</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClInclude Include="src\Plane.h">
     <ClInclude Include="src\Plane.h">
@@ -1733,6 +1739,12 @@
     <ClInclude Include="src\lua\lua_JoystickControl.h">
     <ClInclude Include="src\lua\lua_JoystickControl.h">
       <Filter>src\lua</Filter>
       <Filter>src\lua</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="src\lua\lua_ScriptTargetEventRegistryEvent.h">
+      <Filter>src\lua</Filter>
+    </ClInclude>
+    <ClInclude Include="src\lua\lua_ContainerDirection.h">
+      <Filter>src\lua</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <None Include="src\ScriptController.inl">
     <None Include="src\ScriptController.inl">

+ 1 - 1
gameplay/src/AIAgent.cpp

@@ -10,7 +10,7 @@ AIAgent::AIAgent()
 {
 {
     _stateMachine = new AIStateMachine(this);
     _stateMachine = new AIStateMachine(this);
 
 
-    addScriptEvent("message", "<AIMessage>");
+    registerScriptEvent("message", "<AIMessage>");
 }
 }
 
 
 AIAgent::~AIAgent()
 AIAgent::~AIAgent()

+ 2 - 2
gameplay/src/Control.cpp

@@ -237,8 +237,8 @@ void Control::initialize(const char* typeName, Theme::Style* style, Properties*
 		}
 		}
 
 
 		// Register script listeners for control events
 		// Register script listeners for control events
-		if (properties->exists("listener"))
-			addScriptCallback("controlEvent", properties->getString("listener"));
+		if (properties->exists("script"))
+			addScript(properties->getString("script"));
 
 
 		// Potentially override themed properties for all states.
 		// Potentially override themed properties for all states.
 		overrideThemedProperties(properties, STATE_ALL);
 		overrideThemedProperties(properties, STATE_ALL);

+ 7 - 0
gameplay/src/Node.cpp

@@ -19,11 +19,16 @@
 namespace gameplay
 namespace gameplay
 {
 {
 
 
+GP_SCRIPT_EVENTS();
+GP_SCRIPT_EVENT(update, "f");
+
 Node::Node(const char* id)
 Node::Node(const char* id)
     : _scene(NULL), _firstChild(NULL), _nextSibling(NULL), _prevSibling(NULL), _parent(NULL), _childCount(0), _active(true),
     : _scene(NULL), _firstChild(NULL), _nextSibling(NULL), _prevSibling(NULL), _parent(NULL), _childCount(0), _active(true),
     _tags(NULL), _camera(NULL), _light(NULL), _model(NULL), _terrain(NULL), _form(NULL), _audioSource(NULL), _particleEmitter(NULL),
     _tags(NULL), _camera(NULL), _light(NULL), _model(NULL), _terrain(NULL), _form(NULL), _audioSource(NULL), _particleEmitter(NULL),
     _collisionObject(NULL), _agent(NULL), _dirtyBits(NODE_DIRTY_ALL), _notifyHierarchyChanged(true), _userData(NULL)
     _collisionObject(NULL), _agent(NULL), _dirtyBits(NODE_DIRTY_ALL), _notifyHierarchyChanged(true), _userData(NULL)
 {
 {
+    GP_REGISTER_SCRIPT_EVENTS();
+
     if (id)
     if (id)
     {
     {
         _id = id;
         _id = id;
@@ -444,6 +449,8 @@ void Node::update(float elapsedTime)
         if (node->isActive())
         if (node->isActive())
             node->update(elapsedTime);
             node->update(elapsedTime);
     }
     }
+
+    fireScriptEvent<void>(SCRIPT_EVENT_update, elapsedTime);
 }
 }
 
 
 bool Node::isStatic() const
 bool Node::isStatic() const

+ 227 - 98
gameplay/src/ScriptController.cpp

@@ -42,9 +42,9 @@
     \
     \
     return arr
     return arr
 
 
-#define PUSH_NESTED_VARIABLE(name, defaultValue) \
+#define PUSH_NESTED_VARIABLE(name, defaultValue, script) \
     int top = lua_gettop(_lua); \
     int top = lua_gettop(_lua); \
-    if (!getNestedVariable(_lua, (name))) \
+    if (!getNestedVariable(_lua, name, script)) \
     { \
     { \
         lua_settop(_lua, top); \
         lua_settop(_lua, top); \
         return (defaultValue); \
         return (defaultValue); \
@@ -53,28 +53,42 @@
 #define POP_NESTED_VARIABLE() \
 #define POP_NESTED_VARIABLE() \
     lua_settop(_lua, top)
     lua_settop(_lua, top)
 
 
+namespace gameplay
+{
+
+extern void splitURL(const std::string& url, std::string* file, std::string* id);
+
 /**
 /**
- * Pushes onto the stack, the value of the global 'name' or the nested table value if 'name' is a '.' separated 
+ * Pushes onto the stack, the value of the variable 'name' or the nested table value if 'name' is a '.' separated 
  * list of tables of the form "A.B.C.D", where A, B and C are tables and D is a variable name in the table C.
  * list of tables of the form "A.B.C.D", where A, B and C are tables and D is a variable name in the table C.
  * 
  * 
- * If 'name' does not contain any '.' then it is assumed to be the name of a global variable.
- * 
  * This function will not restore the stack if there is an error.
  * This function will not restore the stack if there is an error.
  * 
  * 
  * @param lua  The Lua state.
  * @param lua  The Lua state.
- * @param name The name of a global variable or a '.' separated list of nested tables ending with a variable name.
+ * @param name The name of a variable or a '.' separated list of nested tables ending with a variable name.
  *             The name value may be in the format "A.B.C.D" where A is a table and B, C are child tables.
  *             The name value may be in the format "A.B.C.D" where A is a table and B, C are child tables.
  *             D is any type, which will be accessed by the calling function.
  *             D is any type, which will be accessed by the calling function.
+ * @param script Optional ID of the script environment to query the variable from (or zero for the global environment).
  * 
  * 
- * @return True if the tables were pushed on the stack or the global variable was pushed. Returns false on error.
+ * @return True if the tables were pushed on the stack or the variable was pushed. Returns false on error.
  */
  */
-static bool getNestedVariable(lua_State* lua, const char* name)
+static bool getNestedVariable(lua_State* lua, const char* name, int script = 0)
 {
 {
     if (strchr(name, '.') == NULL)
     if (strchr(name, '.') == NULL)
     {
     {
-        lua_getglobal(lua, name);
+        // Just a field name, no nested tables
+        if (script)
+        {
+            lua_rawgeti(lua, LUA_REGISTRYINDEX, script);
+            lua_getfield(lua, -1, name);
+        }
+        else
+        {
+            lua_getglobal(lua, name);
+        }
         return true;
         return true;
     }
     }
+
     static std::string str;
     static std::string str;
     // Copy the input string to a std::string so we can modify it because 
     // Copy the input string to a std::string so we can modify it because 
     // some of the Lua functions require NULL terminated c-strings.
     // some of the Lua functions require NULL terminated c-strings.
@@ -89,12 +103,23 @@ static bool getNestedVariable(lua_State* lua, const char* name)
     }
     }
     ++end;
     ++end;
     *(end - 1) = '\0';
     *(end - 1) = '\0';
-    lua_getglobal(lua, start);
+
+    if (script)
+    {
+        lua_rawgeti(lua, LUA_REGISTRYINDEX, script);
+        lua_getfield(lua, -1, start);
+    }
+    else
+    {
+        lua_getglobal(lua, start);
+    }
     *(end - 1) = '.';
     *(end - 1) = '.';
+
     if (!lua_istable(lua, -1))
     if (!lua_istable(lua, -1))
     {
     {
         return false;
         return false;
     }
     }
+
     // Push the nested tables
     // Push the nested tables
     for (;;)
     for (;;)
     {
     {
@@ -128,11 +153,6 @@ static bool getNestedVariable(lua_State* lua, const char* name)
     return false;
     return false;
 }
 }
 
 
-namespace gameplay
-{
-
-extern void splitURL(const std::string& url, std::string* file, std::string* id);
-
 void ScriptUtil::registerLibrary(const char* name, const luaL_Reg* functions)
 void ScriptUtil::registerLibrary(const char* name, const luaL_Reg* functions)
 {
 {
     ScriptController* sc = Game::getInstance()->getScriptController();
     ScriptController* sc = Game::getInstance()->getScriptController();
@@ -521,9 +541,13 @@ int ScriptController::loadScriptIsolated(const char* path)
     return id;
     return id;
 }
 }
 
 
-bool ScriptController::unloadScript(int id)
+void ScriptController::unloadScript(int id)
 {
 {
-    // TODO
+    // Release the reference to the environment table
+    luaL_unref(_lua, LUA_REGISTRYINDEX, id);
+
+    // TODO: What else do we need to clean up?
+    // Can we test this with manual GC and breaking on gameplay object constructors that were delcared local (even global??) to the script?
 }
 }
 
 
 std::string ScriptController::loadUrl(const char* url, int* scriptId)
 std::string ScriptController::loadUrl(const char* url, int* scriptId)
@@ -566,172 +590,284 @@ void ScriptController::parseUrl(const char* url, std::string* script, std::strin
     }
     }
 }
 }
 
 
-bool ScriptController::getBool(const char* name, bool defaultValue)
+bool ScriptController::getBool(const char* name, bool defaultValue, int script)
 {
 {
-    PUSH_NESTED_VARIABLE(name, defaultValue);
+    PUSH_NESTED_VARIABLE(name, defaultValue, script);
     bool b = lua_isboolean(_lua, -1) ? ScriptUtil::luaCheckBool(_lua, -1) : defaultValue;
     bool b = lua_isboolean(_lua, -1) ? ScriptUtil::luaCheckBool(_lua, -1) : defaultValue;
     POP_NESTED_VARIABLE();
     POP_NESTED_VARIABLE();
     return b;
     return b;
 }
 }
 
 
-char ScriptController::getChar(const char* name, char defaultValue)
+char ScriptController::getChar(const char* name, char defaultValue, int script)
 {
 {
-    PUSH_NESTED_VARIABLE(name, defaultValue);
+    PUSH_NESTED_VARIABLE(name, defaultValue, script);
     char c = lua_isnumber(_lua, -1) ?  (char)luaL_checkint(_lua, -1) : defaultValue;
     char c = lua_isnumber(_lua, -1) ?  (char)luaL_checkint(_lua, -1) : defaultValue;
     POP_NESTED_VARIABLE();
     POP_NESTED_VARIABLE();
     return c;
     return c;
 }
 }
 
 
-short ScriptController::getShort(const char* name, short defaultValue)
+short ScriptController::getShort(const char* name, short defaultValue, int script)
 {
 {
-    PUSH_NESTED_VARIABLE(name, defaultValue);
+    PUSH_NESTED_VARIABLE(name, defaultValue, script);
     short n = lua_isnumber(_lua, -1) ? (short)luaL_checkint(_lua, -1) : defaultValue;
     short n = lua_isnumber(_lua, -1) ? (short)luaL_checkint(_lua, -1) : defaultValue;
     POP_NESTED_VARIABLE();
     POP_NESTED_VARIABLE();
     return n;
     return n;
 }
 }
 
 
-int ScriptController::getInt(const char* name, int defaultValue)
+int ScriptController::getInt(const char* name, int defaultValue, int script)
 {
 {
-    PUSH_NESTED_VARIABLE(name, defaultValue);
+    PUSH_NESTED_VARIABLE(name, defaultValue, script);
     int n = lua_isnumber(_lua, -1) ? luaL_checkint(_lua, -1) : defaultValue;
     int n = lua_isnumber(_lua, -1) ? luaL_checkint(_lua, -1) : defaultValue;
     POP_NESTED_VARIABLE();
     POP_NESTED_VARIABLE();
     return n;
     return n;
 }
 }
 
 
-long ScriptController::getLong(const char* name, long defaultValue)
+long ScriptController::getLong(const char* name, long defaultValue, int script)
 {
 {
-    PUSH_NESTED_VARIABLE(name, defaultValue);
+    PUSH_NESTED_VARIABLE(name, defaultValue, script);
     long n = lua_isnumber(_lua, -1) ? luaL_checklong(_lua, -1) : defaultValue;
     long n = lua_isnumber(_lua, -1) ? luaL_checklong(_lua, -1) : defaultValue;
     POP_NESTED_VARIABLE();
     POP_NESTED_VARIABLE();
     return n;
     return n;
 }
 }
 
 
-unsigned char ScriptController::getUnsignedChar(const char* name, unsigned char defaultValue)
+unsigned char ScriptController::getUnsignedChar(const char* name, unsigned char defaultValue, int script)
 {
 {
-    PUSH_NESTED_VARIABLE(name, defaultValue);
+    PUSH_NESTED_VARIABLE(name, defaultValue, script);
     unsigned char c = lua_isnumber(_lua, -1) ? (unsigned char)luaL_checkunsigned(_lua, -1) : defaultValue;
     unsigned char c = lua_isnumber(_lua, -1) ? (unsigned char)luaL_checkunsigned(_lua, -1) : defaultValue;
     POP_NESTED_VARIABLE();
     POP_NESTED_VARIABLE();
     return c;
     return c;
 }
 }
 
 
-unsigned short ScriptController::getUnsignedShort(const char* name, unsigned short defaultValue)
+unsigned short ScriptController::getUnsignedShort(const char* name, unsigned short defaultValue, int script)
 {
 {
-    PUSH_NESTED_VARIABLE(name, defaultValue);
+    PUSH_NESTED_VARIABLE(name, defaultValue, script);
     unsigned short n = lua_isnumber(_lua, -1) ? (unsigned short)luaL_checkunsigned(_lua, -1) : defaultValue;
     unsigned short n = lua_isnumber(_lua, -1) ? (unsigned short)luaL_checkunsigned(_lua, -1) : defaultValue;
     POP_NESTED_VARIABLE();
     POP_NESTED_VARIABLE();
     return n;
     return n;
 }
 }
 
 
-unsigned int ScriptController::getUnsignedInt(const char* name, unsigned int defaultValue)
+unsigned int ScriptController::getUnsignedInt(const char* name, unsigned int defaultValue, int script)
 {
 {
-    PUSH_NESTED_VARIABLE(name, defaultValue);
+    PUSH_NESTED_VARIABLE(name, defaultValue, script);
     unsigned int n = lua_isnumber(_lua, -1) ? (unsigned int)luaL_checkunsigned(_lua, -1) : defaultValue;
     unsigned int n = lua_isnumber(_lua, -1) ? (unsigned int)luaL_checkunsigned(_lua, -1) : defaultValue;
     POP_NESTED_VARIABLE();
     POP_NESTED_VARIABLE();
     return n;
     return n;
 }
 }
 
 
-unsigned long ScriptController::getUnsignedLong(const char* name, unsigned long defaultValue)
+unsigned long ScriptController::getUnsignedLong(const char* name, unsigned long defaultValue, int script)
 {
 {
-    PUSH_NESTED_VARIABLE(name, defaultValue);
+    PUSH_NESTED_VARIABLE(name, defaultValue, script);
     unsigned long n = lua_isnumber(_lua, -1) ? (unsigned long)luaL_checkunsigned(_lua, -1) : defaultValue;
     unsigned long n = lua_isnumber(_lua, -1) ? (unsigned long)luaL_checkunsigned(_lua, -1) : defaultValue;
     POP_NESTED_VARIABLE();
     POP_NESTED_VARIABLE();
     return n;
     return n;
 }
 }
 
 
-float ScriptController::getFloat(const char* name, float defaultValue)
+float ScriptController::getFloat(const char* name, float defaultValue, int script)
 {
 {
-    PUSH_NESTED_VARIABLE(name, defaultValue);
+    PUSH_NESTED_VARIABLE(name, defaultValue, script);
     float f = lua_isnumber(_lua, -1) ? (float)luaL_checknumber(_lua, -1) : defaultValue;
     float f = lua_isnumber(_lua, -1) ? (float)luaL_checknumber(_lua, -1) : defaultValue;
     POP_NESTED_VARIABLE();
     POP_NESTED_VARIABLE();
     return f;
     return f;
 }
 }
 
 
-double ScriptController::getDouble(const char* name, double defaultValue)
+double ScriptController::getDouble(const char* name, double defaultValue, int script)
 {
 {
-    PUSH_NESTED_VARIABLE(name, defaultValue);
+    PUSH_NESTED_VARIABLE(name, defaultValue, script);
     double n = lua_isnumber(_lua, -1) ? (double)luaL_checknumber(_lua, -1) : defaultValue;
     double n = lua_isnumber(_lua, -1) ? (double)luaL_checknumber(_lua, -1) : defaultValue;
     POP_NESTED_VARIABLE();
     POP_NESTED_VARIABLE();
     return n;
     return n;
 }
 }
 
 
-const char* ScriptController::getString(const char* name)
+const char* ScriptController::getString(const char* name, int script)
 {
 {
-    PUSH_NESTED_VARIABLE(name, NULL);
+    PUSH_NESTED_VARIABLE(name, NULL, script);
     const char* s = lua_isstring(_lua, -1) ? luaL_checkstring(_lua, -1) : NULL;
     const char* s = lua_isstring(_lua, -1) ? luaL_checkstring(_lua, -1) : NULL;
     POP_NESTED_VARIABLE();
     POP_NESTED_VARIABLE();
     return s;
     return s;
 }
 }
 
 
-void ScriptController::setBool(const char* name, bool v)
+void ScriptController::setBool(const char* name, bool v, int script)
 {
 {
-    lua_pushboolean(_lua, v);
-    lua_setglobal(_lua, name);
+    // TODO: Support setting variables in nested tables. Should just need to execute code similar to
+    // that in getNestedVariable, except we only need to push the parent tables onto the stack,
+    // NOT the actual field/variable (since we're going to set it).
+
+    if (script)
+    {
+        lua_rawgeti(_lua, LUA_REGISTRYINDEX, script);
+        lua_pushboolean(_lua, v);
+        lua_setfield(_lua, -2, name);
+    }
+    else
+    {
+        lua_pushboolean(_lua, v);
+        lua_setglobal(_lua, name);
+    }
 }
 }
 
 
-void ScriptController::setChar(const char* name, char v)
+void ScriptController::setChar(const char* name, char v, int script)
 {
 {
-    lua_pushinteger(_lua, v);
-    lua_setglobal(_lua, name);
+    if (script)
+    {
+        lua_rawgeti(_lua, LUA_REGISTRYINDEX, script);
+        lua_pushinteger(_lua, v);
+        lua_setfield(_lua, -2, name);
+    }
+    else
+    {
+        lua_pushinteger(_lua, v);
+        lua_setglobal(_lua, name);
+    }
 }
 }
 
 
-void ScriptController::setShort(const char* name, short v)
+void ScriptController::setShort(const char* name, short v, int script)
 {
 {
-    lua_pushinteger(_lua, v);
-    lua_setglobal(_lua, name);
+    if (script)
+    {
+        lua_rawgeti(_lua, LUA_REGISTRYINDEX, script);
+        lua_pushinteger(_lua, v);
+        lua_setfield(_lua, -2, name);
+    }
+    else
+    {
+        lua_pushinteger(_lua, v);
+        lua_setglobal(_lua, name);
+    }
 }
 }
 
 
-void ScriptController::setInt(const char* name, int v)
+void ScriptController::setInt(const char* name, int v, int script)
 {
 {
-    lua_pushinteger(_lua, v);
-    lua_setglobal(_lua, name);
+    if (script)
+    {
+        lua_rawgeti(_lua, LUA_REGISTRYINDEX, script);
+        lua_pushinteger(_lua, v);
+        lua_setfield(_lua, -2, name);
+    }
+    else
+    {
+        lua_pushinteger(_lua, v);
+        lua_setglobal(_lua, name);
+    }
 }
 }
 
 
-void ScriptController::setLong(const char* name, long v)
+void ScriptController::setLong(const char* name, long v, int script)
 {
 {
-    lua_pushinteger(_lua, v);
-    lua_setglobal(_lua, name);
+    if (script)
+    {
+        lua_rawgeti(_lua, LUA_REGISTRYINDEX, script);
+        lua_pushinteger(_lua, v);
+        lua_setfield(_lua, -2, name);
+    }
+    else
+    {
+        lua_pushinteger(_lua, v);
+        lua_setglobal(_lua, name);
+    }
 }
 }
 
 
-void ScriptController::setUnsignedChar(const char* name, unsigned char v)
+void ScriptController::setUnsignedChar(const char* name, unsigned char v, int script)
 {
 {
-    lua_pushunsigned(_lua, v);
-    lua_setglobal(_lua, name);
+    if (script)
+    {
+        lua_rawgeti(_lua, LUA_REGISTRYINDEX, script);
+        lua_pushunsigned(_lua, v);
+        lua_setfield(_lua, -2, name);
+    }
+    else
+    {
+        lua_pushunsigned(_lua, v);
+        lua_setglobal(_lua, name);
+    }
 }
 }
 
 
-void ScriptController::setUnsignedShort(const char* name, unsigned short v)
+void ScriptController::setUnsignedShort(const char* name, unsigned short v, int script)
 {
 {
-    lua_pushunsigned(_lua, v);
-    lua_setglobal(_lua, name);
+    if (script)
+    {
+        lua_rawgeti(_lua, LUA_REGISTRYINDEX, script);
+        lua_pushunsigned(_lua, v);
+        lua_setfield(_lua, -2, name);
+    }
+    else
+    {
+        lua_pushunsigned(_lua, v);
+        lua_setglobal(_lua, name);
+    }
 }
 }
 
 
-void ScriptController::setUnsignedInt(const char* name, unsigned int v)
+void ScriptController::setUnsignedInt(const char* name, unsigned int v, int script)
 {
 {
-    lua_pushunsigned(_lua, v);
-    lua_setglobal(_lua, name);
+    if (script)
+    {
+        lua_rawgeti(_lua, LUA_REGISTRYINDEX, script);
+        lua_pushunsigned(_lua, v);
+        lua_setfield(_lua, -2, name);
+    }
+    else
+    {
+        lua_pushunsigned(_lua, v);
+        lua_setglobal(_lua, name);
+    }
 }
 }
 
 
-void ScriptController::setUnsignedLong(const char* name, unsigned long v)
+void ScriptController::setUnsignedLong(const char* name, unsigned long v, int script)
 {
 {
-    lua_pushunsigned(_lua, v);
-    lua_setglobal(_lua, name);
+    if (script)
+    {
+        lua_rawgeti(_lua, LUA_REGISTRYINDEX, script);
+        lua_pushunsigned(_lua, v);
+        lua_setfield(_lua, -2, name);
+    }
+    else
+    {
+        lua_pushunsigned(_lua, v);
+        lua_setglobal(_lua, name);
+    }
 }
 }
 
 
-void ScriptController::setFloat(const char* name, float v)
+void ScriptController::setFloat(const char* name, float v, int script)
 {
 {
-    lua_pushnumber(_lua, v);
-    lua_setglobal(_lua, name);
+    if (script)
+    {
+        lua_rawgeti(_lua, LUA_REGISTRYINDEX, script);
+        lua_pushnumber(_lua, v);
+        lua_setfield(_lua, -2, name);
+    }
+    else
+    {
+        lua_pushnumber(_lua, v);
+        lua_setglobal(_lua, name);
+    }
 }
 }
 
 
-void ScriptController::setDouble(const char* name, double v)
+void ScriptController::setDouble(const char* name, double v, int script)
 {
 {
-    lua_pushnumber(_lua, v);
-    lua_setglobal(_lua, name);
+    if (script)
+    {
+        lua_rawgeti(_lua, LUA_REGISTRYINDEX, script);
+        lua_pushnumber(_lua, v);
+        lua_setfield(_lua, -2, name);
+    }
+    else
+    {
+        lua_pushnumber(_lua, v);
+        lua_setglobal(_lua, name);
+    }
 }
 }
 
 
-void ScriptController::setString(const char* name, const char* v)
+void ScriptController::setString(const char* name, const char* v, int script)
 {
 {
-    lua_pushstring(_lua, v);
-    lua_setglobal(_lua, name);
+    if (script)
+    {
+        lua_rawgeti(_lua, LUA_REGISTRYINDEX, script);
+        lua_pushstring(_lua, v);
+        lua_setfield(_lua, -2, name);
+    }
+    else
+    {
+        lua_pushstring(_lua, v);
+        lua_setglobal(_lua, name);
+    }
 }
 }
 
 
 void ScriptController::print(const char* str)
 void ScriptController::print(const char* str)
@@ -979,14 +1115,7 @@ void ScriptController::executeFunctionHelper(int resultCount, const char* func,
         return;
         return;
     }
     }
 
 
-    // If this function is being executed for a specific (non-global) script environment,
-    // push the script environment table ref onto the stack
-    if (script > 0)
-    {
-        lua_rawgeti(_lua, LUA_REGISTRYINDEX, script);
-    }
-
-    if (!getNestedVariable(_lua, func))
+    if (!getNestedVariable(_lua, func, script))
     {
     {
         GP_WARN("Failed to call function '%s'", func);
         GP_WARN("Failed to call function '%s'", func);
         return;
         return;
@@ -1219,7 +1348,7 @@ int ScriptController::convert(lua_State* state)
 
 
 #define SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(type, checkfunc) \
 #define SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(type, checkfunc) \
     int top = lua_gettop(_lua); \
     int top = lua_gettop(_lua); \
-    executeFunctionHelper(1, func, args, list); \
+    executeFunctionHelper(1, func, args, list, script); \
     type value = (type)checkfunc(_lua, -1); \
     type value = (type)checkfunc(_lua, -1); \
     lua_pop(_lua, -1); \
     lua_pop(_lua, -1); \
     lua_settop(_lua, top); \
     lua_settop(_lua, top); \
@@ -1384,73 +1513,73 @@ template<> void ScriptController::executeFunction<void>(const char* func, const
 /** Template specialization. */
 /** Template specialization. */
 template<> bool ScriptController::executeFunction<bool>(const char* func, const char* args, va_list* list, int script)
 template<> bool ScriptController::executeFunction<bool>(const char* func, const char* args, va_list* list, int script)
 {
 {
-    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(bool, ScriptUtil::luaCheckBool, script);
+    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(bool, ScriptUtil::luaCheckBool);
 }
 }
 
 
 /** Template specialization. */
 /** Template specialization. */
 template<> char ScriptController::executeFunction<char>(const char* func, const char* args, va_list* list, int script)
 template<> char ScriptController::executeFunction<char>(const char* func, const char* args, va_list* list, int script)
 {
 {
-    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(char, luaL_checkint, script);
+    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(char, luaL_checkint);
 }
 }
 
 
 /** Template specialization. */
 /** Template specialization. */
 template<> short ScriptController::executeFunction<short>(const char* func, const char* args, va_list* list, int script)
 template<> short ScriptController::executeFunction<short>(const char* func, const char* args, va_list* list, int script)
 {
 {
-    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(short, luaL_checkint, script);
+    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(short, luaL_checkint);
 }
 }
 
 
 /** Template specialization. */
 /** Template specialization. */
 template<> int ScriptController::executeFunction<int>(const char* func, const char* args, va_list* list, int script)
 template<> int ScriptController::executeFunction<int>(const char* func, const char* args, va_list* list, int script)
 {
 {
-    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(int, luaL_checkint, script);
+    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(int, luaL_checkint);
 }
 }
 
 
 /** Template specialization. */
 /** Template specialization. */
 template<> long ScriptController::executeFunction<long>(const char* func, const char* args, va_list* list, int script)
 template<> long ScriptController::executeFunction<long>(const char* func, const char* args, va_list* list, int script)
 {
 {
-    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(long, luaL_checklong, script);
+    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(long, luaL_checklong);
 }
 }
 
 
 /** Template specialization. */
 /** Template specialization. */
 template<> unsigned char ScriptController::executeFunction<unsigned char>(const char* func, const char* args, va_list* list, int script)
 template<> unsigned char ScriptController::executeFunction<unsigned char>(const char* func, const char* args, va_list* list, int script)
 {
 {
-    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(unsigned char, luaL_checkunsigned, script);
+    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(unsigned char, luaL_checkunsigned);
 }
 }
 
 
 /** Template specialization. */
 /** Template specialization. */
 template<> unsigned short ScriptController::executeFunction<unsigned short>(const char* func, const char* args, va_list* list, int script)
 template<> unsigned short ScriptController::executeFunction<unsigned short>(const char* func, const char* args, va_list* list, int script)
 {
 {
-    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(unsigned short, luaL_checkunsigned, script);
+    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(unsigned short, luaL_checkunsigned);
 }
 }
 
 
 /** Template specialization. */
 /** Template specialization. */
 template<> unsigned int ScriptController::executeFunction<unsigned int>(const char* func, const char* args, va_list* list, int script)
 template<> unsigned int ScriptController::executeFunction<unsigned int>(const char* func, const char* args, va_list* list, int script)
 {
 {
-    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(unsigned int, luaL_checkunsigned, script);
+    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(unsigned int, luaL_checkunsigned);
 }
 }
 
 
 /** Template specialization. */
 /** Template specialization. */
 template<> unsigned long ScriptController::executeFunction<unsigned long>(const char* func, const char* args, va_list* list, int script)
 template<> unsigned long ScriptController::executeFunction<unsigned long>(const char* func, const char* args, va_list* list, int script)
 {
 {
-    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(unsigned long, luaL_checkunsigned, script);
+    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(unsigned long, luaL_checkunsigned);
 }
 }
 
 
 /** Template specialization. */
 /** Template specialization. */
 template<> float ScriptController::executeFunction<float>(const char* func, const char* args, va_list* list, int script)
 template<> float ScriptController::executeFunction<float>(const char* func, const char* args, va_list* list, int script)
 {
 {
-    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(float, luaL_checknumber, script);
+    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(float, luaL_checknumber);
 }
 }
 
 
 /** Template specialization. */
 /** Template specialization. */
 template<> double ScriptController::executeFunction<double>(const char* func, const char* args, va_list* list, int script)
 template<> double ScriptController::executeFunction<double>(const char* func, const char* args, va_list* list, int script)
 {
 {
-    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(double, luaL_checknumber, script);
+    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(double, luaL_checknumber);
 }
 }
 
 
 /** Template specialization. */
 /** Template specialization. */
 template<> std::string ScriptController::executeFunction<std::string>(const char* func, const char* args, va_list* list, int script)
 template<> std::string ScriptController::executeFunction<std::string>(const char* func, const char* args, va_list* list, int script)
 {
 {
-    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(std::string, luaL_checkstring, script);
+    SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(std::string, luaL_checkstring);
 }
 }
 
 
 }
 }

+ 63 - 27
gameplay/src/ScriptController.h

@@ -397,7 +397,7 @@ public:
      *
      *
      * @param id The unique ID of the isolated script, as returned from loadScriptIsolated(const char*).
      * @param id The unique ID of the isolated script, as returned from loadScriptIsolated(const char*).
      */
      */
-    bool unloadScript(int id);
+    void unloadScript(int id);
 
 
     /**
     /**
      * Given a URL, loads the referenced file and returns the referenced function name.
      * Given a URL, loads the referenced file and returns the referenced function name.
@@ -414,6 +414,8 @@ public:
      * @param url Url to parse.
      * @param url Url to parse.
      * @param script Populated with the path of the script, or an empty string if the URL does not include a script.
      * @param script Populated with the path of the script, or an empty string if the URL does not include a script.
      * @param function Populated with the function name.
      * @param function Populated with the function name.
+     *
+     * @script{ignore}
      */
      */
     void parseUrl(const char* url, std::string* script, std::string* function);
     void parseUrl(const char* url, std::string* script, std::string* function);
 
 
@@ -447,6 +449,8 @@ public:
      * @param func The name of the function to call.
      * @param func The name of the function to call.
      * 
      * 
      * @return The return value of the executed Lua function.
      * @return The return value of the executed Lua function.
+     *
+     * @script{ignore}
      */
      */
     template<typename T> T executeFunction(const char* func);
     template<typename T> T executeFunction(const char* func);
 
 
@@ -472,6 +476,8 @@ public:
      *      - '[enum-type]' - an enumerated value of the given type (where the qualified type name is enclosed by square brackets).
      *      - '[enum-type]' - an enumerated value of the given type (where the qualified type name is enclosed by square brackets).
      * 
      * 
      * @return The return value of the executed Lua function.
      * @return The return value of the executed Lua function.
+     *
+     * @script{ignore}
      */
      */
     template<typename T> T executeFunction(const char* func, const char* args, ...);
     template<typename T> T executeFunction(const char* func, const char* args, ...);
 
 
@@ -499,6 +505,8 @@ public:
      * @param script Optional ID for the script environment of the function to execute, or zero for the default/global environment.
      * @param script Optional ID for the script environment of the function to execute, or zero for the default/global environment.
      *
      *
      * @return The return value of the executed Lua function.
      * @return The return value of the executed Lua function.
+     *
+     * @script{ignore}
      */
      */
     template<typename T> T executeFunction(const char* func, const char* args, va_list* list, int script = 0);
     template<typename T> T executeFunction(const char* func, const char* args, va_list* list, int script = 0);
 
 
@@ -507,143 +515,159 @@ public:
      * 
      * 
      * @param name The name of the variable.
      * @param name The name of the variable.
      * @param defaultValue The default value to return if the variable is not a bool.
      * @param defaultValue The default value to return if the variable is not a bool.
-     * 
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
+     *
      * @return The global boolean script variable.
      * @return The global boolean script variable.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    bool getBool(const char* name, bool defaultValue = false);
+    bool getBool(const char* name, bool defaultValue = false, int script = 0);
 
 
     /**
     /**
      * Gets the global char script variable with the given name.
      * Gets the global char script variable with the given name.
      * 
      * 
      * @param name The name of the variable.
      * @param name The name of the variable.
      * @param defaultValue The default value to return if the variable is not a number.
      * @param defaultValue The default value to return if the variable is not a number.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @return The global char script variable.
      * @return The global char script variable.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    char getChar(const char* name, char defaultValue = 0);
+    char getChar(const char* name, char defaultValue = 0, int script = 0);
 
 
     /**
     /**
      * Gets the global short script variable with the given name.
      * Gets the global short script variable with the given name.
      * 
      * 
      * @param name The name of the variable.
      * @param name The name of the variable.
      * @param defaultValue The default value to return if the variable is not a number.
      * @param defaultValue The default value to return if the variable is not a number.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @return The global short script variable.
      * @return The global short script variable.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    short getShort(const char* name, short defaultValue = 0);
+    short getShort(const char* name, short defaultValue = 0, int script = 0);
 
 
     /**
     /**
      * Gets the global int script variable with the given name.
      * Gets the global int script variable with the given name.
      * 
      * 
      * @param name The name of the variable.
      * @param name The name of the variable.
      * @param defaultValue The default value to return if the variable is not a number.
      * @param defaultValue The default value to return if the variable is not a number.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @return The global int script variable.
      * @return The global int script variable.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    int getInt(const char* name, int defaultValue = 0);
+    int getInt(const char* name, int defaultValue = 0, int script = 0);
 
 
     /**
     /**
      * Gets the global long script variable with the given name.
      * Gets the global long script variable with the given name.
      * 
      * 
      * @param name The name of the variable.
      * @param name The name of the variable.
      * @param defaultValue The default value to return if the variable is not a number.
      * @param defaultValue The default value to return if the variable is not a number.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @return The global long script variable.
      * @return The global long script variable.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    long getLong(const char* name, long defaultValue = 0);
+    long getLong(const char* name, long defaultValue = 0, int script = 0);
 
 
     /**
     /**
      * Gets the global unsigned char script variable with the given name.
      * Gets the global unsigned char script variable with the given name.
      * 
      * 
      * @param name The name of the variable.
      * @param name The name of the variable.
      * @param defaultValue The default value to return if the variable is not a number.
      * @param defaultValue The default value to return if the variable is not a number.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @return The global unsigned char script variable.
      * @return The global unsigned char script variable.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    unsigned char getUnsignedChar(const char* name, unsigned char defaultValue = 0);
+    unsigned char getUnsignedChar(const char* name, unsigned char defaultValue = 0, int script = 0);
 
 
     /**
     /**
      * Gets the global unsigned short script variable with the given name.
      * Gets the global unsigned short script variable with the given name.
      * 
      * 
      * @param name The name of the variable.
      * @param name The name of the variable.
      * @param defaultValue The default value to return if the variable is not a number.
      * @param defaultValue The default value to return if the variable is not a number.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @return The global unsigned short script variable.
      * @return The global unsigned short script variable.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    unsigned short getUnsignedShort(const char* name, unsigned short defaultValue = 0);
+    unsigned short getUnsignedShort(const char* name, unsigned short defaultValue = 0, int script = 0);
 
 
     /**
     /**
      * Gets the global unsigned int script variable with the given name.
      * Gets the global unsigned int script variable with the given name.
      * 
      * 
      * @param name The name of the variable.
      * @param name The name of the variable.
      * @param defaultValue The default value to return if the variable is not a number.
      * @param defaultValue The default value to return if the variable is not a number.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @return The global unsigned int script variable.
      * @return The global unsigned int script variable.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    unsigned int getUnsignedInt(const char* name, unsigned int defaultValue = 0);
+    unsigned int getUnsignedInt(const char* name, unsigned int defaultValue = 0, int script = 0);
 
 
     /**
     /**
      * Gets the global unsigned long script variable with the given name.
      * Gets the global unsigned long script variable with the given name.
      * 
      * 
      * @param name The name of the variable.
      * @param name The name of the variable.
      * @param defaultValue The default value to return if the variable is not a number.
      * @param defaultValue The default value to return if the variable is not a number.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @return The global unsigned long script variable.
      * @return The global unsigned long script variable.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    unsigned long getUnsignedLong(const char* name, unsigned long defaultValue = 0);
+    unsigned long getUnsignedLong(const char* name, unsigned long defaultValue = 0, int script = 0);
 
 
     /**
     /**
      * Gets the global float script variable with the given name.
      * Gets the global float script variable with the given name.
      * 
      * 
      * @param name The name of the variable.
      * @param name The name of the variable.
      * @param defaultValue The default value to return if the variable is not a number.
      * @param defaultValue The default value to return if the variable is not a number.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @return The global float script variable.
      * @return The global float script variable.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    float getFloat(const char* name, float defaultValue = 0);
+    float getFloat(const char* name, float defaultValue = 0, int script = 0);
 
 
     /**
     /**
      * Gets the global double script variable with the given name.
      * Gets the global double script variable with the given name.
      * 
      * 
      * @param name The name of the variable.
      * @param name The name of the variable.
      * @param defaultValue The default value to return if the variable is not a number.
      * @param defaultValue The default value to return if the variable is not a number.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @return The global double script variable.
      * @return The global double script variable.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    double getDouble(const char* name, double defaultValue = 0);
+    double getDouble(const char* name, double defaultValue = 0, int script = 0);
 
 
     /**
     /**
      * Gets the global string variable with the given name.
      * Gets the global string variable with the given name.
-     * 
+     *
+     * The returned character string is temporary and is not gauranteed to live forever, therefore you
+     * should not store a pointer to the returned value. If long-term access to the returned string is
+     * required, it should be copied into another string for storage.
+     *
      * @param name The name of the variable.
      * @param name The name of the variable.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @return The string variable or NULL if the variable is not a string.
      * @return The string variable or NULL if the variable is not a string.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    const char* getString(const char* name);
+    const char* getString(const char* name, int script = 0);
 
 
     /**
     /**
      * Gets the global pointer script variable of the given type with the given name.
      * Gets the global pointer script variable of the given type with the given name.
@@ -662,120 +686,132 @@ public:
      * 
      * 
      * @param name The name of the script variable.
      * @param name The name of the script variable.
      * @param v The boolean value.
      * @param v The boolean value.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    void setBool(const char* name, bool v);
+    void setBool(const char* name, bool v, int script = 0);
 
 
     /**
     /**
      * Sets the global char script variable with the given name to the given value.
      * Sets the global char script variable with the given name to the given value.
      * 
      * 
      * @param name The name of the script variable.
      * @param name The name of the script variable.
      * @param v The char value.
      * @param v The char value.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    void setChar(const char* name, char v);
+    void setChar(const char* name, char v, int script = 0);
 
 
     /**
     /**
      * Sets the global short script variable with the given name to the given value.
      * Sets the global short script variable with the given name to the given value.
      * 
      * 
      * @param name The name of the script variable.
      * @param name The name of the script variable.
      * @param v The short value.
      * @param v The short value.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    void setShort(const char* name, short v);
+    void setShort(const char* name, short v, int script = 0);
 
 
     /**
     /**
      * Sets the global int script variable with the given name to the given value.
      * Sets the global int script variable with the given name to the given value.
      * 
      * 
      * @param name The name of the script variable.
      * @param name The name of the script variable.
      * @param v The int value.
      * @param v The int value.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    void setInt(const char* name, int v);
+    void setInt(const char* name, int v, int script = 0);
 
 
     /**
     /**
      * Sets the global long script variable with the given name to the given value.
      * Sets the global long script variable with the given name to the given value.
      * 
      * 
      * @param name The name of the script variable.
      * @param name The name of the script variable.
      * @param v The long value.
      * @param v The long value.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    void setLong(const char* name, long v);
+    void setLong(const char* name, long v, int script = 0);
 
 
     /**
     /**
      * Gets the global unsigned char script variable with the given name to the given value.
      * Gets the global unsigned char script variable with the given name to the given value.
      * 
      * 
      * @param name The name of the script variable.
      * @param name The name of the script variable.
      * @param v The unsigned char value.
      * @param v The unsigned char value.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    void setUnsignedChar(const char* name, unsigned char v);
+    void setUnsignedChar(const char* name, unsigned char v, int script = 0);
 
 
     /**
     /**
      * Sets the global unsigned short script variable with the given name to the given value.
      * Sets the global unsigned short script variable with the given name to the given value.
      * 
      * 
      * @param name The name of the script variable.
      * @param name The name of the script variable.
      * @param v The unsigned short value.
      * @param v The unsigned short value.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    void setUnsignedShort(const char* name, unsigned short v);
+    void setUnsignedShort(const char* name, unsigned short v, int script = 0);
 
 
     /**
     /**
      * Sets the global unsigned int script variable with the given name to the given value.
      * Sets the global unsigned int script variable with the given name to the given value.
      * 
      * 
      * @param name The name of the script variable.
      * @param name The name of the script variable.
      * @param v The unsigned int value.
      * @param v The unsigned int value.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    void setUnsignedInt(const char* name, unsigned int v);
+    void setUnsignedInt(const char* name, unsigned int v, int script = 0);
 
 
     /**
     /**
      * Sets the global unsigned long script variable with the given name to the given value.
      * Sets the global unsigned long script variable with the given name to the given value.
      * 
      * 
      * @param name The name of the script variable.
      * @param name The name of the script variable.
      * @param v The unsigned long value.
      * @param v The unsigned long value.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    void setUnsignedLong(const char* name, unsigned long v);
+    void setUnsignedLong(const char* name, unsigned long v, int script = 0);
 
 
     /**
     /**
      * Sets the global float script variable with the given name to the given value.
      * Sets the global float script variable with the given name to the given value.
      * 
      * 
      * @param name The name of the script variable.
      * @param name The name of the script variable.
      * @param v The float value.
      * @param v The float value.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    void setFloat(const char* name, float v);
+    void setFloat(const char* name, float v, int script = 0);
 
 
     /**
     /**
      * Sets the global double script variable with the given name to the given value.
      * Sets the global double script variable with the given name to the given value.
      * 
      * 
      * @param name The name of the script variable.
      * @param name The name of the script variable.
      * @param v The double value.
      * @param v The double value.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    void setDouble(const char* name, double v);
+    void setDouble(const char* name, double v, int script = 0);
 
 
     /**
     /**
      * Sets the global string script variable with the given name to the given value.
      * Sets the global string script variable with the given name to the given value.
      * 
      * 
      * @param name The name of the script variable.
      * @param name The name of the script variable.
      * @param v The string value.
      * @param v The string value.
+     * @param script Optional ID for the script environment to use, or zero for the default/global environment.
      * 
      * 
      * @script{ignore}
      * @script{ignore}
      */
      */
-    void setString(const char* name, const char* v);
+    void setString(const char* name, const char* v, int script = 0);
 
 
     /**
     /**
      * Sets the global pointer script variable of the given type with the given name to the given value.
      * Sets the global pointer script variable of the given type with the given name to the given value.

+ 2 - 2
gameplay/src/ScriptController.inl

@@ -290,9 +290,9 @@ template<typename T> T ScriptController::executeFunction(const char* func, const
     return value;
     return value;
 }
 }
 
 
-template<typename T> T ScriptController::executeFunction(const char* func, const char* args, va_list* list)
+template<typename T> T ScriptController::executeFunction(const char* func, const char* args, va_list* list, int script)
 {
 {
-    executeFunctionHelper(1, func, args, list);
+    executeFunctionHelper(1, func, args, list, script);
 
 
     T value = (T)((ScriptUtil::LuaObject*)lua_touserdata(_lua, -1))->instance;
     T value = (T)((ScriptUtil::LuaObject*)lua_touserdata(_lua, -1))->instance;
     lua_pop(_lua, -1);
     lua_pop(_lua, -1);

+ 105 - 110
gameplay/src/ScriptTarget.cpp

@@ -5,20 +5,42 @@
 namespace gameplay
 namespace gameplay
 {
 {
 
 
-extern void splitURL(const std::string& url, std::string* file, std::string* id);
+ScriptTarget::EventRegistry::EventRegistry()
+{
+}
 
 
-ScriptTarget::ScriptTarget() : _scripts(NULL)
+const ScriptTarget::EventRegistry::Event* ScriptTarget::EventRegistry::addEvent(const char* name, const char* args)
 {
 {
+    GP_ASSERT(name);
+
+    Event evt;
+    evt.name = name;
+    evt.args = args ? args : "";
+    evt.registry = this;
+
+    _events.push_back(evt);
+
+    return &_events.back();
 }
 }
 
 
-ScriptTarget::~ScriptTarget()
+unsigned int ScriptTarget::EventRegistry::getEventCount() const
 {
 {
-    std::map<std::string, std::vector<Callback>* >::iterator iter = _callbacks.begin();
-    for (; iter != _callbacks.end(); iter++)
-    {
-        SAFE_DELETE(iter->second);
-    }
+    return _events.size();
+}
 
 
+const ScriptTarget::EventRegistry::Event* ScriptTarget::EventRegistry::getEvent(unsigned int index) const
+{
+    GP_ASSERT(index < _events.size());
+
+    return &_events[index];
+}
+
+ScriptTarget::ScriptTarget() : _scripts(NULL), _events(NULL)
+{
+}
+
+ScriptTarget::~ScriptTarget()
+{
     // Free scripts
     // Free scripts
     Script* script = _scripts;
     Script* script = _scripts;
     while (script)
     while (script)
@@ -29,73 +51,19 @@ ScriptTarget::~ScriptTarget()
         script = script->next;
         script = script->next;
         SAFE_DELETE(script);
         SAFE_DELETE(script);
     }
     }
-}
 
 
-template<> void ScriptTarget::fireScriptEvent<void>(const char* eventName, ...)
-{
-    va_list list;
-    va_start(list, eventName);
-
-    std::map<std::string, std::vector<Callback>* >::iterator iter = _callbacks.find(eventName);
-    if (iter != _callbacks.end() && iter->second != NULL)
-    {
-        ScriptController* sc = Game::getInstance()->getScriptController();
-
-        if (_events[eventName].size() > 0)
-        {
-            for (unsigned int i = 0; i < iter->second->size(); i++)
-            {
-                sc->executeFunction<void>((*iter->second)[i].function.c_str(), _events[eventName].c_str(), &list);
-            }
-        }
-        else
-        {
-            for (unsigned int i = 0; i < iter->second->size(); i++)
-            {
-                sc->executeFunction<void>((*iter->second)[i].function.c_str(), _events[eventName].c_str());
-            }
-        }
-    }
-
-    va_end(list);
+    // Free events (we don't own the EventRegistry pointers, so don't free them)
+    SAFE_DELETE(_events);
 }
 }
 
 
-template<> bool ScriptTarget::fireScriptEvent<bool>(const char* eventName, ...)
+void ScriptTarget::registerEvents(EventRegistry* registry)
 {
 {
-    va_list list;
-    va_start(list, eventName);
-
-    std::map<std::string, std::vector<Callback>* >::iterator iter = _callbacks.find(eventName);
-    if (iter != _callbacks.end() && iter->second)
-    {
-        ScriptController* sc = Game::getInstance()->getScriptController();
+    GP_ASSERT(registry);
 
 
-        if (_events[eventName].size() > 0)
-        {
-            for (unsigned int i = 0; i < iter->second->size(); i++)
-            {
-                if (sc->executeFunction<bool>((*iter->second)[i].function.c_str(), _events[eventName].c_str(), &list))
-                {
-                    va_end(list);
-                    return true;
-                }
-            }
-        }
-        else
-        {
-            for (unsigned int i = 0; i < iter->second->size(); i++)
-            {
-                if (sc->executeFunction<bool>((*iter->second)[i].function.c_str(), _events[eventName].c_str()))
-                {
-                    va_end(list);
-                    return true;
-                }
-            }
-        }
-    }
+    if (!_events)
+        _events = new std::vector<EventRegistry*>();
 
 
-    va_end(list);
-    return false;
+    _events->push_back(registry);
 }
 }
 
 
 int ScriptTarget::addScript(const char* path)
 int ScriptTarget::addScript(const char* path)
@@ -123,64 +91,91 @@ int ScriptTarget::addScript(const char* path)
         _scripts = script;
         _scripts = script;
     }
     }
 
 
-    // Inspect the loaded script for supported event functions
+    // TODO: Inspect the loaded script for supported event functions
 
 
-    std::map<std::string, std::vector<Callback>* >::iterator iter = _callbacks.find(eventName);
-    if (iter != _callbacks.end())
-    {
-        if (!iter->second)
-            iter->second = new std::vector<Callback>();
+    return script->id;
+}
 
 
-        // Add the function to the list of callbacks.
-        std::string functionName = Game::getInstance()->getScriptController()->loadUrl(function.c_str());
-        iter->second->push_back(Callback(functionName));
-    }
-    else
+bool ScriptTarget::removeScript(const char* path)
+{
+    Script* script = _scripts;
+    while (script)
     {
     {
-        GP_ERROR("Attempting to add a script callback for unsupported event '%s'.", eventName.c_str());
+        if (script->path == path)
+        {
+            // Link out this script
+            Script* next = script->next;
+            if (script->prev)
+                script->prev->next = script->next;
+            if (script->next)
+                script->next->prev = script->prev;
+            
+            // Unload the script
+            Game::getInstance()->getScriptController()->unloadScript(script->id);
+
+            // Free the script object
+            SAFE_DELETE(script);
+
+            return true;
+        }
+        script = script->next;
     }
     }
+
+    return false;
 }
 }
 
 
-void ScriptTarget::removeScriptCallback(const std::string& eventName, const std::string& function)
+template<> void ScriptTarget::fireScriptEvent<void>(const EventRegistry::Event* evt, ...)
 {
 {
-    std::map<std::string, std::vector<Callback>* >::iterator iter = _callbacks.find(eventName);
-    if (iter != _callbacks.end())
+    GP_ASSERT(evt);
+
+    va_list list;
+    va_start(list, evt);
+
+    // Fire this event for all scripts that support it
+    Script* script = _scripts;
+    while (script)
     {
     {
-        if (!iter->second)
-            return;
+        // Is there a callback in this script for this event?
+        std::vector<std::string>& callbacks = script->eventCallbacks;
+        std::vector<std::string>::iterator itr = std::find(callbacks.begin(), callbacks.end(), evt->name);
+        if (itr != callbacks.end())
+        {
+            Game::getInstance()->getScriptController()->executeFunction<void>(itr->c_str(), evt->args.c_str(), &list, script->id);
+        }
 
 
-        std::string file;
-        std::string id;
-        splitURL(function, &file, &id);
+        script = script->next;
+    }
 
 
-        // Make sure the function isn't empty.
-        if (id.size() <= 0)
-            return;
+    va_end(list);
+}
 
 
-        // Remove the function from the list of callbacks.
-        for (unsigned int i = 0; i < iter->second->size(); i++)
+template<> bool ScriptTarget::fireScriptEvent<bool>(const EventRegistry::Event* evt, ...)
+{
+    va_list list;
+    va_start(list, evt);
+
+    // Fire this event for all scripts that support it
+    Script* script = _scripts;
+    while (script)
+    {
+        // Is there a callback in this script for this event?
+        std::vector<std::string>& callbacks = script->eventCallbacks;
+        std::vector<std::string>::iterator itr = std::find(callbacks.begin(), callbacks.end(), evt->name);
+        if (itr != callbacks.end())
         {
         {
-            if ((*iter->second)[i].function == id)
+            // Call the script function
+            if (Game::getInstance()->getScriptController()->executeFunction<bool>(itr->c_str(), evt->args.c_str(), &list, script->id))
             {
             {
-                iter->second->erase(iter->second->begin() + i);
-                return;
+                va_end(list);
+                return true;
             }
             }
         }
         }
-    }
-    else
-    {
-        GP_ERROR("Attempting to remove a script callback for unsupported event '%s'.", eventName.c_str());
-    }
-}
 
 
-void ScriptTarget::addScriptEvent(const std::string& eventName, const char* argsString)
-{
-    _events[eventName] = (argsString ? argsString : "");
-    _callbacks[eventName] = NULL;
-}
+        script = script->next;
+    }
 
 
-ScriptTarget::Callback::Callback(const std::string& function) : function(function)
-{
+    va_end(list);
+    return false;
 }
 }
 
 
 }
 }

+ 150 - 30
gameplay/src/ScriptTarget.h

@@ -6,6 +6,46 @@
 namespace gameplay
 namespace gameplay
 {
 {
 
 
+/**
+ * Signals the start of script event declarations for a ScriptTarget implementation.
+ *
+ * This macro should be followed by one or more calls to GP_SCRIPT_EVENT.
+ *
+ * It is recommended that these macros be used at the top of the source file that
+ * contains the implemtation of a ScriptTarget child class.
+ */
+#define GP_SCRIPT_EVENTS() \
+    static gameplay::ScriptTarget::EventRegistry __eventRegistry
+
+/**
+ * Defines a script event of the given name and adds it to the event registry for
+ * the current scope.
+ *
+ * A call to GP_SCRIPT_EVENT_START must exist before any calls to GP_SCRIPT_EVENT
+ * are made. This macro will define a constant in the current code scope that is
+ * named SCRIPT_EVENT_eventName, which should be used when calling 
+ * ScriptTarget::fireScriptEvent from a ScriptTarget child class.  For this reason,
+ * these macros should exist outside the definition of the class, preferably at
+ * the top of the source file.
+ *
+ * @param eventName Name of the event (no quotes).
+ * @param eventArgs Parmeters for this script event.
+ *
+ * @see ScriptController::executeFunction
+ */
+#define GP_SCRIPT_EVENT(eventName, eventArgs) \
+    static const gameplay::ScriptTarget::EventRegistry::Event* SCRIPT_EVENT_ ## eventName = __eventRegistry.addEvent(#eventName, eventArgs)
+
+/**
+ * Registers the defined script events for a ScriptTarget.
+ *
+ * This macro should be called in the constructor of a ScriptTarget
+ * child class implementation. It requires that GP_SCRIPT_EVENT
+ * macros be defined (normally at the top of the compilation unit).
+ */
+#define GP_REGISTER_SCRIPT_EVENTS() \
+    ScriptTarget::registerEvents(&__eventRegistry)
+
 /**
 /**
  * Defines an interface for supporting script callbacks.
  * Defines an interface for supporting script callbacks.
  */
  */
@@ -13,6 +53,79 @@ class ScriptTarget
 {
 {
 public:
 public:
 
 
+    /**
+     * Script event registry that defines the supported script events
+     * for a ScriptTarget.
+     *
+     * This class should generally only be used via the GP_REGISTER_SCRIPT_EVENTS macro.
+     *
+     * @script{ignore}
+     */
+    class EventRegistry
+    {
+    public:
+
+        /**
+         * Defines a single script event.
+         */
+        struct Event
+        {
+            /**
+             * The event name.
+             */
+            std::string name;
+
+            /**
+             * The event arguments.
+             *
+             * @see ScriptController::executeFunction
+             */
+            std::string args;
+
+            /**
+             * The EventRegistry this event belongs to.
+             */
+            EventRegistry* registry;
+        };
+
+        /**
+         * Creates an empty event registry.
+         */
+        EventRegistry();
+
+        /**
+         * Adds a registered event to the registry.
+         *
+         * @param name The name of the script event.
+         * @param args The argument string for the event.
+         *
+         * @return The added event.
+         *
+         * @see ScriptController::executeFunction
+         */
+        const Event* addEvent(const char* name, const char* args = NULL);
+
+        /**
+         * Returns the number of registered script events.
+         *
+         * @return The number of script events registered.
+         */
+        unsigned int getEventCount() const;
+
+        /**
+         * Returns the event with the given index.
+         *
+         * @param index The index of the event to retrieve.
+         *
+         * @return The event for the given index.
+         */
+        const Event* getEvent(unsigned int index) const;
+
+    private:
+
+        std::vector<Event> _events;
+    };
+
     /**
     /**
      * Attaches a script to this object.
      * Attaches a script to this object.
      *
      *
@@ -32,7 +145,7 @@ public:
 protected:
 protected:
 
 
     /**
     /**
-     * Hidden constructor.
+     * Constructor.
      */
      */
     ScriptTarget();
     ScriptTarget();
 
 
@@ -42,61 +155,68 @@ protected:
     virtual ~ScriptTarget();
     virtual ~ScriptTarget();
 
 
     /**
     /**
-     * Registers the given event with the given script parameter string ({@link ScriptController::executeFunction})
-     * as a supported event for this script target.
-     * 
-     * @param eventName The name of the event.
-     * @param argsString The argument string for the event.
+     * Registers a set of supported script events and event arguments for this ScriptTarget. 
+     *
+     * The passed in EventRegistry object should contain a list of all script events to
+     * be supported by this ScriptTarget, along with their parameter definitions. This
+     * registry object will be held onto for the lifetime of the ScriptTarget and it is
+     * recommended that it be shared among all ScriptTargets of the same class/type.
+     *
+     * This should normally be set using the GP_REGISTER_SCRIPT_EVENTS macro in the
+     * constructor of the child class.
+     *
+     * @param registry The EventRegistry containing the list of supported script events.
      */
      */
-    void registerScriptEvent(const std::string& eventName, const char* argsString = NULL);
+    void registerEvents(EventRegistry* registry);
 
 
     /**
     /**
-     * Fires the event with the given event name and the given arguments.
+     * Fires the specified script event, passing the specified arguments.
+     *
+     * The only supported return types are void and boolean. When a boolean
+     * return type is used and there are multiple scripts registered for the
+     * given script event, event delegation will stop at the first script
+     * that returns a value of true.
      * 
      * 
-     * @param eventName The name of the event.
+     * @param evt The script event to fire, which was returned from EventRegistry::addEvent.
+     * @param ... Optional list of arguments to pass to the script event (should match the
+     *      script event argument definition).
      */
      */
-    template<typename T> T fireScriptEvent(const char* eventName, ...);
+    template<typename T> T fireScriptEvent(const EventRegistry::Event* evt, ...);
 
 
     /** Stores an attached script. */
     /** Stores an attached script. */
     struct Script
     struct Script
     {
     {
+        // The ID of the script
         int id;
         int id;
+
+        // The path the script was loaded from
         std::string path;
         std::string path;
-        Script* next;
-        Script* prev;
-        Script() : id(0), next(NULL), prev(NULL) { }
-    };
 
 
-    /** Used to store a script callbacks for given event. */
-    struct Callback
-    {
-        /** Constructor. */
-        Callback(const std::string& string);
+        // Event callback functions available to be called for this script
+        std::vector<std::string> eventCallbacks;
 
 
-        /** The script that this callback belongs to. */
-        Script* scriptId;
+        // Linked list info
+        Script* next;
+        Script* prev;
 
 
-        /** Holds the script callback function. */
-        std::string function;
+        Script() : id(0), next(NULL), prev(NULL) { }
     };
     };
 
 
     /** Holds the registered events for this script target. */
     /** Holds the registered events for this script target. */
-    std::map<std::string, std::string> _events;
-    /** Holds the callbacks for this script target's events. */
-    std::map<std::string, std::vector<Callback>*> _callbacks;
+    std::vector<EventRegistry*>* _events;
     /** Holds the list of scripts referenced by this ScriptTarget. */
     /** Holds the list of scripts referenced by this ScriptTarget. */
     Script* _scripts;
     Script* _scripts;
 };
 };
 
 
-template<typename T> T ScriptTarget::fireScriptEvent(const char* eventName, ...)
+template<typename T> T ScriptTarget::fireScriptEvent(const EventRegistry::Event* evt, ...)
 {
 {
-    GP_ERROR("Unsupported return type!");
+    GP_ERROR("Unsupported return type for template function ScriptTarget::fireScriptEvent.");
 }
 }
 
 
 /** Template specialization. */
 /** Template specialization. */
-template<> void ScriptTarget::fireScriptEvent<void>(const char* eventName, ...);
+template<> void ScriptTarget::fireScriptEvent<void>(const EventRegistry::Event* evt, ...);
 /** Template specialization. */
 /** Template specialization. */
-template<> bool ScriptTarget::fireScriptEvent<bool>(const char* eventName, ...);
+template<> bool ScriptTarget::fireScriptEvent<bool>(const EventRegistry::Event* evt, ...);
 
 
 }
 }
 
 

+ 13 - 5
gameplay/src/Transform.cpp

@@ -6,39 +6,47 @@
 namespace gameplay
 namespace gameplay
 {
 {
 
 
+// Setup scripting
+GP_SCRIPT_EVENTS();
+GP_SCRIPT_EVENT(transformChanged, "<Transform>");
+
 int Transform::_suspendTransformChanged(0);
 int Transform::_suspendTransformChanged(0);
 std::vector<Transform*> Transform::_transformsChanged;
 std::vector<Transform*> Transform::_transformsChanged;
 
 
 Transform::Transform()
 Transform::Transform()
     : _matrixDirtyBits(0), _listeners(NULL)
     : _matrixDirtyBits(0), _listeners(NULL)
 {
 {
+    GP_REGISTER_SCRIPT_EVENTS();
+
     _targetType = AnimationTarget::TRANSFORM;
     _targetType = AnimationTarget::TRANSFORM;
     _scale.set(Vector3::one());
     _scale.set(Vector3::one());
-    addScriptEvent("transformChanged", "<Transform>");
 }
 }
 
 
 Transform::Transform(const Vector3& scale, const Quaternion& rotation, const Vector3& translation)
 Transform::Transform(const Vector3& scale, const Quaternion& rotation, const Vector3& translation)
     : _matrixDirtyBits(0), _listeners(NULL)
     : _matrixDirtyBits(0), _listeners(NULL)
 {
 {
+    GP_REGISTER_SCRIPT_EVENTS();
+
     _targetType = AnimationTarget::TRANSFORM;
     _targetType = AnimationTarget::TRANSFORM;
     set(scale, rotation, translation);
     set(scale, rotation, translation);
-    addScriptEvent("transformChanged", "<Transform>");
 }
 }
 
 
 Transform::Transform(const Vector3& scale, const Matrix& rotation, const Vector3& translation)
 Transform::Transform(const Vector3& scale, const Matrix& rotation, const Vector3& translation)
     : _matrixDirtyBits(0), _listeners(NULL)
     : _matrixDirtyBits(0), _listeners(NULL)
 {
 {
+    GP_REGISTER_SCRIPT_EVENTS();
+
     _targetType = AnimationTarget::TRANSFORM;
     _targetType = AnimationTarget::TRANSFORM;
     set(scale, rotation, translation);
     set(scale, rotation, translation);
-    addScriptEvent("transformChanged", "<Transform>");
 }
 }
 
 
 Transform::Transform(const Transform& copy)
 Transform::Transform(const Transform& copy)
     : _matrixDirtyBits(0), _listeners(NULL)
     : _matrixDirtyBits(0), _listeners(NULL)
 {
 {
+    GP_REGISTER_SCRIPT_EVENTS();
+
     _targetType = AnimationTarget::TRANSFORM;
     _targetType = AnimationTarget::TRANSFORM;
     set(copy);
     set(copy);
-    addScriptEvent("transformChanged", "<Transform>");
 }
 }
 
 
 Transform::~Transform()
 Transform::~Transform()
@@ -991,7 +999,7 @@ void Transform::transformChanged()
             l.listener->transformChanged(this, l.cookie);
             l.listener->transformChanged(this, l.cookie);
         }
         }
     }
     }
-    fireScriptEvent<void>("transformChanged", this);
+    fireScriptEvent<void>(SCRIPT_EVENT_transformChanged, this);
 }
 }
 
 
 void Transform::cloneInto(Transform* transform, NodeCloneContext &context) const
 void Transform::cloneInto(Transform* transform, NodeCloneContext &context) const

+ 26 - 28
gameplay/src/lua/lua_AIAgent.cpp

@@ -17,14 +17,14 @@ void luaRegister_AIAgent()
     const luaL_Reg lua_members[] = 
     const luaL_Reg lua_members[] = 
     {
     {
         {"addRef", lua_AIAgent_addRef},
         {"addRef", lua_AIAgent_addRef},
-        {"addScriptCallback", lua_AIAgent_addScriptCallback},
+        {"addScript", lua_AIAgent_addScript},
         {"getId", lua_AIAgent_getId},
         {"getId", lua_AIAgent_getId},
         {"getNode", lua_AIAgent_getNode},
         {"getNode", lua_AIAgent_getNode},
         {"getRefCount", lua_AIAgent_getRefCount},
         {"getRefCount", lua_AIAgent_getRefCount},
         {"getStateMachine", lua_AIAgent_getStateMachine},
         {"getStateMachine", lua_AIAgent_getStateMachine},
         {"isEnabled", lua_AIAgent_isEnabled},
         {"isEnabled", lua_AIAgent_isEnabled},
         {"release", lua_AIAgent_release},
         {"release", lua_AIAgent_release},
-        {"removeScriptCallback", lua_AIAgent_removeScriptCallback},
+        {"removeScript", lua_AIAgent_removeScript},
         {"setEnabled", lua_AIAgent_setEnabled},
         {"setEnabled", lua_AIAgent_setEnabled},
         {"setListener", lua_AIAgent_setListener},
         {"setListener", lua_AIAgent_setListener},
         {NULL, NULL}
         {NULL, NULL}
@@ -116,7 +116,7 @@ int lua_AIAgent_addRef(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_AIAgent_addScriptCallback(lua_State* state)
+int lua_AIAgent_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -124,31 +124,30 @@ int lua_AIAgent_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 AIAgent* instance = getInstance(state);
                 AIAgent* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_AIAgent_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_AIAgent_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -381,7 +380,7 @@ int lua_AIAgent_release(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_AIAgent_removeScriptCallback(lua_State* state)
+int lua_AIAgent_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -389,31 +388,30 @@ int lua_AIAgent_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 AIAgent* instance = getInstance(state);
                 AIAgent* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_AIAgent_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_AIAgent_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 2
gameplay/src/lua/lua_AIAgent.h

@@ -7,14 +7,14 @@ namespace gameplay
 // Lua bindings for AIAgent.
 // Lua bindings for AIAgent.
 int lua_AIAgent__gc(lua_State* state);
 int lua_AIAgent__gc(lua_State* state);
 int lua_AIAgent_addRef(lua_State* state);
 int lua_AIAgent_addRef(lua_State* state);
-int lua_AIAgent_addScriptCallback(lua_State* state);
+int lua_AIAgent_addScript(lua_State* state);
 int lua_AIAgent_getId(lua_State* state);
 int lua_AIAgent_getId(lua_State* state);
 int lua_AIAgent_getNode(lua_State* state);
 int lua_AIAgent_getNode(lua_State* state);
 int lua_AIAgent_getRefCount(lua_State* state);
 int lua_AIAgent_getRefCount(lua_State* state);
 int lua_AIAgent_getStateMachine(lua_State* state);
 int lua_AIAgent_getStateMachine(lua_State* state);
 int lua_AIAgent_isEnabled(lua_State* state);
 int lua_AIAgent_isEnabled(lua_State* state);
 int lua_AIAgent_release(lua_State* state);
 int lua_AIAgent_release(lua_State* state);
-int lua_AIAgent_removeScriptCallback(lua_State* state);
+int lua_AIAgent_removeScript(lua_State* state);
 int lua_AIAgent_setEnabled(lua_State* state);
 int lua_AIAgent_setEnabled(lua_State* state);
 int lua_AIAgent_setListener(lua_State* state);
 int lua_AIAgent_setListener(lua_State* state);
 int lua_AIAgent_static_create(lua_State* state);
 int lua_AIAgent_static_create(lua_State* state);

+ 26 - 28
gameplay/src/lua/lua_AIState.cpp

@@ -17,11 +17,11 @@ void luaRegister_AIState()
     const luaL_Reg lua_members[] = 
     const luaL_Reg lua_members[] = 
     {
     {
         {"addRef", lua_AIState_addRef},
         {"addRef", lua_AIState_addRef},
-        {"addScriptCallback", lua_AIState_addScriptCallback},
+        {"addScript", lua_AIState_addScript},
         {"getId", lua_AIState_getId},
         {"getId", lua_AIState_getId},
         {"getRefCount", lua_AIState_getRefCount},
         {"getRefCount", lua_AIState_getRefCount},
         {"release", lua_AIState_release},
         {"release", lua_AIState_release},
-        {"removeScriptCallback", lua_AIState_removeScriptCallback},
+        {"removeScript", lua_AIState_removeScript},
         {"setListener", lua_AIState_setListener},
         {"setListener", lua_AIState_setListener},
         {NULL, NULL}
         {NULL, NULL}
     };
     };
@@ -112,7 +112,7 @@ int lua_AIState_addRef(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_AIState_addScriptCallback(lua_State* state)
+int lua_AIState_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -120,31 +120,30 @@ int lua_AIState_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 AIState* instance = getInstance(state);
                 AIState* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_AIState_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_AIState_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -254,7 +253,7 @@ int lua_AIState_release(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_AIState_removeScriptCallback(lua_State* state)
+int lua_AIState_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -262,31 +261,30 @@ int lua_AIState_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 AIState* instance = getInstance(state);
                 AIState* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_AIState_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_AIState_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 2
gameplay/src/lua/lua_AIState.h

@@ -7,11 +7,11 @@ namespace gameplay
 // Lua bindings for AIState.
 // Lua bindings for AIState.
 int lua_AIState__gc(lua_State* state);
 int lua_AIState__gc(lua_State* state);
 int lua_AIState_addRef(lua_State* state);
 int lua_AIState_addRef(lua_State* state);
-int lua_AIState_addScriptCallback(lua_State* state);
+int lua_AIState_addScript(lua_State* state);
 int lua_AIState_getId(lua_State* state);
 int lua_AIState_getId(lua_State* state);
 int lua_AIState_getRefCount(lua_State* state);
 int lua_AIState_getRefCount(lua_State* state);
 int lua_AIState_release(lua_State* state);
 int lua_AIState_release(lua_State* state);
-int lua_AIState_removeScriptCallback(lua_State* state);
+int lua_AIState_removeScript(lua_State* state);
 int lua_AIState_setListener(lua_State* state);
 int lua_AIState_setListener(lua_State* state);
 int lua_AIState_static_create(lua_State* state);
 int lua_AIState_static_create(lua_State* state);
 
 

+ 26 - 28
gameplay/src/lua/lua_Button.cpp

@@ -31,7 +31,7 @@ void luaRegister_Button()
     {
     {
         {"addListener", lua_Button_addListener},
         {"addListener", lua_Button_addListener},
         {"addRef", lua_Button_addRef},
         {"addRef", lua_Button_addRef},
-        {"addScriptCallback", lua_Button_addScriptCallback},
+        {"addScript", lua_Button_addScript},
         {"canFocus", lua_Button_canFocus},
         {"canFocus", lua_Button_canFocus},
         {"createAnimation", lua_Button_createAnimation},
         {"createAnimation", lua_Button_createAnimation},
         {"createAnimationFromBy", lua_Button_createAnimationFromBy},
         {"createAnimationFromBy", lua_Button_createAnimationFromBy},
@@ -91,7 +91,7 @@ void luaRegister_Button()
         {"isYPercentage", lua_Button_isYPercentage},
         {"isYPercentage", lua_Button_isYPercentage},
         {"release", lua_Button_release},
         {"release", lua_Button_release},
         {"removeListener", lua_Button_removeListener},
         {"removeListener", lua_Button_removeListener},
-        {"removeScriptCallback", lua_Button_removeScriptCallback},
+        {"removeScript", lua_Button_removeScript},
         {"setAlignment", lua_Button_setAlignment},
         {"setAlignment", lua_Button_setAlignment},
         {"setAnimationPropertyValue", lua_Button_setAnimationPropertyValue},
         {"setAnimationPropertyValue", lua_Button_setAnimationPropertyValue},
         {"setAutoSize", lua_Button_setAutoSize},
         {"setAutoSize", lua_Button_setAutoSize},
@@ -269,7 +269,7 @@ int lua_Button_addRef(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Button_addScriptCallback(lua_State* state)
+int lua_Button_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -277,31 +277,30 @@ int lua_Button_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Button* instance = getInstance(state);
                 Button* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Button_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Button_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -3150,7 +3149,7 @@ int lua_Button_removeListener(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Button_removeScriptCallback(lua_State* state)
+int lua_Button_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -3158,31 +3157,30 @@ int lua_Button_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Button* instance = getInstance(state);
                 Button* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Button_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Button_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 2
gameplay/src/lua/lua_Button.h

@@ -8,7 +8,7 @@ namespace gameplay
 int lua_Button__gc(lua_State* state);
 int lua_Button__gc(lua_State* state);
 int lua_Button_addListener(lua_State* state);
 int lua_Button_addListener(lua_State* state);
 int lua_Button_addRef(lua_State* state);
 int lua_Button_addRef(lua_State* state);
-int lua_Button_addScriptCallback(lua_State* state);
+int lua_Button_addScript(lua_State* state);
 int lua_Button_canFocus(lua_State* state);
 int lua_Button_canFocus(lua_State* state);
 int lua_Button_createAnimation(lua_State* state);
 int lua_Button_createAnimation(lua_State* state);
 int lua_Button_createAnimationFromBy(lua_State* state);
 int lua_Button_createAnimationFromBy(lua_State* state);
@@ -68,7 +68,7 @@ int lua_Button_isXPercentage(lua_State* state);
 int lua_Button_isYPercentage(lua_State* state);
 int lua_Button_isYPercentage(lua_State* state);
 int lua_Button_release(lua_State* state);
 int lua_Button_release(lua_State* state);
 int lua_Button_removeListener(lua_State* state);
 int lua_Button_removeListener(lua_State* state);
-int lua_Button_removeScriptCallback(lua_State* state);
+int lua_Button_removeScript(lua_State* state);
 int lua_Button_setAlignment(lua_State* state);
 int lua_Button_setAlignment(lua_State* state);
 int lua_Button_setAnimationPropertyValue(lua_State* state);
 int lua_Button_setAnimationPropertyValue(lua_State* state);
 int lua_Button_setAutoSize(lua_State* state);
 int lua_Button_setAutoSize(lua_State* state);

+ 26 - 28
gameplay/src/lua/lua_CheckBox.cpp

@@ -32,7 +32,7 @@ void luaRegister_CheckBox()
     {
     {
         {"addListener", lua_CheckBox_addListener},
         {"addListener", lua_CheckBox_addListener},
         {"addRef", lua_CheckBox_addRef},
         {"addRef", lua_CheckBox_addRef},
-        {"addScriptCallback", lua_CheckBox_addScriptCallback},
+        {"addScript", lua_CheckBox_addScript},
         {"canFocus", lua_CheckBox_canFocus},
         {"canFocus", lua_CheckBox_canFocus},
         {"createAnimation", lua_CheckBox_createAnimation},
         {"createAnimation", lua_CheckBox_createAnimation},
         {"createAnimationFromBy", lua_CheckBox_createAnimationFromBy},
         {"createAnimationFromBy", lua_CheckBox_createAnimationFromBy},
@@ -94,7 +94,7 @@ void luaRegister_CheckBox()
         {"isYPercentage", lua_CheckBox_isYPercentage},
         {"isYPercentage", lua_CheckBox_isYPercentage},
         {"release", lua_CheckBox_release},
         {"release", lua_CheckBox_release},
         {"removeListener", lua_CheckBox_removeListener},
         {"removeListener", lua_CheckBox_removeListener},
-        {"removeScriptCallback", lua_CheckBox_removeScriptCallback},
+        {"removeScript", lua_CheckBox_removeScript},
         {"setAlignment", lua_CheckBox_setAlignment},
         {"setAlignment", lua_CheckBox_setAlignment},
         {"setAnimationPropertyValue", lua_CheckBox_setAnimationPropertyValue},
         {"setAnimationPropertyValue", lua_CheckBox_setAnimationPropertyValue},
         {"setAutoSize", lua_CheckBox_setAutoSize},
         {"setAutoSize", lua_CheckBox_setAutoSize},
@@ -273,7 +273,7 @@ int lua_CheckBox_addRef(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_CheckBox_addScriptCallback(lua_State* state)
+int lua_CheckBox_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -281,31 +281,30 @@ int lua_CheckBox_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 CheckBox* instance = getInstance(state);
                 CheckBox* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_CheckBox_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_CheckBox_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -3224,7 +3223,7 @@ int lua_CheckBox_removeListener(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_CheckBox_removeScriptCallback(lua_State* state)
+int lua_CheckBox_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -3232,31 +3231,30 @@ int lua_CheckBox_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 CheckBox* instance = getInstance(state);
                 CheckBox* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_CheckBox_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_CheckBox_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 2
gameplay/src/lua/lua_CheckBox.h

@@ -8,7 +8,7 @@ namespace gameplay
 int lua_CheckBox__gc(lua_State* state);
 int lua_CheckBox__gc(lua_State* state);
 int lua_CheckBox_addListener(lua_State* state);
 int lua_CheckBox_addListener(lua_State* state);
 int lua_CheckBox_addRef(lua_State* state);
 int lua_CheckBox_addRef(lua_State* state);
-int lua_CheckBox_addScriptCallback(lua_State* state);
+int lua_CheckBox_addScript(lua_State* state);
 int lua_CheckBox_canFocus(lua_State* state);
 int lua_CheckBox_canFocus(lua_State* state);
 int lua_CheckBox_createAnimation(lua_State* state);
 int lua_CheckBox_createAnimation(lua_State* state);
 int lua_CheckBox_createAnimationFromBy(lua_State* state);
 int lua_CheckBox_createAnimationFromBy(lua_State* state);
@@ -70,7 +70,7 @@ int lua_CheckBox_isXPercentage(lua_State* state);
 int lua_CheckBox_isYPercentage(lua_State* state);
 int lua_CheckBox_isYPercentage(lua_State* state);
 int lua_CheckBox_release(lua_State* state);
 int lua_CheckBox_release(lua_State* state);
 int lua_CheckBox_removeListener(lua_State* state);
 int lua_CheckBox_removeListener(lua_State* state);
-int lua_CheckBox_removeScriptCallback(lua_State* state);
+int lua_CheckBox_removeScript(lua_State* state);
 int lua_CheckBox_setAlignment(lua_State* state);
 int lua_CheckBox_setAlignment(lua_State* state);
 int lua_CheckBox_setAnimationPropertyValue(lua_State* state);
 int lua_CheckBox_setAnimationPropertyValue(lua_State* state);
 int lua_CheckBox_setAutoSize(lua_State* state);
 int lua_CheckBox_setAutoSize(lua_State* state);

+ 67 - 28
gameplay/src/lua/lua_Container.cpp

@@ -26,6 +26,7 @@
 #include "TextBox.h"
 #include "TextBox.h"
 #include "Theme.h"
 #include "Theme.h"
 #include "VerticalLayout.h"
 #include "VerticalLayout.h"
+#include "lua_ContainerDirection.h"
 #include "lua_ContainerScroll.h"
 #include "lua_ContainerScroll.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlAutoSize.h"
@@ -45,7 +46,7 @@ void luaRegister_Container()
         {"addControl", lua_Container_addControl},
         {"addControl", lua_Container_addControl},
         {"addListener", lua_Container_addListener},
         {"addListener", lua_Container_addListener},
         {"addRef", lua_Container_addRef},
         {"addRef", lua_Container_addRef},
-        {"addScriptCallback", lua_Container_addScriptCallback},
+        {"addScript", lua_Container_addScript},
         {"canFocus", lua_Container_canFocus},
         {"canFocus", lua_Container_canFocus},
         {"createAnimation", lua_Container_createAnimation},
         {"createAnimation", lua_Container_createAnimation},
         {"createAnimationFromBy", lua_Container_createAnimationFromBy},
         {"createAnimationFromBy", lua_Container_createAnimationFromBy},
@@ -116,10 +117,11 @@ void luaRegister_Container()
         {"isWidthPercentage", lua_Container_isWidthPercentage},
         {"isWidthPercentage", lua_Container_isWidthPercentage},
         {"isXPercentage", lua_Container_isXPercentage},
         {"isXPercentage", lua_Container_isXPercentage},
         {"isYPercentage", lua_Container_isYPercentage},
         {"isYPercentage", lua_Container_isYPercentage},
+        {"moveFocus", lua_Container_moveFocus},
         {"release", lua_Container_release},
         {"release", lua_Container_release},
         {"removeControl", lua_Container_removeControl},
         {"removeControl", lua_Container_removeControl},
         {"removeListener", lua_Container_removeListener},
         {"removeListener", lua_Container_removeListener},
-        {"removeScriptCallback", lua_Container_removeScriptCallback},
+        {"removeScript", lua_Container_removeScript},
         {"setActiveControl", lua_Container_setActiveControl},
         {"setActiveControl", lua_Container_setActiveControl},
         {"setAlignment", lua_Container_setAlignment},
         {"setAlignment", lua_Container_setAlignment},
         {"setAnimationPropertyValue", lua_Container_setAnimationPropertyValue},
         {"setAnimationPropertyValue", lua_Container_setAnimationPropertyValue},
@@ -351,7 +353,7 @@ int lua_Container_addRef(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Container_addScriptCallback(lua_State* state)
+int lua_Container_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -359,31 +361,30 @@ int lua_Container_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Container* instance = getInstance(state);
                 Container* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Container_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Container_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -3694,6 +3695,45 @@ int lua_Container_isYPercentage(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Container_moveFocus(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                Container::Direction param1 = (Container::Direction)lua_enumFromString_ContainerDirection(luaL_checkstring(state, 2));
+
+                Container* instance = getInstance(state);
+                bool result = instance->moveFocus(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Container_moveFocus - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_Container_release(lua_State* state)
 int lua_Container_release(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -3840,7 +3880,7 @@ int lua_Container_removeListener(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Container_removeScriptCallback(lua_State* state)
+int lua_Container_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -3848,31 +3888,30 @@ int lua_Container_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Container* instance = getInstance(state);
                 Container* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Container_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Container_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 3 - 2
gameplay/src/lua/lua_Container.h

@@ -9,7 +9,7 @@ int lua_Container__gc(lua_State* state);
 int lua_Container_addControl(lua_State* state);
 int lua_Container_addControl(lua_State* state);
 int lua_Container_addListener(lua_State* state);
 int lua_Container_addListener(lua_State* state);
 int lua_Container_addRef(lua_State* state);
 int lua_Container_addRef(lua_State* state);
-int lua_Container_addScriptCallback(lua_State* state);
+int lua_Container_addScript(lua_State* state);
 int lua_Container_canFocus(lua_State* state);
 int lua_Container_canFocus(lua_State* state);
 int lua_Container_createAnimation(lua_State* state);
 int lua_Container_createAnimation(lua_State* state);
 int lua_Container_createAnimationFromBy(lua_State* state);
 int lua_Container_createAnimationFromBy(lua_State* state);
@@ -80,10 +80,11 @@ int lua_Container_isVisibleInHierarchy(lua_State* state);
 int lua_Container_isWidthPercentage(lua_State* state);
 int lua_Container_isWidthPercentage(lua_State* state);
 int lua_Container_isXPercentage(lua_State* state);
 int lua_Container_isXPercentage(lua_State* state);
 int lua_Container_isYPercentage(lua_State* state);
 int lua_Container_isYPercentage(lua_State* state);
+int lua_Container_moveFocus(lua_State* state);
 int lua_Container_release(lua_State* state);
 int lua_Container_release(lua_State* state);
 int lua_Container_removeControl(lua_State* state);
 int lua_Container_removeControl(lua_State* state);
 int lua_Container_removeListener(lua_State* state);
 int lua_Container_removeListener(lua_State* state);
-int lua_Container_removeScriptCallback(lua_State* state);
+int lua_Container_removeScript(lua_State* state);
 int lua_Container_setActiveControl(lua_State* state);
 int lua_Container_setActiveControl(lua_State* state);
 int lua_Container_setAlignment(lua_State* state);
 int lua_Container_setAlignment(lua_State* state);
 int lua_Container_setAnimationPropertyValue(lua_State* state);
 int lua_Container_setAnimationPropertyValue(lua_State* state);

+ 51 - 0
gameplay/src/lua/lua_ContainerDirection.cpp

@@ -0,0 +1,51 @@
+#include "Base.h"
+#include "lua_ContainerDirection.h"
+
+namespace gameplay
+{
+
+static const char* enumStringEmpty = "";
+
+static const char* luaEnumString_ContainerDirection_UP = "UP";
+static const char* luaEnumString_ContainerDirection_DOWN = "DOWN";
+static const char* luaEnumString_ContainerDirection_LEFT = "LEFT";
+static const char* luaEnumString_ContainerDirection_RIGHT = "RIGHT";
+static const char* luaEnumString_ContainerDirection_NEXT = "NEXT";
+static const char* luaEnumString_ContainerDirection_PREVIOUS = "PREVIOUS";
+
+Container::Direction lua_enumFromString_ContainerDirection(const char* s)
+{
+    if (strcmp(s, luaEnumString_ContainerDirection_UP) == 0)
+        return Container::UP;
+    if (strcmp(s, luaEnumString_ContainerDirection_DOWN) == 0)
+        return Container::DOWN;
+    if (strcmp(s, luaEnumString_ContainerDirection_LEFT) == 0)
+        return Container::LEFT;
+    if (strcmp(s, luaEnumString_ContainerDirection_RIGHT) == 0)
+        return Container::RIGHT;
+    if (strcmp(s, luaEnumString_ContainerDirection_NEXT) == 0)
+        return Container::NEXT;
+    if (strcmp(s, luaEnumString_ContainerDirection_PREVIOUS) == 0)
+        return Container::PREVIOUS;
+    return Container::UP;
+}
+
+const char* lua_stringFromEnum_ContainerDirection(Container::Direction e)
+{
+    if (e == Container::UP)
+        return luaEnumString_ContainerDirection_UP;
+    if (e == Container::DOWN)
+        return luaEnumString_ContainerDirection_DOWN;
+    if (e == Container::LEFT)
+        return luaEnumString_ContainerDirection_LEFT;
+    if (e == Container::RIGHT)
+        return luaEnumString_ContainerDirection_RIGHT;
+    if (e == Container::NEXT)
+        return luaEnumString_ContainerDirection_NEXT;
+    if (e == Container::PREVIOUS)
+        return luaEnumString_ContainerDirection_PREVIOUS;
+    return enumStringEmpty;
+}
+
+}
+

+ 15 - 0
gameplay/src/lua/lua_ContainerDirection.h

@@ -0,0 +1,15 @@
+#ifndef LUA_CONTAINERDIRECTION_H_
+#define LUA_CONTAINERDIRECTION_H_
+
+#include "Container.h"
+
+namespace gameplay
+{
+
+// Lua bindings for enum conversion functions for Container::Direction.
+Container::Direction lua_enumFromString_ContainerDirection(const char* s);
+const char* lua_stringFromEnum_ContainerDirection(Container::Direction e);
+
+}
+
+#endif

+ 26 - 28
gameplay/src/lua/lua_Control.cpp

@@ -28,7 +28,7 @@ void luaRegister_Control()
     {
     {
         {"addListener", lua_Control_addListener},
         {"addListener", lua_Control_addListener},
         {"addRef", lua_Control_addRef},
         {"addRef", lua_Control_addRef},
-        {"addScriptCallback", lua_Control_addScriptCallback},
+        {"addScript", lua_Control_addScript},
         {"canFocus", lua_Control_canFocus},
         {"canFocus", lua_Control_canFocus},
         {"createAnimation", lua_Control_createAnimation},
         {"createAnimation", lua_Control_createAnimation},
         {"createAnimationFromBy", lua_Control_createAnimationFromBy},
         {"createAnimationFromBy", lua_Control_createAnimationFromBy},
@@ -88,7 +88,7 @@ void luaRegister_Control()
         {"isYPercentage", lua_Control_isYPercentage},
         {"isYPercentage", lua_Control_isYPercentage},
         {"release", lua_Control_release},
         {"release", lua_Control_release},
         {"removeListener", lua_Control_removeListener},
         {"removeListener", lua_Control_removeListener},
-        {"removeScriptCallback", lua_Control_removeScriptCallback},
+        {"removeScript", lua_Control_removeScript},
         {"setAlignment", lua_Control_setAlignment},
         {"setAlignment", lua_Control_setAlignment},
         {"setAnimationPropertyValue", lua_Control_setAnimationPropertyValue},
         {"setAnimationPropertyValue", lua_Control_setAnimationPropertyValue},
         {"setAutoSize", lua_Control_setAutoSize},
         {"setAutoSize", lua_Control_setAutoSize},
@@ -264,7 +264,7 @@ int lua_Control_addRef(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Control_addScriptCallback(lua_State* state)
+int lua_Control_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -272,31 +272,30 @@ int lua_Control_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Control* instance = getInstance(state);
                 Control* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Control_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Control_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -3145,7 +3144,7 @@ int lua_Control_removeListener(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Control_removeScriptCallback(lua_State* state)
+int lua_Control_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -3153,31 +3152,30 @@ int lua_Control_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Control* instance = getInstance(state);
                 Control* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Control_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Control_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 2
gameplay/src/lua/lua_Control.h

@@ -8,7 +8,7 @@ namespace gameplay
 int lua_Control__gc(lua_State* state);
 int lua_Control__gc(lua_State* state);
 int lua_Control_addListener(lua_State* state);
 int lua_Control_addListener(lua_State* state);
 int lua_Control_addRef(lua_State* state);
 int lua_Control_addRef(lua_State* state);
-int lua_Control_addScriptCallback(lua_State* state);
+int lua_Control_addScript(lua_State* state);
 int lua_Control_canFocus(lua_State* state);
 int lua_Control_canFocus(lua_State* state);
 int lua_Control_createAnimation(lua_State* state);
 int lua_Control_createAnimation(lua_State* state);
 int lua_Control_createAnimationFromBy(lua_State* state);
 int lua_Control_createAnimationFromBy(lua_State* state);
@@ -68,7 +68,7 @@ int lua_Control_isXPercentage(lua_State* state);
 int lua_Control_isYPercentage(lua_State* state);
 int lua_Control_isYPercentage(lua_State* state);
 int lua_Control_release(lua_State* state);
 int lua_Control_release(lua_State* state);
 int lua_Control_removeListener(lua_State* state);
 int lua_Control_removeListener(lua_State* state);
-int lua_Control_removeScriptCallback(lua_State* state);
+int lua_Control_removeScript(lua_State* state);
 int lua_Control_setAlignment(lua_State* state);
 int lua_Control_setAlignment(lua_State* state);
 int lua_Control_setAnimationPropertyValue(lua_State* state);
 int lua_Control_setAnimationPropertyValue(lua_State* state);
 int lua_Control_setAutoSize(lua_State* state);
 int lua_Control_setAutoSize(lua_State* state);

+ 96 - 29
gameplay/src/lua/lua_Form.cpp

@@ -27,6 +27,7 @@
 #include "TextBox.h"
 #include "TextBox.h"
 #include "Theme.h"
 #include "Theme.h"
 #include "VerticalLayout.h"
 #include "VerticalLayout.h"
+#include "lua_ContainerDirection.h"
 #include "lua_ContainerScroll.h"
 #include "lua_ContainerScroll.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlAutoSize.h"
@@ -46,7 +47,7 @@ void luaRegister_Form()
         {"addControl", lua_Form_addControl},
         {"addControl", lua_Form_addControl},
         {"addListener", lua_Form_addListener},
         {"addListener", lua_Form_addListener},
         {"addRef", lua_Form_addRef},
         {"addRef", lua_Form_addRef},
-        {"addScriptCallback", lua_Form_addScriptCallback},
+        {"addScript", lua_Form_addScript},
         {"canFocus", lua_Form_canFocus},
         {"canFocus", lua_Form_canFocus},
         {"createAnimation", lua_Form_createAnimation},
         {"createAnimation", lua_Form_createAnimation},
         {"createAnimationFromBy", lua_Form_createAnimationFromBy},
         {"createAnimationFromBy", lua_Form_createAnimationFromBy},
@@ -119,10 +120,11 @@ void luaRegister_Form()
         {"isWidthPercentage", lua_Form_isWidthPercentage},
         {"isWidthPercentage", lua_Form_isWidthPercentage},
         {"isXPercentage", lua_Form_isXPercentage},
         {"isXPercentage", lua_Form_isXPercentage},
         {"isYPercentage", lua_Form_isYPercentage},
         {"isYPercentage", lua_Form_isYPercentage},
+        {"moveFocus", lua_Form_moveFocus},
         {"release", lua_Form_release},
         {"release", lua_Form_release},
         {"removeControl", lua_Form_removeControl},
         {"removeControl", lua_Form_removeControl},
         {"removeListener", lua_Form_removeListener},
         {"removeListener", lua_Form_removeListener},
-        {"removeScriptCallback", lua_Form_removeScriptCallback},
+        {"removeScript", lua_Form_removeScript},
         {"setActiveControl", lua_Form_setActiveControl},
         {"setActiveControl", lua_Form_setActiveControl},
         {"setAlignment", lua_Form_setAlignment},
         {"setAlignment", lua_Form_setAlignment},
         {"setAnimationPropertyValue", lua_Form_setAnimationPropertyValue},
         {"setAnimationPropertyValue", lua_Form_setAnimationPropertyValue},
@@ -361,7 +363,7 @@ int lua_Form_addRef(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Form_addScriptCallback(lua_State* state)
+int lua_Form_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -369,31 +371,30 @@ int lua_Form_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Form* instance = getInstance(state);
                 Form* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Form_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Form_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -3774,6 +3775,45 @@ int lua_Form_isYPercentage(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Form_moveFocus(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                Container::Direction param1 = (Container::Direction)lua_enumFromString_ContainerDirection(luaL_checkstring(state, 2));
+
+                Form* instance = getInstance(state);
+                bool result = instance->moveFocus(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Form_moveFocus - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_Form_release(lua_State* state)
 int lua_Form_release(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -3920,7 +3960,7 @@ int lua_Form_removeListener(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Form_removeScriptCallback(lua_State* state)
+int lua_Form_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -3928,31 +3968,30 @@ int lua_Form_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Form* instance = getInstance(state);
                 Form* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Form_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Form_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -6426,9 +6465,37 @@ int lua_Form_static_getActiveControl(lua_State* state)
             return 1;
             return 1;
             break;
             break;
         }
         }
+        case 1:
+        {
+            if (lua_type(state, 1) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 1);
+
+                void* returnPtr = (void*)Form::getActiveControl(param1);
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Control");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Form_static_getActiveControl - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 0).");
+            lua_pushstring(state, "Invalid number of parameters (expected 0 or 1).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 3 - 2
gameplay/src/lua/lua_Form.h

@@ -9,7 +9,7 @@ int lua_Form__gc(lua_State* state);
 int lua_Form_addControl(lua_State* state);
 int lua_Form_addControl(lua_State* state);
 int lua_Form_addListener(lua_State* state);
 int lua_Form_addListener(lua_State* state);
 int lua_Form_addRef(lua_State* state);
 int lua_Form_addRef(lua_State* state);
-int lua_Form_addScriptCallback(lua_State* state);
+int lua_Form_addScript(lua_State* state);
 int lua_Form_canFocus(lua_State* state);
 int lua_Form_canFocus(lua_State* state);
 int lua_Form_createAnimation(lua_State* state);
 int lua_Form_createAnimation(lua_State* state);
 int lua_Form_createAnimationFromBy(lua_State* state);
 int lua_Form_createAnimationFromBy(lua_State* state);
@@ -82,10 +82,11 @@ int lua_Form_isVisibleInHierarchy(lua_State* state);
 int lua_Form_isWidthPercentage(lua_State* state);
 int lua_Form_isWidthPercentage(lua_State* state);
 int lua_Form_isXPercentage(lua_State* state);
 int lua_Form_isXPercentage(lua_State* state);
 int lua_Form_isYPercentage(lua_State* state);
 int lua_Form_isYPercentage(lua_State* state);
+int lua_Form_moveFocus(lua_State* state);
 int lua_Form_release(lua_State* state);
 int lua_Form_release(lua_State* state);
 int lua_Form_removeControl(lua_State* state);
 int lua_Form_removeControl(lua_State* state);
 int lua_Form_removeListener(lua_State* state);
 int lua_Form_removeListener(lua_State* state);
-int lua_Form_removeScriptCallback(lua_State* state);
+int lua_Form_removeScript(lua_State* state);
 int lua_Form_setActiveControl(lua_State* state);
 int lua_Form_setActiveControl(lua_State* state);
 int lua_Form_setAlignment(lua_State* state);
 int lua_Form_setAlignment(lua_State* state);
 int lua_Form_setAnimationPropertyValue(lua_State* state);
 int lua_Form_setAnimationPropertyValue(lua_State* state);

+ 120 - 0
gameplay/src/lua/lua_Global.cpp

@@ -6,6 +6,7 @@ namespace gameplay
 
 
 void luaRegister_lua_Global()
 void luaRegister_lua_Global()
 {
 {
+    gameplay::ScriptUtil::registerFunction("GP_SCRIPT_EVENTS", lua___init);
     gameplay::ScriptUtil::registerFunction("strcmpnocase", lua__strcmpnocase);
     gameplay::ScriptUtil::registerFunction("strcmpnocase", lua__strcmpnocase);
     gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Button");
     gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Button");
     gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "CheckBox");
     gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "CheckBox");
@@ -182,6 +183,18 @@ void luaRegister_lua_Global()
         gameplay::ScriptUtil::registerConstantString("ORTHOGRAPHIC", "ORTHOGRAPHIC", scopePath);
         gameplay::ScriptUtil::registerConstantString("ORTHOGRAPHIC", "ORTHOGRAPHIC", scopePath);
     }
     }
 
 
+    // Register enumeration Container::Direction.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Container");
+        gameplay::ScriptUtil::registerConstantString("UP", "UP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DOWN", "DOWN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LEFT", "LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("RIGHT", "RIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("NEXT", "NEXT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("PREVIOUS", "PREVIOUS", scopePath);
+    }
+
     // Register enumeration Container::Scroll.
     // Register enumeration Container::Scroll.
     {
     {
         std::vector<std::string> scopePath;
         std::vector<std::string> scopePath;
@@ -910,6 +923,111 @@ void luaRegister_lua_Global()
     }
     }
 }
 }
 
 
+int lua___init(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 0:
+        {
+            void* returnPtr = (void*)GP_SCRIPT_EVENTS();
+            if (returnPtr)
+            {
+                gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                object->instance = returnPtr;
+                object->owns = false;
+                luaL_getmetatable(state, "GP_SCRIPT_EVENTS");
+                lua_setmetatable(state, -2);
+            }
+            else
+            {
+                lua_pushnil(state);
+            }
+
+            return 1;
+            break;
+        }
+        case 2:
+        {
+            do
+            {
+                if (lua_type(state, 1) == LUA_TNONE &&
+                    lua_type(state, 2) == LUA_TNONE)
+                {
+                    // Get parameter 1 off the stack.
+                    GP_WARN("Attempting to get parameter 1 with unrecognized type update as an unsigned integer.");
+                    update param1 = (update)luaL_checkunsigned(state, 1);
+
+                    // Get parameter 2 off the stack.
+                    GP_WARN("Attempting to get parameter 2 with unrecognized type "f" as an unsigned integer.");
+                    "f" param2 = ("f")luaL_checkunsigned(state, 2);
+
+                    void* returnPtr = (void*)GP_SCRIPT_EVENT(param1, param2);
+                    if (returnPtr)
+                    {
+                        gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                        object->instance = returnPtr;
+                        object->owns = false;
+                        luaL_getmetatable(state, "GP_SCRIPT_EVENT");
+                        lua_setmetatable(state, -2);
+                    }
+                    else
+                    {
+                        lua_pushnil(state);
+                    }
+
+                    return 1;
+                }
+            } while (0);
+
+            do
+            {
+                if (lua_type(state, 1) == LUA_TNONE &&
+                    lua_type(state, 2) == LUA_TNONE)
+                {
+                    // Get parameter 1 off the stack.
+                    GP_WARN("Attempting to get parameter 1 with unrecognized type transformChanged as an unsigned integer.");
+                    transformChanged param1 = (transformChanged)luaL_checkunsigned(state, 1);
+
+                    // Get parameter 2 off the stack.
+                    GP_WARN("Attempting to get parameter 2 with unrecognized type "<Transform>" as an unsigned integer.");
+                    "<Transform>" param2 = ("<Transform>")luaL_checkunsigned(state, 2);
+
+                    void* returnPtr = (void*)GP_SCRIPT_EVENT(param1, param2);
+                    if (returnPtr)
+                    {
+                        gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                        object->instance = returnPtr;
+                        object->owns = false;
+                        luaL_getmetatable(state, "GP_SCRIPT_EVENT");
+                        lua_setmetatable(state, -2);
+                    }
+                    else
+                    {
+                        lua_pushnil(state);
+                    }
+
+                    return 1;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua___init - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 0 or 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua__strcmpnocase(lua_State* state)
 int lua__strcmpnocase(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -963,6 +1081,8 @@ const char* lua_stringFromEnumGlobal(std::string& enumname, unsigned int value)
         return lua_stringFromEnum_AudioSourceState((AudioSource::State)value);
         return lua_stringFromEnum_AudioSourceState((AudioSource::State)value);
     if (enumname == "Camera::Type")
     if (enumname == "Camera::Type")
         return lua_stringFromEnum_CameraType((Camera::Type)value);
         return lua_stringFromEnum_CameraType((Camera::Type)value);
+    if (enumname == "Container::Direction")
+        return lua_stringFromEnum_ContainerDirection((Container::Direction)value);
     if (enumname == "Container::Scroll")
     if (enumname == "Container::Scroll")
         return lua_stringFromEnum_ContainerScroll((Container::Scroll)value);
         return lua_stringFromEnum_ContainerScroll((Container::Scroll)value);
     if (enumname == "Control::Alignment")
     if (enumname == "Control::Alignment")

+ 2 - 0
gameplay/src/lua/lua_Global.h

@@ -5,6 +5,7 @@
 #include "lua_AnimationClipListenerEventType.h"
 #include "lua_AnimationClipListenerEventType.h"
 #include "lua_AudioSourceState.h"
 #include "lua_AudioSourceState.h"
 #include "lua_CameraType.h"
 #include "lua_CameraType.h"
+#include "lua_ContainerDirection.h"
 #include "lua_ContainerScroll.h"
 #include "lua_ContainerScroll.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlAutoSize.h"
@@ -55,6 +56,7 @@ namespace gameplay
 {
 {
 
 
 // Lua bindings for global functions.
 // Lua bindings for global functions.
+int lua___init(lua_State* state);
 int lua__strcmpnocase(lua_State* state);
 int lua__strcmpnocase(lua_State* state);
 
 
 // Global enum to string conversion function (used to pass enums to Lua from C++).
 // Global enum to string conversion function (used to pass enums to Lua from C++).

+ 26 - 28
gameplay/src/lua/lua_ImageControl.cpp

@@ -29,7 +29,7 @@ void luaRegister_ImageControl()
     {
     {
         {"addListener", lua_ImageControl_addListener},
         {"addListener", lua_ImageControl_addListener},
         {"addRef", lua_ImageControl_addRef},
         {"addRef", lua_ImageControl_addRef},
-        {"addScriptCallback", lua_ImageControl_addScriptCallback},
+        {"addScript", lua_ImageControl_addScript},
         {"canFocus", lua_ImageControl_canFocus},
         {"canFocus", lua_ImageControl_canFocus},
         {"createAnimation", lua_ImageControl_createAnimation},
         {"createAnimation", lua_ImageControl_createAnimation},
         {"createAnimationFromBy", lua_ImageControl_createAnimationFromBy},
         {"createAnimationFromBy", lua_ImageControl_createAnimationFromBy},
@@ -91,7 +91,7 @@ void luaRegister_ImageControl()
         {"isYPercentage", lua_ImageControl_isYPercentage},
         {"isYPercentage", lua_ImageControl_isYPercentage},
         {"release", lua_ImageControl_release},
         {"release", lua_ImageControl_release},
         {"removeListener", lua_ImageControl_removeListener},
         {"removeListener", lua_ImageControl_removeListener},
-        {"removeScriptCallback", lua_ImageControl_removeScriptCallback},
+        {"removeScript", lua_ImageControl_removeScript},
         {"setAlignment", lua_ImageControl_setAlignment},
         {"setAlignment", lua_ImageControl_setAlignment},
         {"setAnimationPropertyValue", lua_ImageControl_setAnimationPropertyValue},
         {"setAnimationPropertyValue", lua_ImageControl_setAnimationPropertyValue},
         {"setAutoSize", lua_ImageControl_setAutoSize},
         {"setAutoSize", lua_ImageControl_setAutoSize},
@@ -271,7 +271,7 @@ int lua_ImageControl_addRef(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_ImageControl_addScriptCallback(lua_State* state)
+int lua_ImageControl_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -279,31 +279,30 @@ int lua_ImageControl_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 ImageControl* instance = getInstance(state);
                 ImageControl* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_ImageControl_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_ImageControl_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -3240,7 +3239,7 @@ int lua_ImageControl_removeListener(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_ImageControl_removeScriptCallback(lua_State* state)
+int lua_ImageControl_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -3248,31 +3247,30 @@ int lua_ImageControl_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 ImageControl* instance = getInstance(state);
                 ImageControl* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_ImageControl_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_ImageControl_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 2
gameplay/src/lua/lua_ImageControl.h

@@ -8,7 +8,7 @@ namespace gameplay
 int lua_ImageControl__gc(lua_State* state);
 int lua_ImageControl__gc(lua_State* state);
 int lua_ImageControl_addListener(lua_State* state);
 int lua_ImageControl_addListener(lua_State* state);
 int lua_ImageControl_addRef(lua_State* state);
 int lua_ImageControl_addRef(lua_State* state);
-int lua_ImageControl_addScriptCallback(lua_State* state);
+int lua_ImageControl_addScript(lua_State* state);
 int lua_ImageControl_canFocus(lua_State* state);
 int lua_ImageControl_canFocus(lua_State* state);
 int lua_ImageControl_createAnimation(lua_State* state);
 int lua_ImageControl_createAnimation(lua_State* state);
 int lua_ImageControl_createAnimationFromBy(lua_State* state);
 int lua_ImageControl_createAnimationFromBy(lua_State* state);
@@ -70,7 +70,7 @@ int lua_ImageControl_isXPercentage(lua_State* state);
 int lua_ImageControl_isYPercentage(lua_State* state);
 int lua_ImageControl_isYPercentage(lua_State* state);
 int lua_ImageControl_release(lua_State* state);
 int lua_ImageControl_release(lua_State* state);
 int lua_ImageControl_removeListener(lua_State* state);
 int lua_ImageControl_removeListener(lua_State* state);
-int lua_ImageControl_removeScriptCallback(lua_State* state);
+int lua_ImageControl_removeScript(lua_State* state);
 int lua_ImageControl_setAlignment(lua_State* state);
 int lua_ImageControl_setAlignment(lua_State* state);
 int lua_ImageControl_setAnimationPropertyValue(lua_State* state);
 int lua_ImageControl_setAnimationPropertyValue(lua_State* state);
 int lua_ImageControl_setAutoSize(lua_State* state);
 int lua_ImageControl_setAutoSize(lua_State* state);

+ 26 - 28
gameplay/src/lua/lua_Joint.cpp

@@ -34,7 +34,7 @@ void luaRegister_Joint()
         {"addChild", lua_Joint_addChild},
         {"addChild", lua_Joint_addChild},
         {"addListener", lua_Joint_addListener},
         {"addListener", lua_Joint_addListener},
         {"addRef", lua_Joint_addRef},
         {"addRef", lua_Joint_addRef},
-        {"addScriptCallback", lua_Joint_addScriptCallback},
+        {"addScript", lua_Joint_addScript},
         {"clone", lua_Joint_clone},
         {"clone", lua_Joint_clone},
         {"createAnimation", lua_Joint_createAnimation},
         {"createAnimation", lua_Joint_createAnimation},
         {"createAnimationFromBy", lua_Joint_createAnimationFromBy},
         {"createAnimationFromBy", lua_Joint_createAnimationFromBy},
@@ -108,7 +108,7 @@ void luaRegister_Joint()
         {"removeAllChildren", lua_Joint_removeAllChildren},
         {"removeAllChildren", lua_Joint_removeAllChildren},
         {"removeChild", lua_Joint_removeChild},
         {"removeChild", lua_Joint_removeChild},
         {"removeListener", lua_Joint_removeListener},
         {"removeListener", lua_Joint_removeListener},
-        {"removeScriptCallback", lua_Joint_removeScriptCallback},
+        {"removeScript", lua_Joint_removeScript},
         {"rotate", lua_Joint_rotate},
         {"rotate", lua_Joint_rotate},
         {"rotateX", lua_Joint_rotateX},
         {"rotateX", lua_Joint_rotateX},
         {"rotateY", lua_Joint_rotateY},
         {"rotateY", lua_Joint_rotateY},
@@ -369,7 +369,7 @@ int lua_Joint_addRef(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Joint_addScriptCallback(lua_State* state)
+int lua_Joint_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -377,31 +377,30 @@ int lua_Joint_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Joint* instance = getInstance(state);
                 Joint* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Joint_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Joint_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -4064,7 +4063,7 @@ int lua_Joint_removeListener(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Joint_removeScriptCallback(lua_State* state)
+int lua_Joint_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -4072,31 +4071,30 @@ int lua_Joint_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Joint* instance = getInstance(state);
                 Joint* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Joint_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Joint_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 2
gameplay/src/lua/lua_Joint.h

@@ -9,7 +9,7 @@ int lua_Joint__gc(lua_State* state);
 int lua_Joint_addChild(lua_State* state);
 int lua_Joint_addChild(lua_State* state);
 int lua_Joint_addListener(lua_State* state);
 int lua_Joint_addListener(lua_State* state);
 int lua_Joint_addRef(lua_State* state);
 int lua_Joint_addRef(lua_State* state);
-int lua_Joint_addScriptCallback(lua_State* state);
+int lua_Joint_addScript(lua_State* state);
 int lua_Joint_clone(lua_State* state);
 int lua_Joint_clone(lua_State* state);
 int lua_Joint_createAnimation(lua_State* state);
 int lua_Joint_createAnimation(lua_State* state);
 int lua_Joint_createAnimationFromBy(lua_State* state);
 int lua_Joint_createAnimationFromBy(lua_State* state);
@@ -83,7 +83,7 @@ int lua_Joint_release(lua_State* state);
 int lua_Joint_removeAllChildren(lua_State* state);
 int lua_Joint_removeAllChildren(lua_State* state);
 int lua_Joint_removeChild(lua_State* state);
 int lua_Joint_removeChild(lua_State* state);
 int lua_Joint_removeListener(lua_State* state);
 int lua_Joint_removeListener(lua_State* state);
-int lua_Joint_removeScriptCallback(lua_State* state);
+int lua_Joint_removeScript(lua_State* state);
 int lua_Joint_rotate(lua_State* state);
 int lua_Joint_rotate(lua_State* state);
 int lua_Joint_rotateX(lua_State* state);
 int lua_Joint_rotateX(lua_State* state);
 int lua_Joint_rotateY(lua_State* state);
 int lua_Joint_rotateY(lua_State* state);

+ 26 - 28
gameplay/src/lua/lua_JoystickControl.cpp

@@ -29,7 +29,7 @@ void luaRegister_JoystickControl()
     {
     {
         {"addListener", lua_JoystickControl_addListener},
         {"addListener", lua_JoystickControl_addListener},
         {"addRef", lua_JoystickControl_addRef},
         {"addRef", lua_JoystickControl_addRef},
-        {"addScriptCallback", lua_JoystickControl_addScriptCallback},
+        {"addScript", lua_JoystickControl_addScript},
         {"canFocus", lua_JoystickControl_canFocus},
         {"canFocus", lua_JoystickControl_canFocus},
         {"createAnimation", lua_JoystickControl_createAnimation},
         {"createAnimation", lua_JoystickControl_createAnimation},
         {"createAnimationFromBy", lua_JoystickControl_createAnimationFromBy},
         {"createAnimationFromBy", lua_JoystickControl_createAnimationFromBy},
@@ -94,7 +94,7 @@ void luaRegister_JoystickControl()
         {"isYPercentage", lua_JoystickControl_isYPercentage},
         {"isYPercentage", lua_JoystickControl_isYPercentage},
         {"release", lua_JoystickControl_release},
         {"release", lua_JoystickControl_release},
         {"removeListener", lua_JoystickControl_removeListener},
         {"removeListener", lua_JoystickControl_removeListener},
-        {"removeScriptCallback", lua_JoystickControl_removeScriptCallback},
+        {"removeScript", lua_JoystickControl_removeScript},
         {"setAlignment", lua_JoystickControl_setAlignment},
         {"setAlignment", lua_JoystickControl_setAlignment},
         {"setAnimationPropertyValue", lua_JoystickControl_setAnimationPropertyValue},
         {"setAnimationPropertyValue", lua_JoystickControl_setAnimationPropertyValue},
         {"setAutoSize", lua_JoystickControl_setAutoSize},
         {"setAutoSize", lua_JoystickControl_setAutoSize},
@@ -274,7 +274,7 @@ int lua_JoystickControl_addRef(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_JoystickControl_addScriptCallback(lua_State* state)
+int lua_JoystickControl_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -282,31 +282,30 @@ int lua_JoystickControl_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 JoystickControl* instance = getInstance(state);
                 JoystickControl* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_JoystickControl_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_JoystickControl_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -3357,7 +3356,7 @@ int lua_JoystickControl_removeListener(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_JoystickControl_removeScriptCallback(lua_State* state)
+int lua_JoystickControl_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -3365,31 +3364,30 @@ int lua_JoystickControl_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 JoystickControl* instance = getInstance(state);
                 JoystickControl* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_JoystickControl_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_JoystickControl_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 2
gameplay/src/lua/lua_JoystickControl.h

@@ -8,7 +8,7 @@ namespace gameplay
 int lua_JoystickControl__gc(lua_State* state);
 int lua_JoystickControl__gc(lua_State* state);
 int lua_JoystickControl_addListener(lua_State* state);
 int lua_JoystickControl_addListener(lua_State* state);
 int lua_JoystickControl_addRef(lua_State* state);
 int lua_JoystickControl_addRef(lua_State* state);
-int lua_JoystickControl_addScriptCallback(lua_State* state);
+int lua_JoystickControl_addScript(lua_State* state);
 int lua_JoystickControl_canFocus(lua_State* state);
 int lua_JoystickControl_canFocus(lua_State* state);
 int lua_JoystickControl_createAnimation(lua_State* state);
 int lua_JoystickControl_createAnimation(lua_State* state);
 int lua_JoystickControl_createAnimationFromBy(lua_State* state);
 int lua_JoystickControl_createAnimationFromBy(lua_State* state);
@@ -73,7 +73,7 @@ int lua_JoystickControl_isXPercentage(lua_State* state);
 int lua_JoystickControl_isYPercentage(lua_State* state);
 int lua_JoystickControl_isYPercentage(lua_State* state);
 int lua_JoystickControl_release(lua_State* state);
 int lua_JoystickControl_release(lua_State* state);
 int lua_JoystickControl_removeListener(lua_State* state);
 int lua_JoystickControl_removeListener(lua_State* state);
-int lua_JoystickControl_removeScriptCallback(lua_State* state);
+int lua_JoystickControl_removeScript(lua_State* state);
 int lua_JoystickControl_setAlignment(lua_State* state);
 int lua_JoystickControl_setAlignment(lua_State* state);
 int lua_JoystickControl_setAnimationPropertyValue(lua_State* state);
 int lua_JoystickControl_setAnimationPropertyValue(lua_State* state);
 int lua_JoystickControl_setAutoSize(lua_State* state);
 int lua_JoystickControl_setAutoSize(lua_State* state);

+ 26 - 28
gameplay/src/lua/lua_Label.cpp

@@ -29,7 +29,7 @@ void luaRegister_Label()
     {
     {
         {"addListener", lua_Label_addListener},
         {"addListener", lua_Label_addListener},
         {"addRef", lua_Label_addRef},
         {"addRef", lua_Label_addRef},
-        {"addScriptCallback", lua_Label_addScriptCallback},
+        {"addScript", lua_Label_addScript},
         {"canFocus", lua_Label_canFocus},
         {"canFocus", lua_Label_canFocus},
         {"createAnimation", lua_Label_createAnimation},
         {"createAnimation", lua_Label_createAnimation},
         {"createAnimationFromBy", lua_Label_createAnimationFromBy},
         {"createAnimationFromBy", lua_Label_createAnimationFromBy},
@@ -90,7 +90,7 @@ void luaRegister_Label()
         {"isYPercentage", lua_Label_isYPercentage},
         {"isYPercentage", lua_Label_isYPercentage},
         {"release", lua_Label_release},
         {"release", lua_Label_release},
         {"removeListener", lua_Label_removeListener},
         {"removeListener", lua_Label_removeListener},
-        {"removeScriptCallback", lua_Label_removeScriptCallback},
+        {"removeScript", lua_Label_removeScript},
         {"setAlignment", lua_Label_setAlignment},
         {"setAlignment", lua_Label_setAlignment},
         {"setAnimationPropertyValue", lua_Label_setAnimationPropertyValue},
         {"setAnimationPropertyValue", lua_Label_setAnimationPropertyValue},
         {"setAutoSize", lua_Label_setAutoSize},
         {"setAutoSize", lua_Label_setAutoSize},
@@ -268,7 +268,7 @@ int lua_Label_addRef(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Label_addScriptCallback(lua_State* state)
+int lua_Label_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -276,31 +276,30 @@ int lua_Label_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Label* instance = getInstance(state);
                 Label* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Label_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Label_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -3184,7 +3183,7 @@ int lua_Label_removeListener(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Label_removeScriptCallback(lua_State* state)
+int lua_Label_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -3192,31 +3191,30 @@ int lua_Label_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Label* instance = getInstance(state);
                 Label* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Label_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Label_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 2
gameplay/src/lua/lua_Label.h

@@ -8,7 +8,7 @@ namespace gameplay
 int lua_Label__gc(lua_State* state);
 int lua_Label__gc(lua_State* state);
 int lua_Label_addListener(lua_State* state);
 int lua_Label_addListener(lua_State* state);
 int lua_Label_addRef(lua_State* state);
 int lua_Label_addRef(lua_State* state);
-int lua_Label_addScriptCallback(lua_State* state);
+int lua_Label_addScript(lua_State* state);
 int lua_Label_canFocus(lua_State* state);
 int lua_Label_canFocus(lua_State* state);
 int lua_Label_createAnimation(lua_State* state);
 int lua_Label_createAnimation(lua_State* state);
 int lua_Label_createAnimationFromBy(lua_State* state);
 int lua_Label_createAnimationFromBy(lua_State* state);
@@ -69,7 +69,7 @@ int lua_Label_isXPercentage(lua_State* state);
 int lua_Label_isYPercentage(lua_State* state);
 int lua_Label_isYPercentage(lua_State* state);
 int lua_Label_release(lua_State* state);
 int lua_Label_release(lua_State* state);
 int lua_Label_removeListener(lua_State* state);
 int lua_Label_removeListener(lua_State* state);
-int lua_Label_removeScriptCallback(lua_State* state);
+int lua_Label_removeScript(lua_State* state);
 int lua_Label_setAlignment(lua_State* state);
 int lua_Label_setAlignment(lua_State* state);
 int lua_Label_setAnimationPropertyValue(lua_State* state);
 int lua_Label_setAnimationPropertyValue(lua_State* state);
 int lua_Label_setAutoSize(lua_State* state);
 int lua_Label_setAutoSize(lua_State* state);

+ 26 - 28
gameplay/src/lua/lua_Node.cpp

@@ -33,7 +33,7 @@ void luaRegister_Node()
         {"addChild", lua_Node_addChild},
         {"addChild", lua_Node_addChild},
         {"addListener", lua_Node_addListener},
         {"addListener", lua_Node_addListener},
         {"addRef", lua_Node_addRef},
         {"addRef", lua_Node_addRef},
-        {"addScriptCallback", lua_Node_addScriptCallback},
+        {"addScript", lua_Node_addScript},
         {"clone", lua_Node_clone},
         {"clone", lua_Node_clone},
         {"createAnimation", lua_Node_createAnimation},
         {"createAnimation", lua_Node_createAnimation},
         {"createAnimationFromBy", lua_Node_createAnimationFromBy},
         {"createAnimationFromBy", lua_Node_createAnimationFromBy},
@@ -106,7 +106,7 @@ void luaRegister_Node()
         {"removeAllChildren", lua_Node_removeAllChildren},
         {"removeAllChildren", lua_Node_removeAllChildren},
         {"removeChild", lua_Node_removeChild},
         {"removeChild", lua_Node_removeChild},
         {"removeListener", lua_Node_removeListener},
         {"removeListener", lua_Node_removeListener},
-        {"removeScriptCallback", lua_Node_removeScriptCallback},
+        {"removeScript", lua_Node_removeScript},
         {"rotate", lua_Node_rotate},
         {"rotate", lua_Node_rotate},
         {"rotateX", lua_Node_rotateX},
         {"rotateX", lua_Node_rotateX},
         {"rotateY", lua_Node_rotateY},
         {"rotateY", lua_Node_rotateY},
@@ -368,7 +368,7 @@ int lua_Node_addRef(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Node_addScriptCallback(lua_State* state)
+int lua_Node_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -376,31 +376,30 @@ int lua_Node_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Node* instance = getInstance(state);
                 Node* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Node_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Node_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -4019,7 +4018,7 @@ int lua_Node_removeListener(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Node_removeScriptCallback(lua_State* state)
+int lua_Node_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -4027,31 +4026,30 @@ int lua_Node_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Node* instance = getInstance(state);
                 Node* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Node_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Node_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 2
gameplay/src/lua/lua_Node.h

@@ -9,7 +9,7 @@ int lua_Node__gc(lua_State* state);
 int lua_Node_addChild(lua_State* state);
 int lua_Node_addChild(lua_State* state);
 int lua_Node_addListener(lua_State* state);
 int lua_Node_addListener(lua_State* state);
 int lua_Node_addRef(lua_State* state);
 int lua_Node_addRef(lua_State* state);
-int lua_Node_addScriptCallback(lua_State* state);
+int lua_Node_addScript(lua_State* state);
 int lua_Node_clone(lua_State* state);
 int lua_Node_clone(lua_State* state);
 int lua_Node_createAnimation(lua_State* state);
 int lua_Node_createAnimation(lua_State* state);
 int lua_Node_createAnimationFromBy(lua_State* state);
 int lua_Node_createAnimationFromBy(lua_State* state);
@@ -82,7 +82,7 @@ int lua_Node_release(lua_State* state);
 int lua_Node_removeAllChildren(lua_State* state);
 int lua_Node_removeAllChildren(lua_State* state);
 int lua_Node_removeChild(lua_State* state);
 int lua_Node_removeChild(lua_State* state);
 int lua_Node_removeListener(lua_State* state);
 int lua_Node_removeListener(lua_State* state);
-int lua_Node_removeScriptCallback(lua_State* state);
+int lua_Node_removeScript(lua_State* state);
 int lua_Node_rotate(lua_State* state);
 int lua_Node_rotate(lua_State* state);
 int lua_Node_rotateX(lua_State* state);
 int lua_Node_rotateX(lua_State* state);
 int lua_Node_rotateY(lua_State* state);
 int lua_Node_rotateY(lua_State* state);

+ 26 - 28
gameplay/src/lua/lua_PhysicsController.cpp

@@ -20,7 +20,7 @@ void luaRegister_PhysicsController()
 {
 {
     const luaL_Reg lua_members[] = 
     const luaL_Reg lua_members[] = 
     {
     {
-        {"addScriptCallback", lua_PhysicsController_addScriptCallback},
+        {"addScript", lua_PhysicsController_addScript},
         {"addStatusListener", lua_PhysicsController_addStatusListener},
         {"addStatusListener", lua_PhysicsController_addStatusListener},
         {"createFixedConstraint", lua_PhysicsController_createFixedConstraint},
         {"createFixedConstraint", lua_PhysicsController_createFixedConstraint},
         {"createGenericConstraint", lua_PhysicsController_createGenericConstraint},
         {"createGenericConstraint", lua_PhysicsController_createGenericConstraint},
@@ -30,7 +30,7 @@ void luaRegister_PhysicsController()
         {"drawDebug", lua_PhysicsController_drawDebug},
         {"drawDebug", lua_PhysicsController_drawDebug},
         {"getGravity", lua_PhysicsController_getGravity},
         {"getGravity", lua_PhysicsController_getGravity},
         {"rayTest", lua_PhysicsController_rayTest},
         {"rayTest", lua_PhysicsController_rayTest},
-        {"removeScriptCallback", lua_PhysicsController_removeScriptCallback},
+        {"removeScript", lua_PhysicsController_removeScript},
         {"removeStatusListener", lua_PhysicsController_removeStatusListener},
         {"removeStatusListener", lua_PhysicsController_removeStatusListener},
         {"setGravity", lua_PhysicsController_setGravity},
         {"setGravity", lua_PhysicsController_setGravity},
         {"sweepTest", lua_PhysicsController_sweepTest},
         {"sweepTest", lua_PhysicsController_sweepTest},
@@ -49,7 +49,7 @@ static PhysicsController* getInstance(lua_State* state)
     return (PhysicsController*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
     return (PhysicsController*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
 }
 }
 
 
-int lua_PhysicsController_addScriptCallback(lua_State* state)
+int lua_PhysicsController_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -57,31 +57,30 @@ int lua_PhysicsController_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 PhysicsController* instance = getInstance(state);
                 PhysicsController* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_PhysicsController_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_PhysicsController_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -1472,7 +1471,7 @@ int lua_PhysicsController_rayTest(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_PhysicsController_removeScriptCallback(lua_State* state)
+int lua_PhysicsController_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -1480,31 +1479,30 @@ int lua_PhysicsController_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 PhysicsController* instance = getInstance(state);
                 PhysicsController* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_PhysicsController_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_PhysicsController_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 2
gameplay/src/lua/lua_PhysicsController.h

@@ -5,7 +5,7 @@ namespace gameplay
 {
 {
 
 
 // Lua bindings for PhysicsController.
 // Lua bindings for PhysicsController.
-int lua_PhysicsController_addScriptCallback(lua_State* state);
+int lua_PhysicsController_addScript(lua_State* state);
 int lua_PhysicsController_addStatusListener(lua_State* state);
 int lua_PhysicsController_addStatusListener(lua_State* state);
 int lua_PhysicsController_createFixedConstraint(lua_State* state);
 int lua_PhysicsController_createFixedConstraint(lua_State* state);
 int lua_PhysicsController_createGenericConstraint(lua_State* state);
 int lua_PhysicsController_createGenericConstraint(lua_State* state);
@@ -15,7 +15,7 @@ int lua_PhysicsController_createSpringConstraint(lua_State* state);
 int lua_PhysicsController_drawDebug(lua_State* state);
 int lua_PhysicsController_drawDebug(lua_State* state);
 int lua_PhysicsController_getGravity(lua_State* state);
 int lua_PhysicsController_getGravity(lua_State* state);
 int lua_PhysicsController_rayTest(lua_State* state);
 int lua_PhysicsController_rayTest(lua_State* state);
-int lua_PhysicsController_removeScriptCallback(lua_State* state);
+int lua_PhysicsController_removeScript(lua_State* state);
 int lua_PhysicsController_removeStatusListener(lua_State* state);
 int lua_PhysicsController_removeStatusListener(lua_State* state);
 int lua_PhysicsController_setGravity(lua_State* state);
 int lua_PhysicsController_setGravity(lua_State* state);
 int lua_PhysicsController_sweepTest(lua_State* state);
 int lua_PhysicsController_sweepTest(lua_State* state);

+ 26 - 28
gameplay/src/lua/lua_RadioButton.cpp

@@ -32,7 +32,7 @@ void luaRegister_RadioButton()
     {
     {
         {"addListener", lua_RadioButton_addListener},
         {"addListener", lua_RadioButton_addListener},
         {"addRef", lua_RadioButton_addRef},
         {"addRef", lua_RadioButton_addRef},
-        {"addScriptCallback", lua_RadioButton_addScriptCallback},
+        {"addScript", lua_RadioButton_addScript},
         {"canFocus", lua_RadioButton_canFocus},
         {"canFocus", lua_RadioButton_canFocus},
         {"createAnimation", lua_RadioButton_createAnimation},
         {"createAnimation", lua_RadioButton_createAnimation},
         {"createAnimationFromBy", lua_RadioButton_createAnimationFromBy},
         {"createAnimationFromBy", lua_RadioButton_createAnimationFromBy},
@@ -95,7 +95,7 @@ void luaRegister_RadioButton()
         {"isYPercentage", lua_RadioButton_isYPercentage},
         {"isYPercentage", lua_RadioButton_isYPercentage},
         {"release", lua_RadioButton_release},
         {"release", lua_RadioButton_release},
         {"removeListener", lua_RadioButton_removeListener},
         {"removeListener", lua_RadioButton_removeListener},
-        {"removeScriptCallback", lua_RadioButton_removeScriptCallback},
+        {"removeScript", lua_RadioButton_removeScript},
         {"setAlignment", lua_RadioButton_setAlignment},
         {"setAlignment", lua_RadioButton_setAlignment},
         {"setAnimationPropertyValue", lua_RadioButton_setAnimationPropertyValue},
         {"setAnimationPropertyValue", lua_RadioButton_setAnimationPropertyValue},
         {"setAutoSize", lua_RadioButton_setAutoSize},
         {"setAutoSize", lua_RadioButton_setAutoSize},
@@ -275,7 +275,7 @@ int lua_RadioButton_addRef(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_RadioButton_addScriptCallback(lua_State* state)
+int lua_RadioButton_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -283,31 +283,30 @@ int lua_RadioButton_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 RadioButton* instance = getInstance(state);
                 RadioButton* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_RadioButton_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_RadioButton_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -3261,7 +3260,7 @@ int lua_RadioButton_removeListener(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_RadioButton_removeScriptCallback(lua_State* state)
+int lua_RadioButton_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -3269,31 +3268,30 @@ int lua_RadioButton_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 RadioButton* instance = getInstance(state);
                 RadioButton* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_RadioButton_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_RadioButton_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 2
gameplay/src/lua/lua_RadioButton.h

@@ -8,7 +8,7 @@ namespace gameplay
 int lua_RadioButton__gc(lua_State* state);
 int lua_RadioButton__gc(lua_State* state);
 int lua_RadioButton_addListener(lua_State* state);
 int lua_RadioButton_addListener(lua_State* state);
 int lua_RadioButton_addRef(lua_State* state);
 int lua_RadioButton_addRef(lua_State* state);
-int lua_RadioButton_addScriptCallback(lua_State* state);
+int lua_RadioButton_addScript(lua_State* state);
 int lua_RadioButton_canFocus(lua_State* state);
 int lua_RadioButton_canFocus(lua_State* state);
 int lua_RadioButton_createAnimation(lua_State* state);
 int lua_RadioButton_createAnimation(lua_State* state);
 int lua_RadioButton_createAnimationFromBy(lua_State* state);
 int lua_RadioButton_createAnimationFromBy(lua_State* state);
@@ -71,7 +71,7 @@ int lua_RadioButton_isXPercentage(lua_State* state);
 int lua_RadioButton_isYPercentage(lua_State* state);
 int lua_RadioButton_isYPercentage(lua_State* state);
 int lua_RadioButton_release(lua_State* state);
 int lua_RadioButton_release(lua_State* state);
 int lua_RadioButton_removeListener(lua_State* state);
 int lua_RadioButton_removeListener(lua_State* state);
-int lua_RadioButton_removeScriptCallback(lua_State* state);
+int lua_RadioButton_removeScript(lua_State* state);
 int lua_RadioButton_setAlignment(lua_State* state);
 int lua_RadioButton_setAlignment(lua_State* state);
 int lua_RadioButton_setAnimationPropertyValue(lua_State* state);
 int lua_RadioButton_setAnimationPropertyValue(lua_State* state);
 int lua_RadioButton_setAutoSize(lua_State* state);
 int lua_RadioButton_setAutoSize(lua_State* state);

+ 115 - 7
gameplay/src/lua/lua_ScriptController.cpp

@@ -13,8 +13,10 @@ void luaRegister_ScriptController()
     const luaL_Reg lua_members[] = 
     const luaL_Reg lua_members[] = 
     {
     {
         {"loadScript", lua_ScriptController_loadScript},
         {"loadScript", lua_ScriptController_loadScript},
+        {"loadScriptIsolated", lua_ScriptController_loadScriptIsolated},
         {"loadUrl", lua_ScriptController_loadUrl},
         {"loadUrl", lua_ScriptController_loadUrl},
         {"registerCallback", lua_ScriptController_registerCallback},
         {"registerCallback", lua_ScriptController_registerCallback},
+        {"unloadScript", lua_ScriptController_unloadScript},
         {"unregisterCallback", lua_ScriptController_unregisterCallback},
         {"unregisterCallback", lua_ScriptController_unregisterCallback},
         {NULL, NULL}
         {NULL, NULL}
     };
     };
@@ -52,9 +54,12 @@ int lua_ScriptController_loadScript(lua_State* state)
                 const char* param1 = gameplay::ScriptUtil::getString(2, false);
                 const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 ScriptController* instance = getInstance(state);
                 ScriptController* instance = getInstance(state);
-                instance->loadScript(param1);
-                
-                return 0;
+                bool result = instance->loadScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
             lua_pushstring(state, "lua_ScriptController_loadScript - Failed to match the given parameters to a valid function signature.");
             lua_pushstring(state, "lua_ScriptController_loadScript - Failed to match the given parameters to a valid function signature.");
@@ -74,9 +79,12 @@ int lua_ScriptController_loadScript(lua_State* state)
                 bool param2 = gameplay::ScriptUtil::luaCheckBool(state, 3);
                 bool param2 = gameplay::ScriptUtil::luaCheckBool(state, 3);
 
 
                 ScriptController* instance = getInstance(state);
                 ScriptController* instance = getInstance(state);
-                instance->loadScript(param1, param2);
-                
-                return 0;
+                bool result = instance->loadScript(param1, param2);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
             lua_pushstring(state, "lua_ScriptController_loadScript - Failed to match the given parameters to a valid function signature.");
             lua_pushstring(state, "lua_ScriptController_loadScript - Failed to match the given parameters to a valid function signature.");
@@ -93,6 +101,45 @@ int lua_ScriptController_loadScript(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_ScriptController_loadScriptIsolated(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                ScriptController* instance = getInstance(state);
+                int result = instance->loadScriptIsolated(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_ScriptController_loadScriptIsolated - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_ScriptController_loadUrl(lua_State* state)
 int lua_ScriptController_loadUrl(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -122,9 +169,34 @@ int lua_ScriptController_loadUrl(lua_State* state)
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
+        case 3:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
+                (lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TLIGHTUSERDATA))
+            {
+                // Get parameter 1 off the stack.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                // Get parameter 2 off the stack.
+                gameplay::ScriptUtil::LuaArray<int> param2 = gameplay::ScriptUtil::getIntPointer(3);
+
+                ScriptController* instance = getInstance(state);
+                std::string result = instance->loadUrl(param1, param2);
+
+                // Push the return value onto the stack.
+                lua_pushstring(state, result.c_str());
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_ScriptController_loadUrl - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2 or 3).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -232,6 +304,42 @@ int lua_ScriptController_static_print(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_ScriptController_unloadScript(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                int param1 = (int)luaL_checkint(state, 2);
+
+                ScriptController* instance = getInstance(state);
+                instance->unloadScript(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_ScriptController_unloadScript - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_ScriptController_unregisterCallback(lua_State* state)
 int lua_ScriptController_unregisterCallback(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.

+ 2 - 0
gameplay/src/lua/lua_ScriptController.h

@@ -6,9 +6,11 @@ namespace gameplay
 
 
 // Lua bindings for ScriptController.
 // Lua bindings for ScriptController.
 int lua_ScriptController_loadScript(lua_State* state);
 int lua_ScriptController_loadScript(lua_State* state);
+int lua_ScriptController_loadScriptIsolated(lua_State* state);
 int lua_ScriptController_loadUrl(lua_State* state);
 int lua_ScriptController_loadUrl(lua_State* state);
 int lua_ScriptController_registerCallback(lua_State* state);
 int lua_ScriptController_registerCallback(lua_State* state);
 int lua_ScriptController_static_print(lua_State* state);
 int lua_ScriptController_static_print(lua_State* state);
+int lua_ScriptController_unloadScript(lua_State* state);
 int lua_ScriptController_unregisterCallback(lua_State* state);
 int lua_ScriptController_unregisterCallback(lua_State* state);
 
 
 void luaRegister_ScriptController();
 void luaRegister_ScriptController();

+ 26 - 28
gameplay/src/lua/lua_ScriptTarget.cpp

@@ -12,8 +12,8 @@ void luaRegister_ScriptTarget()
 {
 {
     const luaL_Reg lua_members[] = 
     const luaL_Reg lua_members[] = 
     {
     {
-        {"addScriptCallback", lua_ScriptTarget_addScriptCallback},
-        {"removeScriptCallback", lua_ScriptTarget_removeScriptCallback},
+        {"addScript", lua_ScriptTarget_addScript},
+        {"removeScript", lua_ScriptTarget_removeScript},
         {NULL, NULL}
         {NULL, NULL}
     };
     };
     const luaL_Reg* lua_statics = NULL;
     const luaL_Reg* lua_statics = NULL;
@@ -29,7 +29,7 @@ static ScriptTarget* getInstance(lua_State* state)
     return (ScriptTarget*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
     return (ScriptTarget*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
 }
 }
 
 
-int lua_ScriptTarget_addScriptCallback(lua_State* state)
+int lua_ScriptTarget_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -37,31 +37,30 @@ int lua_ScriptTarget_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 ScriptTarget* instance = getInstance(state);
                 ScriptTarget* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_ScriptTarget_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_ScriptTarget_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -69,7 +68,7 @@ int lua_ScriptTarget_addScriptCallback(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_ScriptTarget_removeScriptCallback(lua_State* state)
+int lua_ScriptTarget_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -77,31 +76,30 @@ int lua_ScriptTarget_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 ScriptTarget* instance = getInstance(state);
                 ScriptTarget* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_ScriptTarget_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_ScriptTarget_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 2
gameplay/src/lua/lua_ScriptTarget.h

@@ -5,8 +5,8 @@ namespace gameplay
 {
 {
 
 
 // Lua bindings for ScriptTarget.
 // Lua bindings for ScriptTarget.
-int lua_ScriptTarget_addScriptCallback(lua_State* state);
-int lua_ScriptTarget_removeScriptCallback(lua_State* state);
+int lua_ScriptTarget_addScript(lua_State* state);
+int lua_ScriptTarget_removeScript(lua_State* state);
 
 
 void luaRegister_ScriptTarget();
 void luaRegister_ScriptTarget();
 
 

+ 197 - 0
gameplay/src/lua/lua_ScriptTargetEventRegistryEvent.cpp

@@ -0,0 +1,197 @@
+#include "Base.h"
+#include "ScriptController.h"
+#include "lua_ScriptTargetEventRegistryEvent.h"
+#include "Base.h"
+#include "ScriptController.h"
+#include "ScriptTarget.h"
+
+namespace gameplay
+{
+
+void luaRegister_ScriptTargetEventRegistryEvent()
+{
+    const luaL_Reg lua_members[] = 
+    {
+        {"args", lua_ScriptTargetEventRegistryEvent_args},
+        {"name", lua_ScriptTargetEventRegistryEvent_name},
+        {"registry", lua_ScriptTargetEventRegistryEvent_registry},
+        {NULL, NULL}
+    };
+    const luaL_Reg* lua_statics = NULL;
+    std::vector<std::string> scopePath;
+    scopePath.push_back("ScriptTarget");
+    scopePath.push_back("EventRegistry");
+
+    gameplay::ScriptUtil::registerClass("ScriptTargetEventRegistryEvent", lua_members, lua_ScriptTargetEventRegistryEvent__init, lua_ScriptTargetEventRegistryEvent__gc, lua_statics, scopePath);
+}
+
+static ScriptTarget::EventRegistry::Event* getInstance(lua_State* state)
+{
+    void* userdata = luaL_checkudata(state, 1, "ScriptTargetEventRegistryEvent");
+    luaL_argcheck(state, userdata != NULL, 1, "'ScriptTargetEventRegistryEvent' expected.");
+    return (ScriptTarget::EventRegistry::Event*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
+}
+
+int lua_ScriptTargetEventRegistryEvent__gc(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                void* userdata = luaL_checkudata(state, 1, "ScriptTargetEventRegistryEvent");
+                luaL_argcheck(state, userdata != NULL, 1, "'ScriptTargetEventRegistryEvent' expected.");
+                gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata;
+                if (object->owns)
+                {
+                    ScriptTarget::EventRegistry::Event* instance = (ScriptTarget::EventRegistry::Event*)object->instance;
+                    SAFE_DELETE(instance);
+                }
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_ScriptTargetEventRegistryEvent__gc - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_ScriptTargetEventRegistryEvent__init(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 0:
+        {
+            void* returnPtr = (void*)new ScriptTarget::EventRegistry::Event();
+            if (returnPtr)
+            {
+                gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                object->instance = returnPtr;
+                object->owns = true;
+                luaL_getmetatable(state, "ScriptTargetEventRegistryEvent");
+                lua_setmetatable(state, -2);
+            }
+            else
+            {
+                lua_pushnil(state);
+            }
+
+            return 1;
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 0).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_ScriptTargetEventRegistryEvent_args(lua_State* state)
+{
+    // Validate the number of parameters.
+    if (lua_gettop(state) > 2)
+    {
+        lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
+        lua_error(state);
+    }
+
+    ScriptTarget::EventRegistry::Event* instance = getInstance(state);
+    if (lua_gettop(state) == 2)
+    {
+        // Get parameter 2 off the stack.
+        std::string param2 = gameplay::ScriptUtil::getString(2, true);
+
+        instance->args = param2;
+        return 0;
+    }
+    else
+    {
+        std::string result = instance->args;
+
+        // Push the return value onto the stack.
+        lua_pushstring(state, result.c_str());
+
+        return 1;
+    }
+}
+
+int lua_ScriptTargetEventRegistryEvent_name(lua_State* state)
+{
+    // Validate the number of parameters.
+    if (lua_gettop(state) > 2)
+    {
+        lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
+        lua_error(state);
+    }
+
+    ScriptTarget::EventRegistry::Event* instance = getInstance(state);
+    if (lua_gettop(state) == 2)
+    {
+        // Get parameter 2 off the stack.
+        std::string param2 = gameplay::ScriptUtil::getString(2, true);
+
+        instance->name = param2;
+        return 0;
+    }
+    else
+    {
+        std::string result = instance->name;
+
+        // Push the return value onto the stack.
+        lua_pushstring(state, result.c_str());
+
+        return 1;
+    }
+}
+
+int lua_ScriptTargetEventRegistryEvent_registry(lua_State* state)
+{
+    // Validate the number of parameters.
+    if (lua_gettop(state) > 2)
+    {
+        lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
+        lua_error(state);
+    }
+
+    ScriptTarget::EventRegistry::Event* instance = getInstance(state);
+    if (lua_gettop(state) == 2)
+    {
+        // Get parameter 2 off the stack.
+        GP_WARN("Attempting to get parameter 2 with unrecognized type classgameplay_1_1_script_target_1_1_event_registry as an unsigned integer.");
+        classgameplay_1_1_script_target_1_1_event_registry* param2 = (classgameplay_1_1_script_target_1_1_event_registry)luaL_checkunsigned(state, 2);
+
+        memcpy(instance->registry, param2, sizeof() * classgameplay_1_1_script_target_1_1_event_registry);
+        return 0;
+    }
+    else
+    {
+        classgameplay_1_1_script_target_1_1_event_registry* result = instance->registry;
+
+        // Push the return value onto the stack.
+        lua_pushlightuserdata(state, result);
+        return 1;
+    }
+}
+
+}

+ 18 - 0
gameplay/src/lua/lua_ScriptTargetEventRegistryEvent.h

@@ -0,0 +1,18 @@
+#ifndef LUA_SCRIPTTARGETEVENTREGISTRYEVENT_H_
+#define LUA_SCRIPTTARGETEVENTREGISTRYEVENT_H_
+
+namespace gameplay
+{
+
+// Lua bindings for ScriptTarget::EventRegistry::Event.
+int lua_ScriptTargetEventRegistryEvent__gc(lua_State* state);
+int lua_ScriptTargetEventRegistryEvent__init(lua_State* state);
+int lua_ScriptTargetEventRegistryEvent_args(lua_State* state);
+int lua_ScriptTargetEventRegistryEvent_name(lua_State* state);
+int lua_ScriptTargetEventRegistryEvent_registry(lua_State* state);
+
+void luaRegister_ScriptTargetEventRegistryEvent();
+
+}
+
+#endif

+ 26 - 28
gameplay/src/lua/lua_Slider.cpp

@@ -30,7 +30,7 @@ void luaRegister_Slider()
     {
     {
         {"addListener", lua_Slider_addListener},
         {"addListener", lua_Slider_addListener},
         {"addRef", lua_Slider_addRef},
         {"addRef", lua_Slider_addRef},
-        {"addScriptCallback", lua_Slider_addScriptCallback},
+        {"addScript", lua_Slider_addScript},
         {"canFocus", lua_Slider_canFocus},
         {"canFocus", lua_Slider_canFocus},
         {"createAnimation", lua_Slider_createAnimation},
         {"createAnimation", lua_Slider_createAnimation},
         {"createAnimationFromBy", lua_Slider_createAnimationFromBy},
         {"createAnimationFromBy", lua_Slider_createAnimationFromBy},
@@ -98,7 +98,7 @@ void luaRegister_Slider()
         {"isYPercentage", lua_Slider_isYPercentage},
         {"isYPercentage", lua_Slider_isYPercentage},
         {"release", lua_Slider_release},
         {"release", lua_Slider_release},
         {"removeListener", lua_Slider_removeListener},
         {"removeListener", lua_Slider_removeListener},
-        {"removeScriptCallback", lua_Slider_removeScriptCallback},
+        {"removeScript", lua_Slider_removeScript},
         {"setAlignment", lua_Slider_setAlignment},
         {"setAlignment", lua_Slider_setAlignment},
         {"setAnimationPropertyValue", lua_Slider_setAnimationPropertyValue},
         {"setAnimationPropertyValue", lua_Slider_setAnimationPropertyValue},
         {"setAutoSize", lua_Slider_setAutoSize},
         {"setAutoSize", lua_Slider_setAutoSize},
@@ -283,7 +283,7 @@ int lua_Slider_addRef(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Slider_addScriptCallback(lua_State* state)
+int lua_Slider_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -291,31 +291,30 @@ int lua_Slider_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Slider* instance = getInstance(state);
                 Slider* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Slider_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Slider_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -3444,7 +3443,7 @@ int lua_Slider_removeListener(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Slider_removeScriptCallback(lua_State* state)
+int lua_Slider_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -3452,31 +3451,30 @@ int lua_Slider_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Slider* instance = getInstance(state);
                 Slider* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Slider_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Slider_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 2
gameplay/src/lua/lua_Slider.h

@@ -8,7 +8,7 @@ namespace gameplay
 int lua_Slider__gc(lua_State* state);
 int lua_Slider__gc(lua_State* state);
 int lua_Slider_addListener(lua_State* state);
 int lua_Slider_addListener(lua_State* state);
 int lua_Slider_addRef(lua_State* state);
 int lua_Slider_addRef(lua_State* state);
-int lua_Slider_addScriptCallback(lua_State* state);
+int lua_Slider_addScript(lua_State* state);
 int lua_Slider_canFocus(lua_State* state);
 int lua_Slider_canFocus(lua_State* state);
 int lua_Slider_createAnimation(lua_State* state);
 int lua_Slider_createAnimation(lua_State* state);
 int lua_Slider_createAnimationFromBy(lua_State* state);
 int lua_Slider_createAnimationFromBy(lua_State* state);
@@ -76,7 +76,7 @@ int lua_Slider_isXPercentage(lua_State* state);
 int lua_Slider_isYPercentage(lua_State* state);
 int lua_Slider_isYPercentage(lua_State* state);
 int lua_Slider_release(lua_State* state);
 int lua_Slider_release(lua_State* state);
 int lua_Slider_removeListener(lua_State* state);
 int lua_Slider_removeListener(lua_State* state);
-int lua_Slider_removeScriptCallback(lua_State* state);
+int lua_Slider_removeScript(lua_State* state);
 int lua_Slider_setAlignment(lua_State* state);
 int lua_Slider_setAlignment(lua_State* state);
 int lua_Slider_setAnimationPropertyValue(lua_State* state);
 int lua_Slider_setAnimationPropertyValue(lua_State* state);
 int lua_Slider_setAutoSize(lua_State* state);
 int lua_Slider_setAutoSize(lua_State* state);

+ 26 - 28
gameplay/src/lua/lua_TextBox.cpp

@@ -31,7 +31,7 @@ void luaRegister_TextBox()
     {
     {
         {"addListener", lua_TextBox_addListener},
         {"addListener", lua_TextBox_addListener},
         {"addRef", lua_TextBox_addRef},
         {"addRef", lua_TextBox_addRef},
-        {"addScriptCallback", lua_TextBox_addScriptCallback},
+        {"addScript", lua_TextBox_addScript},
         {"canFocus", lua_TextBox_canFocus},
         {"canFocus", lua_TextBox_canFocus},
         {"createAnimation", lua_TextBox_createAnimation},
         {"createAnimation", lua_TextBox_createAnimation},
         {"createAnimationFromBy", lua_TextBox_createAnimationFromBy},
         {"createAnimationFromBy", lua_TextBox_createAnimationFromBy},
@@ -96,7 +96,7 @@ void luaRegister_TextBox()
         {"isYPercentage", lua_TextBox_isYPercentage},
         {"isYPercentage", lua_TextBox_isYPercentage},
         {"release", lua_TextBox_release},
         {"release", lua_TextBox_release},
         {"removeListener", lua_TextBox_removeListener},
         {"removeListener", lua_TextBox_removeListener},
-        {"removeScriptCallback", lua_TextBox_removeScriptCallback},
+        {"removeScript", lua_TextBox_removeScript},
         {"setAlignment", lua_TextBox_setAlignment},
         {"setAlignment", lua_TextBox_setAlignment},
         {"setAnimationPropertyValue", lua_TextBox_setAnimationPropertyValue},
         {"setAnimationPropertyValue", lua_TextBox_setAnimationPropertyValue},
         {"setAutoSize", lua_TextBox_setAutoSize},
         {"setAutoSize", lua_TextBox_setAutoSize},
@@ -277,7 +277,7 @@ int lua_TextBox_addRef(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_TextBox_addScriptCallback(lua_State* state)
+int lua_TextBox_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -285,31 +285,30 @@ int lua_TextBox_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 TextBox* instance = getInstance(state);
                 TextBox* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_TextBox_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_TextBox_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -3333,7 +3332,7 @@ int lua_TextBox_removeListener(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_TextBox_removeScriptCallback(lua_State* state)
+int lua_TextBox_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -3341,31 +3340,30 @@ int lua_TextBox_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 TextBox* instance = getInstance(state);
                 TextBox* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_TextBox_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_TextBox_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 2
gameplay/src/lua/lua_TextBox.h

@@ -8,7 +8,7 @@ namespace gameplay
 int lua_TextBox__gc(lua_State* state);
 int lua_TextBox__gc(lua_State* state);
 int lua_TextBox_addListener(lua_State* state);
 int lua_TextBox_addListener(lua_State* state);
 int lua_TextBox_addRef(lua_State* state);
 int lua_TextBox_addRef(lua_State* state);
-int lua_TextBox_addScriptCallback(lua_State* state);
+int lua_TextBox_addScript(lua_State* state);
 int lua_TextBox_canFocus(lua_State* state);
 int lua_TextBox_canFocus(lua_State* state);
 int lua_TextBox_createAnimation(lua_State* state);
 int lua_TextBox_createAnimation(lua_State* state);
 int lua_TextBox_createAnimationFromBy(lua_State* state);
 int lua_TextBox_createAnimationFromBy(lua_State* state);
@@ -73,7 +73,7 @@ int lua_TextBox_isXPercentage(lua_State* state);
 int lua_TextBox_isYPercentage(lua_State* state);
 int lua_TextBox_isYPercentage(lua_State* state);
 int lua_TextBox_release(lua_State* state);
 int lua_TextBox_release(lua_State* state);
 int lua_TextBox_removeListener(lua_State* state);
 int lua_TextBox_removeListener(lua_State* state);
-int lua_TextBox_removeScriptCallback(lua_State* state);
+int lua_TextBox_removeScript(lua_State* state);
 int lua_TextBox_setAlignment(lua_State* state);
 int lua_TextBox_setAlignment(lua_State* state);
 int lua_TextBox_setAnimationPropertyValue(lua_State* state);
 int lua_TextBox_setAnimationPropertyValue(lua_State* state);
 int lua_TextBox_setAutoSize(lua_State* state);
 int lua_TextBox_setAutoSize(lua_State* state);

+ 22 - 1
gameplay/src/lua/lua_Touch.cpp

@@ -12,7 +12,11 @@ void luaRegister_Touch()
     {
     {
         {NULL, NULL}
         {NULL, NULL}
     };
     };
-    const luaL_Reg* lua_statics = NULL;
+    const luaL_Reg lua_statics[] = 
+    {
+        {"MAX_TOUCH_POINTS", lua_Touch_static_MAX_TOUCH_POINTS},
+        {NULL, NULL}
+    };
     std::vector<std::string> scopePath;
     std::vector<std::string> scopePath;
 
 
     gameplay::ScriptUtil::registerClass("Touch", lua_members, NULL, lua_Touch__gc, lua_statics, scopePath);
     gameplay::ScriptUtil::registerClass("Touch", lua_members, NULL, lua_Touch__gc, lua_statics, scopePath);
@@ -63,4 +67,21 @@ int lua_Touch__gc(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Touch_static_MAX_TOUCH_POINTS(lua_State* state)
+{
+    // Validate the number of parameters.
+    if (lua_gettop(state) > 0)
+    {
+        lua_pushstring(state, "Invalid number of parameters (expected 0).");
+        lua_error(state);
+    }
+
+    unsigned int result = Touch::MAX_TOUCH_POINTS;
+
+    // Push the return value onto the stack.
+    lua_pushunsigned(state, result);
+
+    return 1;
+}
+
 }
 }

+ 1 - 0
gameplay/src/lua/lua_Touch.h

@@ -6,6 +6,7 @@ namespace gameplay
 
 
 // Lua bindings for Touch.
 // Lua bindings for Touch.
 int lua_Touch__gc(lua_State* state);
 int lua_Touch__gc(lua_State* state);
+int lua_Touch_static_MAX_TOUCH_POINTS(lua_State* state);
 
 
 void luaRegister_Touch();
 void luaRegister_Touch();
 
 

+ 26 - 28
gameplay/src/lua/lua_Transform.cpp

@@ -19,7 +19,7 @@ void luaRegister_Transform()
     const luaL_Reg lua_members[] = 
     const luaL_Reg lua_members[] = 
     {
     {
         {"addListener", lua_Transform_addListener},
         {"addListener", lua_Transform_addListener},
-        {"addScriptCallback", lua_Transform_addScriptCallback},
+        {"addScript", lua_Transform_addScript},
         {"createAnimation", lua_Transform_createAnimation},
         {"createAnimation", lua_Transform_createAnimation},
         {"createAnimationFromBy", lua_Transform_createAnimationFromBy},
         {"createAnimationFromBy", lua_Transform_createAnimationFromBy},
         {"createAnimationFromTo", lua_Transform_createAnimationFromTo},
         {"createAnimationFromTo", lua_Transform_createAnimationFromTo},
@@ -45,7 +45,7 @@ void luaRegister_Transform()
         {"getUpVector", lua_Transform_getUpVector},
         {"getUpVector", lua_Transform_getUpVector},
         {"isStatic", lua_Transform_isStatic},
         {"isStatic", lua_Transform_isStatic},
         {"removeListener", lua_Transform_removeListener},
         {"removeListener", lua_Transform_removeListener},
-        {"removeScriptCallback", lua_Transform_removeScriptCallback},
+        {"removeScript", lua_Transform_removeScript},
         {"rotate", lua_Transform_rotate},
         {"rotate", lua_Transform_rotate},
         {"rotateX", lua_Transform_rotateX},
         {"rotateX", lua_Transform_rotateX},
         {"rotateY", lua_Transform_rotateY},
         {"rotateY", lua_Transform_rotateY},
@@ -380,7 +380,7 @@ int lua_Transform_addListener(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Transform_addScriptCallback(lua_State* state)
+int lua_Transform_addScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -388,31 +388,30 @@ int lua_Transform_addScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Transform* instance = getInstance(state);
                 Transform* instance = getInstance(state);
-                instance->addScriptCallback(param1, param2);
-                
-                return 0;
+                int result = instance->addScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Transform_addScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Transform_addScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -1977,7 +1976,7 @@ int lua_Transform_removeListener(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_Transform_removeScriptCallback(lua_State* state)
+int lua_Transform_removeScript(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
     int paramCount = lua_gettop(state);
@@ -1985,31 +1984,30 @@ int lua_Transform_removeScriptCallback(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
-        case 3:
+        case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
             {
             {
                 // Get parameter 1 off the stack.
                 // Get parameter 1 off the stack.
-                std::string param1 = gameplay::ScriptUtil::getString(2, true);
-
-                // Get parameter 2 off the stack.
-                std::string param2 = gameplay::ScriptUtil::getString(3, true);
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
 
 
                 Transform* instance = getInstance(state);
                 Transform* instance = getInstance(state);
-                instance->removeScriptCallback(param1, param2);
-                
-                return 0;
+                bool result = instance->removeScript(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
             }
             }
 
 
-            lua_pushstring(state, "lua_Transform_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Transform_removeScript - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 2
gameplay/src/lua/lua_Transform.h

@@ -8,7 +8,7 @@ namespace gameplay
 int lua_Transform__gc(lua_State* state);
 int lua_Transform__gc(lua_State* state);
 int lua_Transform__init(lua_State* state);
 int lua_Transform__init(lua_State* state);
 int lua_Transform_addListener(lua_State* state);
 int lua_Transform_addListener(lua_State* state);
-int lua_Transform_addScriptCallback(lua_State* state);
+int lua_Transform_addScript(lua_State* state);
 int lua_Transform_createAnimation(lua_State* state);
 int lua_Transform_createAnimation(lua_State* state);
 int lua_Transform_createAnimationFromBy(lua_State* state);
 int lua_Transform_createAnimationFromBy(lua_State* state);
 int lua_Transform_createAnimationFromTo(lua_State* state);
 int lua_Transform_createAnimationFromTo(lua_State* state);
@@ -34,7 +34,7 @@ int lua_Transform_getTranslationZ(lua_State* state);
 int lua_Transform_getUpVector(lua_State* state);
 int lua_Transform_getUpVector(lua_State* state);
 int lua_Transform_isStatic(lua_State* state);
 int lua_Transform_isStatic(lua_State* state);
 int lua_Transform_removeListener(lua_State* state);
 int lua_Transform_removeListener(lua_State* state);
-int lua_Transform_removeScriptCallback(lua_State* state);
+int lua_Transform_removeScript(lua_State* state);
 int lua_Transform_rotate(lua_State* state);
 int lua_Transform_rotate(lua_State* state);
 int lua_Transform_rotateX(lua_State* state);
 int lua_Transform_rotateX(lua_State* state);
 int lua_Transform_rotateY(lua_State* state);
 int lua_Transform_rotateY(lua_State* state);

+ 1 - 0
gameplay/src/lua/lua_all_bindings.cpp

@@ -107,6 +107,7 @@ void lua_RegisterAllBindings()
     luaRegister_ScreenDisplayer();
     luaRegister_ScreenDisplayer();
     luaRegister_ScriptController();
     luaRegister_ScriptController();
     luaRegister_ScriptTarget();
     luaRegister_ScriptTarget();
+    luaRegister_ScriptTargetEventRegistryEvent();
     luaRegister_Slider();
     luaRegister_Slider();
     luaRegister_SpriteBatch();
     luaRegister_SpriteBatch();
     luaRegister_Technique();
     luaRegister_Technique();

+ 1 - 0
gameplay/src/lua/lua_all_bindings.h

@@ -102,6 +102,7 @@
 #include "lua_ScreenDisplayer.h"
 #include "lua_ScreenDisplayer.h"
 #include "lua_ScriptController.h"
 #include "lua_ScriptController.h"
 #include "lua_ScriptTarget.h"
 #include "lua_ScriptTarget.h"
+#include "lua_ScriptTargetEventRegistryEvent.h"
 #include "lua_Slider.h"
 #include "lua_Slider.h"
 #include "lua_SpriteBatch.h"
 #include "lua_SpriteBatch.h"
 #include "lua_Technique.h"
 #include "lua_Technique.h"