summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-08-07 14:34:00 +0200
committermadmaxoft <github@xoft.cz>2013-08-07 14:34:00 +0200
commit58a76a90dc640af707aab073325827f3e8f41d71 (patch)
tree8915d56c6c57fd42e65eb036996121a3125a7b43
parentPlugin: Fixed plugin name in the cLuaState's subsystem (diff)
downloadcuberite-58a76a90dc640af707aab073325827f3e8f41d71.tar
cuberite-58a76a90dc640af707aab073325827f3e8f41d71.tar.gz
cuberite-58a76a90dc640af707aab073325827f3e8f41d71.tar.bz2
cuberite-58a76a90dc640af707aab073325827f3e8f41d71.tar.lz
cuberite-58a76a90dc640af707aab073325827f3e8f41d71.tar.xz
cuberite-58a76a90dc640af707aab073325827f3e8f41d71.tar.zst
cuberite-58a76a90dc640af707aab073325827f3e8f41d71.zip
Diffstat (limited to '')
-rw-r--r--source/AllToLua.pkg8
-rw-r--r--source/Bindings.cpp161
-rw-r--r--source/Bindings.h2
-rw-r--r--source/ManualBindings.cpp180
4 files changed, 296 insertions, 55 deletions
diff --git a/source/AllToLua.pkg b/source/AllToLua.pkg
index 7041211b5..cd22aba0a 100644
--- a/source/AllToLua.pkg
+++ b/source/AllToLua.pkg
@@ -63,3 +63,11 @@ $cfile "LuaWindow.h"
+
+// Need to declare this class so that the usertype is properly registered in Bindings.cpp -
+// it seems impossible to register a usertype in ManualBindings.cpp
+class cLineBlockTracer;
+
+
+
+
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index df45cb1b3..fd953e29d 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 08/02/13 08:41:18.
+** Generated automatically by tolua++-1.0.92 on 08/07/13 12:06:03.
*/
#ifndef __cplusplus
@@ -202,8 +202,11 @@ static int tolua_collect_Vector3d (lua_State* tolua_S)
static void tolua_reg_types (lua_State* tolua_S)
{
tolua_usertype(tolua_S,"TakeDamageInfo");
- tolua_usertype(tolua_S,"cCraftingRecipe");
tolua_usertype(tolua_S,"cPlugin_NewLua");
+ tolua_usertype(tolua_S,"cCraftingGrid");
+ tolua_usertype(tolua_S,"cCraftingRecipe");
+ tolua_usertype(tolua_S,"cPlugin");
+ tolua_usertype(tolua_S,"cWindow");
tolua_usertype(tolua_S,"cStringMap");
tolua_usertype(tolua_S,"cItemGrid");
tolua_usertype(tolua_S,"cBlockArea");
@@ -211,42 +214,42 @@ static void tolua_reg_types (lua_State* tolua_S)
tolua_usertype(tolua_S,"cLuaWindow");
tolua_usertype(tolua_S,"cInventory");
tolua_usertype(tolua_S,"cRoot");
- tolua_usertype(tolua_S,"cWindow");
- tolua_usertype(tolua_S,"cCraftingGrid");
- tolua_usertype(tolua_S,"cTracer");
- tolua_usertype(tolua_S,"cPickup");
- tolua_usertype(tolua_S,"cItems");
+ tolua_usertype(tolua_S,"cCuboid");
+ tolua_usertype(tolua_S,"std::vector<cIniFile::key>");
tolua_usertype(tolua_S,"cGroup");
+ tolua_usertype(tolua_S,"cPickup");
+ tolua_usertype(tolua_S,"std::vector<std::string>");
+ tolua_usertype(tolua_S,"cTracer");
tolua_usertype(tolua_S,"cClientHandle");
tolua_usertype(tolua_S,"cChunkDesc");
tolua_usertype(tolua_S,"cFurnaceRecipe");
- tolua_usertype(tolua_S,"cCuboid");
- tolua_usertype(tolua_S,"cChatColor");
tolua_usertype(tolua_S,"Vector3i");
- tolua_usertype(tolua_S,"cEntity");
+ tolua_usertype(tolua_S,"cChatColor");
+ tolua_usertype(tolua_S,"cWorld");
+ tolua_usertype(tolua_S,"Lua__cPickup");
tolua_usertype(tolua_S,"Lua__cWebPlugin");
- tolua_usertype(tolua_S,"cPlugin");
tolua_usertype(tolua_S,"cCraftingRecipes");
+ tolua_usertype(tolua_S,"cEntity");
tolua_usertype(tolua_S,"cItem");
tolua_usertype(tolua_S,"Vector3f");
- tolua_usertype(tolua_S,"Lua__cPickup");
+ tolua_usertype(tolua_S,"cWebPlugin");
tolua_usertype(tolua_S,"cDropSpenserEntity");
tolua_usertype(tolua_S,"Lua__cPlayer");
- tolua_usertype(tolua_S,"cWebPlugin");
+ tolua_usertype(tolua_S,"cWebAdmin");
tolua_usertype(tolua_S,"cChestEntity");
tolua_usertype(tolua_S,"cDispenserEntity");
- tolua_usertype(tolua_S,"cWebAdmin");
+ tolua_usertype(tolua_S,"sWebAdminPage");
tolua_usertype(tolua_S,"cBlockEntity");
tolua_usertype(tolua_S,"cCriticalSection");
tolua_usertype(tolua_S,"HTTPTemplateRequest");
- tolua_usertype(tolua_S,"sWebAdminPage");
tolua_usertype(tolua_S,"HTTPRequest");
tolua_usertype(tolua_S,"HTTPFormData");
tolua_usertype(tolua_S,"cFurnaceEntity");
- tolua_usertype(tolua_S,"cPluginManager");
tolua_usertype(tolua_S,"cDropperEntity");
+ tolua_usertype(tolua_S,"cLineBlockTracer");
+ tolua_usertype(tolua_S,"cPluginManager");
tolua_usertype(tolua_S,"cIniFile");
- tolua_usertype(tolua_S,"cWorld");
+ tolua_usertype(tolua_S,"cBlockEntityWithItems");
tolua_usertype(tolua_S,"cListeners");
tolua_usertype(tolua_S,"cPawn");
tolua_usertype(tolua_S,"cPlayer");
@@ -254,7 +257,7 @@ static void tolua_reg_types (lua_State* tolua_S)
tolua_usertype(tolua_S,"cBlockEntityWindowOwner");
tolua_usertype(tolua_S,"cItemGrid::cListener");
tolua_usertype(tolua_S,"cServer");
- tolua_usertype(tolua_S,"cBlockEntityWithItems");
+ tolua_usertype(tolua_S,"cItems");
tolua_usertype(tolua_S,"Lua__cEntity");
tolua_usertype(tolua_S,"Vector3d");
}
@@ -267,16 +270,14 @@ static int tolua_AllToLua_cIniFile_new00(lua_State* tolua_S)
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,1,"cIniFile",0,&tolua_err) ||
- !tolua_iscppstring(tolua_S,2,1,&tolua_err) ||
- !tolua_isnoobj(tolua_S,3,&tolua_err)
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- const std::string iniPath = ((const std::string) tolua_tocppstring(tolua_S,2,""));
{
- cIniFile* tolua_ret = (cIniFile*) Mtolua_new((cIniFile)(iniPath));
+ cIniFile* tolua_ret = (cIniFile*) Mtolua_new((cIniFile)());
tolua_pushusertype(tolua_S,(void*)tolua_ret,"cIniFile");
}
}
@@ -297,16 +298,14 @@ static int tolua_AllToLua_cIniFile_new00_local(lua_State* tolua_S)
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,1,"cIniFile",0,&tolua_err) ||
- !tolua_iscppstring(tolua_S,2,1,&tolua_err) ||
- !tolua_isnoobj(tolua_S,3,&tolua_err)
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- const std::string iniPath = ((const std::string) tolua_tocppstring(tolua_S,2,""));
{
- cIniFile* tolua_ret = (cIniFile*) Mtolua_new((cIniFile)(iniPath));
+ cIniFile* tolua_ret = (cIniFile*) Mtolua_new((cIniFile)());
tolua_pushusertype(tolua_S,(void*)tolua_ret,"cIniFile");
tolua_register_gc(tolua_S,lua_gettop(tolua_S));
}
@@ -320,6 +319,59 @@ static int tolua_AllToLua_cIniFile_new00_local(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: new of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_new01
+static int tolua_AllToLua_cIniFile_new01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const std::string a_Path = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ {
+ cIniFile* tolua_ret = (cIniFile*) Mtolua_new((cIniFile)(a_Path));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cIniFile");
+ tolua_pushcppstring(tolua_S,(const char*)a_Path);
+ }
+ }
+ return 2;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_new00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_new01_local
+static int tolua_AllToLua_cIniFile_new01_local(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ const std::string a_Path = ((const std::string) tolua_tocppstring(tolua_S,2,0));
+ {
+ cIniFile* tolua_ret = (cIniFile*) Mtolua_new((cIniFile)(a_Path));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cIniFile");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ tolua_pushcppstring(tolua_S,(const char*)a_Path);
+ }
+ }
+ return 2;
+tolua_lerror:
+ return tolua_AllToLua_cIniFile_new00_local(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: CaseSensitive of class cIniFile */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_CaseSensitive00
static int tolua_AllToLua_cIniFile_CaseSensitive00(lua_State* tolua_S)
@@ -433,7 +485,7 @@ static int tolua_AllToLua_cIniFile_Path01(lua_State* tolua_S)
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Path'", NULL);
#endif
{
- std::string tolua_ret = (std::string) self->Path();
+ const std::string tolua_ret = (const std::string) self->Path();
tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
}
}
@@ -485,18 +537,20 @@ static int tolua_AllToLua_cIniFile_ReadFile00(lua_State* tolua_S)
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,2,&tolua_err)
+ !tolua_isboolean(tolua_S,2,1,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ bool a_AllowExampleRedirect = ((bool) tolua_toboolean(tolua_S,2,true));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ReadFile'", NULL);
#endif
{
- bool tolua_ret = (bool) self->ReadFile();
+ bool tolua_ret = (bool) self->ReadFile(a_AllowExampleRedirect);
tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
@@ -516,14 +570,14 @@ static int tolua_AllToLua_cIniFile_WriteFile00(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'WriteFile'", NULL);
#endif
@@ -541,9 +595,9 @@ static int tolua_AllToLua_cIniFile_WriteFile00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
-/* method: Erase of class cIniFile */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_Erase00
-static int tolua_AllToLua_cIniFile_Erase00(lua_State* tolua_S)
+/* method: Clear of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_Clear00
+static int tolua_AllToLua_cIniFile_Clear00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@@ -557,24 +611,24 @@ static int tolua_AllToLua_cIniFile_Erase00(lua_State* tolua_S)
{
cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Erase'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Clear'", NULL);
#endif
{
- self->Erase();
+ self->Clear();
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'Erase'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'Clear'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: Clear of class cIniFile */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_Clear00
-static int tolua_AllToLua_cIniFile_Clear00(lua_State* tolua_S)
+/* method: Reset of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_Reset00
+static int tolua_AllToLua_cIniFile_Reset00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@@ -588,24 +642,24 @@ static int tolua_AllToLua_cIniFile_Clear00(lua_State* tolua_S)
{
cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Clear'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Reset'", NULL);
#endif
{
- self->Clear();
+ self->Reset();
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'Clear'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'Reset'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: Reset of class cIniFile */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_Reset00
-static int tolua_AllToLua_cIniFile_Reset00(lua_State* tolua_S)
+/* method: Erase of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_Erase00
+static int tolua_AllToLua_cIniFile_Erase00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@@ -619,16 +673,16 @@ static int tolua_AllToLua_cIniFile_Reset00(lua_State* tolua_S)
{
cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Reset'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Erase'", NULL);
#endif
{
- self->Reset();
+ self->Erase();
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'Reset'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'Erase'.",&tolua_err);
return 0;
#endif
}
@@ -28476,6 +28530,9 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"new",tolua_AllToLua_cIniFile_new00);
tolua_function(tolua_S,"new_local",tolua_AllToLua_cIniFile_new00_local);
tolua_function(tolua_S,".call",tolua_AllToLua_cIniFile_new00_local);
+ tolua_function(tolua_S,"new",tolua_AllToLua_cIniFile_new01);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_cIniFile_new01_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_cIniFile_new01_local);
tolua_function(tolua_S,"CaseSensitive",tolua_AllToLua_cIniFile_CaseSensitive00);
tolua_function(tolua_S,"CaseInsensitive",tolua_AllToLua_cIniFile_CaseInsensitive00);
tolua_function(tolua_S,"Path",tolua_AllToLua_cIniFile_Path00);
@@ -28483,9 +28540,9 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"SetPath",tolua_AllToLua_cIniFile_SetPath00);
tolua_function(tolua_S,"ReadFile",tolua_AllToLua_cIniFile_ReadFile00);
tolua_function(tolua_S,"WriteFile",tolua_AllToLua_cIniFile_WriteFile00);
- tolua_function(tolua_S,"Erase",tolua_AllToLua_cIniFile_Erase00);
tolua_function(tolua_S,"Clear",tolua_AllToLua_cIniFile_Clear00);
tolua_function(tolua_S,"Reset",tolua_AllToLua_cIniFile_Reset00);
+ tolua_function(tolua_S,"Erase",tolua_AllToLua_cIniFile_Erase00);
tolua_function(tolua_S,"FindKey",tolua_AllToLua_cIniFile_FindKey00);
tolua_function(tolua_S,"FindValue",tolua_AllToLua_cIniFile_FindValue00);
tolua_function(tolua_S,"NumKeys",tolua_AllToLua_cIniFile_NumKeys00);
@@ -28699,6 +28756,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_BLOCK_QUARTZ_BLOCK",E_BLOCK_QUARTZ_BLOCK);
tolua_constant(tolua_S,"E_BLOCK_ACTIVATOR_RAIL",E_BLOCK_ACTIVATOR_RAIL);
tolua_constant(tolua_S,"E_BLOCK_DROPPER",E_BLOCK_DROPPER);
+ tolua_constant(tolua_S,"E_BLOCK_CARPET",E_BLOCK_CARPET);
tolua_constant(tolua_S,"E_BLOCK_NUMBER_OF_TYPES",E_BLOCK_NUMBER_OF_TYPES);
tolua_constant(tolua_S,"E_BLOCK_MAX_TYPE_ID",E_BLOCK_MAX_TYPE_ID);
tolua_constant(tolua_S,"E_ITEM_EMPTY",E_ITEM_EMPTY);
@@ -30283,6 +30341,9 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"GetContents",tolua_AllToLua_cLuaWindow_GetContents00);
tolua_variable(tolua_S,"__cItemGrid__cListener__",tolua_get_cLuaWindow___cItemGrid__cListener__,NULL);
tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cLineBlockTracer","cLineBlockTracer","",NULL);
+ tolua_beginmodule(tolua_S,"cLineBlockTracer");
+ tolua_endmodule(tolua_S);
tolua_endmodule(tolua_S);
return 1;
}
diff --git a/source/Bindings.h b/source/Bindings.h
index 6dfe855d3..a5654c062 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 08/02/13 08:41:19.
+** Generated automatically by tolua++-1.0.92 on 08/07/13 12:06:04.
*/
/* Exported function */
diff --git a/source/ManualBindings.cpp b/source/ManualBindings.cpp
index f428b0905..4041ccc94 100644
--- a/source/ManualBindings.cpp
+++ b/source/ManualBindings.cpp
@@ -20,6 +20,7 @@
#include "md5/md5.h"
#include "LuaWindow.h"
#include "LuaState.h"
+#include "LineBlockTracer.h"
@@ -340,9 +341,11 @@ static int tolua_DoWithID(lua_State* tolua_S)
-template< class Ty1,
- class Ty2,
- bool (Ty1::*Func1)(int, int, int, cItemCallback<Ty2> &) >
+template<
+ class Ty1,
+ class Ty2,
+ bool (Ty1::*Func1)(int, int, int, cItemCallback<Ty2> &)
+>
static int tolua_DoWithXYZ(lua_State* tolua_S)
{
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
@@ -1483,9 +1486,174 @@ tolua_lerror:
+/// Provides interface between a Lua table of callbacks and the cBlockTracer::cCallbacks
+class cLuaBlockTracerCallbacks :
+ public cBlockTracer::cCallbacks
+{
+public:
+ cLuaBlockTracerCallbacks(cLuaState & a_LuaState, int a_ParamNum) :
+ m_LuaState(a_LuaState),
+ m_TableRef(a_LuaState, a_ParamNum)
+ {
+ }
+
+ virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
+ {
+ if (!m_LuaState.PushFunctionFromRefTable(m_TableRef, "OnNextBlock"))
+ {
+ // No such function in the table, skip the callback
+ return false;
+ }
+ m_LuaState.PushNumber(a_BlockX);
+ m_LuaState.PushNumber(a_BlockY);
+ m_LuaState.PushNumber(a_BlockZ);
+ m_LuaState.PushNumber(a_BlockType);
+ m_LuaState.PushNumber(a_BlockMeta);
+ if (!m_LuaState.CallFunction(1))
+ {
+ return false;
+ }
+ bool res = false;
+ if (lua_isboolean(m_LuaState, -1))
+ {
+ res = (lua_toboolean(m_LuaState, -1) != 0);
+ }
+ lua_pop(m_LuaState, 1);
+ return res;
+ }
+
+ virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ if (!m_LuaState.PushFunctionFromRefTable(m_TableRef, "OnNextBlockNoData"))
+ {
+ // No such function in the table, skip the callback
+ return false;
+ }
+ m_LuaState.PushNumber(a_BlockX);
+ m_LuaState.PushNumber(a_BlockY);
+ m_LuaState.PushNumber(a_BlockZ);
+ if (!m_LuaState.CallFunction(1))
+ {
+ return false;
+ }
+ bool res = false;
+ if (lua_isboolean(m_LuaState, -1))
+ {
+ res = (lua_toboolean(m_LuaState, -1) != 0);
+ }
+ lua_pop(m_LuaState, 1);
+ return res;
+ }
+
+ virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ) override
+ {
+ if (!m_LuaState.PushFunctionFromRefTable(m_TableRef, "OnOutOfWorld"))
+ {
+ // No such function in the table, skip the callback
+ return false;
+ }
+ m_LuaState.PushNumber(a_BlockX);
+ m_LuaState.PushNumber(a_BlockY);
+ m_LuaState.PushNumber(a_BlockZ);
+ if (!m_LuaState.CallFunction(1))
+ {
+ return false;
+ }
+ bool res = false;
+ if (lua_isboolean(m_LuaState, -1))
+ {
+ res = (lua_toboolean(m_LuaState, -1) != 0);
+ }
+ lua_pop(m_LuaState, 1);
+ return res;
+ }
+
+ virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ) override
+ {
+ if (!m_LuaState.PushFunctionFromRefTable(m_TableRef, "OnIntoWorld"))
+ {
+ // No such function in the table, skip the callback
+ return false;
+ }
+ m_LuaState.PushNumber(a_BlockX);
+ m_LuaState.PushNumber(a_BlockY);
+ m_LuaState.PushNumber(a_BlockZ);
+ if (!m_LuaState.CallFunction(1))
+ {
+ return false;
+ }
+ bool res = false;
+ if (lua_isboolean(m_LuaState, -1))
+ {
+ res = (lua_toboolean(m_LuaState, -1) != 0);
+ }
+ lua_pop(m_LuaState, 1);
+ return res;
+ }
+
+ virtual void OnNoMoreHits(void) override
+ {
+ if (!m_LuaState.PushFunctionFromRefTable(m_TableRef, "OnNoMoreHits"))
+ {
+ // No such function in the table, skip the callback
+ return;
+ }
+ m_LuaState.CallFunction(0);
+ }
+
+ virtual void OnNoChunk(void) override
+ {
+ if (!m_LuaState.PushFunctionFromRefTable(m_TableRef, "OnNoChunk"))
+ {
+ // No such function in the table, skip the callback
+ return;
+ }
+ m_LuaState.CallFunction(0);
+ }
+
+protected:
+ cLuaState & m_LuaState;
+ cLuaState::cRef m_TableRef;
+} ;
+
+
+
+
+
+static int tolua_cLineBlockTracer_Trace(lua_State * tolua_S)
+{
+ // cLineBlockTracer.Trace(World, Callbacks, StartX, StartY, StartZ, EndX, EndY, EndZ)
+ cLuaState L(tolua_S);
+ if (
+ !L.CheckParamUserType(1, "cWorld") ||
+ !L.CheckParamTable (2) ||
+ !L.CheckParamNumber (3, 8) ||
+ !L.CheckParamEnd (9)
+ )
+ {
+ return 0;
+ }
+
+ cWorld * World = (cWorld *)tolua_tousertype(L, 1, NULL);
+ cLuaBlockTracerCallbacks Callbacks(L, 2);
+ double StartX = tolua_tonumber(L, 3, 0);
+ double StartY = tolua_tonumber(L, 4, 0);
+ double StartZ = tolua_tonumber(L, 5, 0);
+ double EndX = tolua_tonumber(L, 6, 0);
+ double EndY = tolua_tonumber(L, 7, 0);
+ double EndZ = tolua_tonumber(L, 8, 0);
+ bool res = cLineBlockTracer::Trace(*World, Callbacks, StartX, StartY, StartZ, EndX, EndY, EndZ);
+ tolua_pushboolean(L, res ? 1 : 0);
+ return 1;
+}
+
+
+
+
+
void ManualBindings::Bind(lua_State * tolua_S)
{
- tolua_beginmodule(tolua_S,NULL);
+ tolua_beginmodule(tolua_S, NULL);
tolua_function(tolua_S, "StringSplit", tolua_StringSplit);
tolua_function(tolua_S, "LOG", tolua_LOG);
tolua_function(tolua_S, "LOGINFO", tolua_LOGINFO);
@@ -1493,6 +1661,10 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "LOGWARNING", tolua_LOGWARN);
tolua_function(tolua_S, "LOGERROR", tolua_LOGERROR);
+ tolua_beginmodule(tolua_S, "cLineBlockTracer");
+ tolua_function(tolua_S, "Trace", tolua_cLineBlockTracer_Trace);
+ tolua_endmodule(tolua_S);
+
tolua_beginmodule(tolua_S, "cRoot");
tolua_function(tolua_S, "FindAndDoWithPlayer", tolua_DoWith <cRoot, cPlayer, &cRoot::FindAndDoWithPlayer>);
tolua_function(tolua_S, "ForEachPlayer", tolua_ForEach<cRoot, cPlayer, &cRoot::ForEachPlayer>);