summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaState.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-01-19 23:45:26 +0100
committermadmaxoft <github@xoft.cz>2014-01-19 23:45:26 +0100
commit4a01879911c5673612693531c4f8970c1644947b (patch)
tree38c8ba5c9571accc9f172843da2db741e78ae6a4 /src/Bindings/LuaState.cpp
parentMerge pull request #569 from worktycho/EnchantmentsFix (diff)
downloadcuberite-4a01879911c5673612693531c4f8970c1644947b.tar
cuberite-4a01879911c5673612693531c4f8970c1644947b.tar.gz
cuberite-4a01879911c5673612693531c4f8970c1644947b.tar.bz2
cuberite-4a01879911c5673612693531c4f8970c1644947b.tar.lz
cuberite-4a01879911c5673612693531c4f8970c1644947b.tar.xz
cuberite-4a01879911c5673612693531c4f8970c1644947b.tar.zst
cuberite-4a01879911c5673612693531c4f8970c1644947b.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/LuaState.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index 00e62fcf6..bfee1d037 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -914,6 +914,40 @@ bool cLuaState::CheckParamString(int a_StartParam, int a_EndParam)
+bool cLuaState::CheckParamFunction(int a_StartParam, int a_EndParam)
+{
+ ASSERT(IsValid());
+
+ if (a_EndParam < 0)
+ {
+ a_EndParam = a_StartParam;
+ }
+
+ for (int i = a_StartParam; i <= a_EndParam; i++)
+ {
+ if (lua_isfunction(m_LuaState, i))
+ {
+ continue;
+ }
+ // Not the correct parameter
+ lua_Debug entry;
+ VERIFY(lua_getstack(m_LuaState, 0, &entry));
+ VERIFY(lua_getinfo (m_LuaState, "n", &entry));
+ AString ErrMsg = Printf("Error in function '%s' parameter #%d. Function expected, got %s",
+ (entry.name != NULL) ? entry.name : "?", i, GetTypeText(i).c_str()
+ );
+ LogStackTrace();
+ return false;
+ } // for i - Param
+
+ // All params checked ok
+ return true;
+}
+
+
+
+
+
bool cLuaState::CheckParamEnd(int a_Param)
{
tolua_Error tolua_err;