summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaState.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2017-06-24 11:58:06 +0200
committerGitHub <noreply@github.com>2017-06-24 11:58:06 +0200
commitfe4253834919d6c742c59c701d3d5ce8285f4504 (patch)
treec201ca7a02344029679d4addffb695a3d20c4bec /src/Bindings/LuaState.cpp
parentLoad entities from old and new names (diff)
downloadcuberite-fe4253834919d6c742c59c701d3d5ce8285f4504.tar
cuberite-fe4253834919d6c742c59c701d3d5ce8285f4504.tar.gz
cuberite-fe4253834919d6c742c59c701d3d5ce8285f4504.tar.bz2
cuberite-fe4253834919d6c742c59c701d3d5ce8285f4504.tar.lz
cuberite-fe4253834919d6c742c59c701d3d5ce8285f4504.tar.xz
cuberite-fe4253834919d6c742c59c701d3d5ce8285f4504.tar.zst
cuberite-fe4253834919d6c742c59c701d3d5ce8285f4504.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/LuaState.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index 947e337fc..d18b6efcd 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -1762,6 +1762,30 @@ bool cLuaState::CheckParamEnd(int a_Param)
+bool cLuaState::CheckParamSelf(const char * a_SelfClassName)
+{
+ tolua_Error tolua_err;
+ if (tolua_isusertype(m_LuaState, 1, a_SelfClassName, 0, &tolua_err) && !lua_isnil(m_LuaState, 1))
+ {
+ return true;
+ }
+
+ // 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'. The 'self' parameter is not of the expected type, \"instance of %s\". Make sure you're using the correct calling convention (obj:fn() instead of obj.fn()).",
+ (entry.name != nullptr) ? entry.name : "<unknown>", a_SelfClassName
+ );
+ tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
+ return false;
+}
+
+
+
+
+
bool cLuaState::IsParamUserType(int a_Param, AString a_UserType)
{
ASSERT(IsValid());