|
@@ -28,6 +28,7 @@ void luaRegister_Material()
|
|
|
{"getRefCount", lua_Material_getRefCount},
|
|
{"getRefCount", lua_Material_getRefCount},
|
|
|
{"getStateBlock", lua_Material_getStateBlock},
|
|
{"getStateBlock", lua_Material_getStateBlock},
|
|
|
{"getTechnique", lua_Material_getTechnique},
|
|
{"getTechnique", lua_Material_getTechnique},
|
|
|
|
|
+ {"getTechniqueByIndex", lua_Material_getTechniqueByIndex},
|
|
|
{"getTechniqueCount", lua_Material_getTechniqueCount},
|
|
{"getTechniqueCount", lua_Material_getTechniqueCount},
|
|
|
{"release", lua_Material_release},
|
|
{"release", lua_Material_release},
|
|
|
{"setParameterAutoBinding", lua_Material_setParameterAutoBinding},
|
|
{"setParameterAutoBinding", lua_Material_setParameterAutoBinding},
|
|
@@ -348,10 +349,10 @@ int lua_Material_getTechnique(lua_State* state)
|
|
|
case 2:
|
|
case 2:
|
|
|
{
|
|
{
|
|
|
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
|
|
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
|
|
|
- lua_type(state, 2) == LUA_TNUMBER)
|
|
|
|
|
|
|
+ (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
|
|
|
{
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
// Get parameter 1 off the stack.
|
|
|
- unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
|
|
|
|
|
|
|
+ const char* param1 = ScriptUtil::getString(2, false);
|
|
|
|
|
|
|
|
Material* instance = getInstance(state);
|
|
Material* instance = getInstance(state);
|
|
|
void* returnPtr = (void*)instance->getTechnique(param1);
|
|
void* returnPtr = (void*)instance->getTechnique(param1);
|
|
@@ -370,14 +371,41 @@ int lua_Material_getTechnique(lua_State* state)
|
|
|
|
|
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
- else if ((lua_type(state, 1) == LUA_TUSERDATA) &&
|
|
|
|
|
- (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
|
|
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ lua_pushstring(state, "lua_Material_getTechnique - 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 or 2).");
|
|
|
|
|
+ lua_error(state);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+int lua_Material_getTechniqueByIndex(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.
|
|
// Get parameter 1 off the stack.
|
|
|
- const char* param1 = ScriptUtil::getString(2, false);
|
|
|
|
|
|
|
+ unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
|
|
|
|
|
|
|
|
Material* instance = getInstance(state);
|
|
Material* instance = getInstance(state);
|
|
|
- void* returnPtr = (void*)instance->getTechnique(param1);
|
|
|
|
|
|
|
+ void* returnPtr = (void*)instance->getTechniqueByIndex(param1);
|
|
|
if (returnPtr)
|
|
if (returnPtr)
|
|
|
{
|
|
{
|
|
|
ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
|
|
ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
|
|
@@ -395,14 +423,14 @@ int lua_Material_getTechnique(lua_State* state)
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- lua_pushstring(state, "lua_Material_getTechnique - Failed to match the given parameters to a valid function signature.");
|
|
|
|
|
|
|
+ lua_pushstring(state, "lua_Material_getTechniqueByIndex - 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 1 or 2).");
|
|
|
|
|
|
|
+ lua_pushstring(state, "Invalid number of parameters (expected 2).");
|
|
|
lua_error(state);
|
|
lua_error(state);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -587,17 +615,6 @@ int lua_Material_setTechnique(lua_State* state)
|
|
|
case 2:
|
|
case 2:
|
|
|
{
|
|
{
|
|
|
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
|
|
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
|
|
|
- lua_type(state, 2) == LUA_TNUMBER)
|
|
|
|
|
- {
|
|
|
|
|
- // Get parameter 1 off the stack.
|
|
|
|
|
- unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
|
|
|
|
|
-
|
|
|
|
|
- Material* instance = getInstance(state);
|
|
|
|
|
- instance->setTechnique(param1);
|
|
|
|
|
-
|
|
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
- else if ((lua_type(state, 1) == LUA_TUSERDATA) &&
|
|
|
|
|
(lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == 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.
|