summaryrefslogtreecommitdiffstats
path: root/src/Bindings
diff options
context:
space:
mode:
authorandrew <xdotftw@gmail.com>2014-02-20 14:37:15 +0100
committerandrew <xdotftw@gmail.com>2014-02-20 14:37:15 +0100
commit83d3a2eedf88a3a180b9dfc4c706838d7f99382a (patch)
treed96970727615c681efe3bf76793015cead438394 /src/Bindings
parentcMapDecorator: Implemented random rotations (diff)
parentAPIDump: Fixed cBlockArea:GetRelBlockType() return types. (diff)
downloadcuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar
cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar.gz
cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar.bz2
cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar.lz
cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar.xz
cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.tar.zst
cuberite-83d3a2eedf88a3a180b9dfc4c706838d7f99382a.zip
Diffstat (limited to 'src/Bindings')
-rw-r--r--src/Bindings/AllToLua.pkg2
-rw-r--r--src/Bindings/LuaState.cpp26
-rw-r--r--src/Bindings/LuaState.h3
-rw-r--r--src/Bindings/ManualBindings.cpp135
-rw-r--r--src/Bindings/PluginLua.cpp8
-rw-r--r--src/Bindings/PluginManager.cpp2
-rw-r--r--src/Bindings/PluginManager.h4
7 files changed, 150 insertions, 30 deletions
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg
index 335acff95..ef61f55f0 100644
--- a/src/Bindings/AllToLua.pkg
+++ b/src/Bindings/AllToLua.pkg
@@ -34,6 +34,7 @@ $cfile "../Entities/Entity.h"
$cfile "../Entities/Floater.h"
$cfile "../Entities/Pawn.h"
$cfile "../Entities/Player.h"
+$cfile "../Entities/Painting.h"
$cfile "../Entities/Pickup.h"
$cfile "../Entities/ProjectileEntity.h"
$cfile "../Entities/TNTEntity.h"
@@ -71,6 +72,7 @@ $cfile "../Generating/ChunkDesc.h"
$cfile "../CraftingRecipes.h"
$cfile "../UI/Window.h"
$cfile "../Mobs/Monster.h"
+$cfile "../CompositeChat.h"
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index c6be7be3c..ca7f6b255 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -173,6 +173,31 @@ void cLuaState::Detach(void)
+void cLuaState::AddPackagePath(const AString & a_PathVariable, const AString & a_Path)
+{
+ // Get the current path:
+ lua_getfield(m_LuaState, LUA_GLOBALSINDEX, "package"); // Stk: <package>
+ lua_getfield(m_LuaState, -1, a_PathVariable.c_str()); // Stk: <package> <package.path>
+ size_t len = 0;
+ const char * PackagePath = lua_tolstring(m_LuaState, -1, &len);
+
+ // Append the new path:
+ AString NewPackagePath(PackagePath, len);
+ NewPackagePath.append(LUA_PATHSEP);
+ NewPackagePath.append(a_Path);
+
+ // Set the new path to the environment:
+ lua_pop(m_LuaState, 1); // Stk: <package>
+ lua_pushlstring(m_LuaState, NewPackagePath.c_str(), NewPackagePath.length()); // Stk: <package> <NewPackagePath>
+ lua_setfield(m_LuaState, -2, a_PathVariable.c_str()); // Stk: <package>
+ lua_pop(m_LuaState, 1);
+ lua_pop(m_LuaState, 1); // Stk: -
+}
+
+
+
+
+
bool cLuaState::LoadFile(const AString & a_FileName)
{
ASSERT(IsValid());
@@ -1251,6 +1276,7 @@ void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header)
case LUA_TLIGHTUSERDATA: Printf(Value, "%p", lua_touserdata(a_LuaState, i)); break;
case LUA_TNUMBER: Printf(Value, "%f", (double)lua_tonumber(a_LuaState, i)); break;
case LUA_TSTRING: Printf(Value, "%s", lua_tostring(a_LuaState, i)); break;
+ case LUA_TTABLE: Printf(Value, "%p", lua_topointer(a_LuaState, i)); break;
default: break;
}
LOGD(" Idx %d: type %d (%s) %s", i, Type, lua_typename(a_LuaState, Type), Value.c_str());
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index b9bf10142..dcb660c3f 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -154,6 +154,9 @@ public:
/** Returns true if the m_LuaState is valid */
bool IsValid(void) const { return (m_LuaState != NULL); }
+ /** Adds the specified path to package.<a_PathVariable> */
+ void AddPackagePath(const AString & a_PathVariable, const AString & a_Path);
+
/** Loads the specified file
Returns false and logs a warning to the console if not successful (but the LuaState is kept open).
m_SubsystemName is displayed in the warning log message.
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 2a7631120..c220e5e0a 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -22,6 +22,7 @@
#include "../BlockEntities/FurnaceEntity.h"
#include "../BlockEntities/HopperEntity.h"
#include "../BlockEntities/NoteEntity.h"
+#include "../BlockEntities/MobHeadEntity.h"
#include "md5/md5.h"
#include "../LineBlockTracer.h"
#include "../WorldStorage/SchematicFileSerializer.h"
@@ -212,7 +213,7 @@ static int tolua_DoWith(lua_State* tolua_S)
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 2 or 3 arguments, got %i", NumArgs);
}
- Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, 0);
+ Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, NULL);
const char * ItemName = tolua_tocppstring(tolua_S, 2, "");
if ((ItemName == NULL) || (ItemName[0] == 0))
@@ -306,7 +307,7 @@ static int tolua_DoWithID(lua_State* tolua_S)
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 2 or 3 arguments, got %i", NumArgs);
}
- Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, 0);
+ Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, NULL);
int ItemID = (int)tolua_tonumber(tolua_S, 2, 0);
if (!lua_isfunction(tolua_S, 3))
@@ -396,7 +397,7 @@ static int tolua_DoWithXYZ(lua_State* tolua_S)
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 4 or 5 arguments, got %i", NumArgs);
}
- Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, 0);
+ Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, NULL);
if (!lua_isnumber(tolua_S, 2) || !lua_isnumber(tolua_S, 3) || !lua_isnumber(tolua_S, 4))
{
return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a number for parameters #1, #2 and #3");
@@ -490,7 +491,7 @@ static int tolua_ForEachInChunk(lua_State* tolua_S)
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 3 or 4 arguments, got %i", NumArgs);
}
- Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, 0);
+ Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, NULL);
if (!lua_isnumber(tolua_S, 2) || !lua_isnumber(tolua_S, 3))
{
return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a number for parameters #1 and #2");
@@ -584,7 +585,7 @@ static int tolua_ForEach(lua_State * tolua_S)
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 1 or 2 arguments, got %i", NumArgs);
}
- Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, 0);
+ Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
{
return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance");
@@ -681,7 +682,7 @@ static int tolua_cWorld_GetBlockInfo(lua_State * tolua_S)
else
#endif
{
- cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, 0);
+ cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, NULL);
int BlockX = (int) tolua_tonumber (tolua_S, 2, 0);
int BlockY = (int) tolua_tonumber (tolua_S, 3, 0);
int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0);
@@ -736,7 +737,7 @@ static int tolua_cWorld_GetBlockTypeMeta(lua_State * tolua_S)
else
#endif
{
- cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, 0);
+ cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, NULL);
int BlockX = (int) tolua_tonumber (tolua_S, 2, 0);
int BlockY = (int) tolua_tonumber (tolua_S, 3, 0);
int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0);
@@ -788,7 +789,7 @@ static int tolua_cWorld_GetSignLines(lua_State * tolua_S)
else
#endif
{
- cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, 0);
+ cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, NULL);
int BlockX = (int) tolua_tonumber (tolua_S, 2, 0);
int BlockY = (int) tolua_tonumber (tolua_S, 3, 0);
int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0);
@@ -846,7 +847,7 @@ static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
else
#endif
{
- cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, 0);
+ cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, NULL);
int BlockX = (int) tolua_tonumber (tolua_S, 2, 0);
int BlockY = (int) tolua_tonumber (tolua_S, 3, 0);
int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0);
@@ -895,7 +896,7 @@ static int tolua_cWorld_TryGetHeight(lua_State * tolua_S)
else
#endif
{
- cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, 0);
+ cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, NULL);
int BlockX = (int) tolua_tonumber (tolua_S, 2, 0);
int BlockZ = (int) tolua_tonumber (tolua_S, 3, 0);
#ifndef TOLUA_RELEASE
@@ -967,7 +968,7 @@ static int tolua_cWorld_QueueTask(lua_State * tolua_S)
}
// Retrieve the args:
- cWorld * self = (cWorld *)tolua_tousertype(tolua_S, 1, 0);
+ cWorld * self = (cWorld *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
{
return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance");
@@ -1065,7 +1066,7 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
static int tolua_cPluginManager_GetAllPlugins(lua_State * tolua_S)
{
- cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, 0);
+ cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, NULL);
const cPluginManager::PluginMap & AllPlugins = self->GetAllPlugins();
@@ -1289,7 +1290,7 @@ static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S)
return 0;
}
- cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, 0);
+ cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
{
LOGWARN("Error in function call 'ForEachCommand': Not called on an object instance");
@@ -1364,7 +1365,7 @@ static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S)
return 0;
}
- cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, 0);
+ cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
{
LOGWARN("Error in function call 'ForEachConsoleCommand': Not called on an object instance");
@@ -1686,7 +1687,7 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
static int tolua_cPlayer_GetGroups(lua_State* tolua_S)
{
- cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S, 1, NULL);
const cPlayer::GroupList & AllGroups = self->GetGroups();
@@ -1711,7 +1712,7 @@ static int tolua_cPlayer_GetGroups(lua_State* tolua_S)
static int tolua_cPlayer_GetResolvedPermissions(lua_State* tolua_S)
{
- cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S, 1, NULL);
cPlayer::StringList AllPermissions = self->GetResolvedPermissions();
@@ -1824,7 +1825,7 @@ static int tolua_SetObjectCallback(lua_State * tolua_S)
static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
{
- cPluginLua * self = (cPluginLua *)tolua_tousertype(tolua_S,1,0);
+ cPluginLua * self = (cPluginLua *)tolua_tousertype(tolua_S, 1, NULL);
tolua_Error tolua_err;
tolua_err.array = 0;
@@ -1868,7 +1869,7 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
static int tolua_cPluginLua_AddTab(lua_State* tolua_S)
{
- cPluginLua * self = (cPluginLua *) tolua_tousertype(tolua_S, 1, 0);
+ cPluginLua * self = (cPluginLua *) tolua_tousertype(tolua_S, 1, NULL);
LOGWARN("WARNING: Using deprecated function AddTab()! Use AddWebTab() instead. (plugin \"%s\" in folder \"%s\")",
self->GetName().c_str(), self->GetDirectory().c_str()
);
@@ -1888,7 +1889,7 @@ static int tolua_cPlugin_Call(lua_State * tolua_S)
L.LogStackTrace();
// Retrieve the params: plugin and the function name to call
- cPluginLua * TargetPlugin = (cPluginLua *) tolua_tousertype(tolua_S, 1, 0);
+ cPluginLua * TargetPlugin = (cPluginLua *) tolua_tousertype(tolua_S, 1, NULL);
AString FunctionName = tolua_tostring(tolua_S, 2, "");
// Call the function:
@@ -1941,7 +1942,7 @@ static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string,
static int tolua_get_HTTPRequest_Params(lua_State* tolua_S)
{
- HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S,1,0);
+ HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, NULL);
return tolua_push_StringStringMap(tolua_S, self->Params);
}
@@ -1951,7 +1952,7 @@ static int tolua_get_HTTPRequest_Params(lua_State* tolua_S)
static int tolua_get_HTTPRequest_PostParams(lua_State* tolua_S)
{
- HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S,1,0);
+ HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, NULL);
return tolua_push_StringStringMap(tolua_S, self->PostParams);
}
@@ -1961,7 +1962,7 @@ static int tolua_get_HTTPRequest_PostParams(lua_State* tolua_S)
static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
{
- HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S,1,0);
+ HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, NULL);
std::map< std::string, HTTPFormData >& FormData = self->FormData;
lua_newtable(tolua_S);
@@ -1984,7 +1985,7 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
static int tolua_cWebAdmin_GetPlugins(lua_State * tolua_S)
{
- cWebAdmin* self = (cWebAdmin*) tolua_tousertype(tolua_S,1,0);
+ cWebAdmin* self = (cWebAdmin*) tolua_tousertype(tolua_S, 1, NULL);
const cWebAdmin::PluginList & AllPlugins = self->GetPlugins();
@@ -2009,7 +2010,7 @@ static int tolua_cWebAdmin_GetPlugins(lua_State * tolua_S)
static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S)
{
- cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S,1,0);
+ cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S, 1, NULL);
const cWebPlugin::TabNameList & TabNames = self->GetTabNames();
@@ -2076,7 +2077,7 @@ static int Lua_ItemGrid_GetSlotCoords(lua_State * L)
}
{
- const cItemGrid * self = (const cItemGrid *)tolua_tousertype(L, 1, 0);
+ const cItemGrid * self = (const cItemGrid *)tolua_tousertype(L, 1, NULL);
int SlotNum = (int)tolua_tonumber(L, 2, 0);
if (self == NULL)
{
@@ -2288,7 +2289,7 @@ static int tolua_cHopperEntity_GetOutputBlockPos(lua_State * tolua_S)
{
return 0;
}
- cHopperEntity * self = (cHopperEntity *)tolua_tousertype(tolua_S, 1, 0);
+ cHopperEntity * self = (cHopperEntity *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
{
tolua_error(tolua_S, "invalid 'self' in function 'cHopperEntity::GetOutputBlockPos()'", NULL);
@@ -2314,6 +2315,76 @@ static int tolua_cHopperEntity_GetOutputBlockPos(lua_State * tolua_S)
+static int tolua_cBlockArea_GetBlockTypeMeta(lua_State * tolua_S)
+{
+ // function cBlockArea::GetBlockTypeMeta()
+ // Exported manually because tolua generates extra input params for the outputs
+
+ cLuaState L(tolua_S);
+ if (
+ !L.CheckParamUserType(1, "cBlockArea") ||
+ !L.CheckParamNumber (2, 4)
+ )
+ {
+ return 0;
+ }
+
+ cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
+ if (self == NULL)
+ {
+ tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetRelBlockTypeMeta'", NULL);
+ return 0;
+ }
+ int BlockX = (int)tolua_tonumber(tolua_S, 2, 0);
+ int BlockY = (int)tolua_tonumber(tolua_S, 3, 0);
+ int BlockZ = (int)tolua_tonumber(tolua_S, 4, 0);
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ self->GetBlockTypeMeta(BlockX, BlockY, BlockZ, BlockType, BlockMeta);
+ tolua_pushnumber(tolua_S, BlockType);
+ tolua_pushnumber(tolua_S, BlockMeta);
+ return 2;
+}
+
+
+
+
+
+static int tolua_cBlockArea_GetRelBlockTypeMeta(lua_State * tolua_S)
+{
+ // function cBlockArea::GetRelBlockTypeMeta()
+ // Exported manually because tolua generates extra input params for the outputs
+
+ cLuaState L(tolua_S);
+ if (
+ !L.CheckParamUserType(1, "cBlockArea") ||
+ !L.CheckParamNumber (2, 4)
+ )
+ {
+ return 0;
+ }
+
+ cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
+ if (self == NULL)
+ {
+ tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetRelBlockTypeMeta'", NULL);
+ return 0;
+ }
+ int BlockX = (int)tolua_tonumber(tolua_S, 2, 0);
+ int BlockY = (int)tolua_tonumber(tolua_S, 3, 0);
+ int BlockZ = (int)tolua_tonumber(tolua_S, 4, 0);
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ self->GetRelBlockTypeMeta(BlockX, BlockY, BlockZ, BlockType, BlockMeta);
+ tolua_pushnumber(tolua_S, BlockType);
+ tolua_pushnumber(tolua_S, BlockMeta);
+ return 2;
+}
+
+
+
+
+
static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S)
{
// function cBlockArea::LoadFromSchematicFile
@@ -2327,7 +2398,7 @@ static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S)
{
return 0;
}
- cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, 0);
+ cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
{
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::LoadFromSchematicFile'", NULL);
@@ -2343,6 +2414,7 @@ static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S)
+
static int tolua_cBlockArea_SaveToSchematicFile(lua_State * tolua_S)
{
// function cBlockArea::SaveToSchematicFile
@@ -2356,7 +2428,7 @@ static int tolua_cBlockArea_SaveToSchematicFile(lua_State * tolua_S)
{
return 0;
}
- cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, 0);
+ cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
{
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::SaveToSchematicFile'", NULL);
@@ -2370,6 +2442,8 @@ static int tolua_cBlockArea_SaveToSchematicFile(lua_State * tolua_S)
+
+
void ManualBindings::Bind(lua_State * tolua_S)
{
tolua_beginmodule(tolua_S, NULL);
@@ -2386,8 +2460,10 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cBlockArea");
+ tolua_function(tolua_S, "GetBlockTypeMeta", tolua_cBlockArea_GetBlockTypeMeta);
+ tolua_function(tolua_S, "GetRelBlockTypeMeta", tolua_cBlockArea_GetRelBlockTypeMeta);
tolua_function(tolua_S, "LoadFromSchematicFile", tolua_cBlockArea_LoadFromSchematicFile);
- tolua_function(tolua_S, "SaveToSchematicFile", tolua_cBlockArea_SaveToSchematicFile);
+ tolua_function(tolua_S, "SaveToSchematicFile", tolua_cBlockArea_SaveToSchematicFile);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cHopperEntity");
@@ -2416,6 +2492,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "DoWithFurnaceAt", tolua_DoWithXYZ<cWorld, cFurnaceEntity, &cWorld::DoWithFurnaceAt>);
tolua_function(tolua_S, "DoWithNoteBlockAt", tolua_DoWithXYZ<cWorld, cNoteEntity, &cWorld::DoWithNoteBlockAt>);
tolua_function(tolua_S, "DoWithCommandBlockAt", tolua_DoWithXYZ<cWorld, cCommandBlockEntity, &cWorld::DoWithCommandBlockAt>);
+ tolua_function(tolua_S, "DoWithMobHeadBlockAt", tolua_DoWithXYZ<cWorld, cMobHeadEntity, &cWorld::DoWithMobHeadBlockAt>);
tolua_function(tolua_S, "DoWithPlayer", tolua_DoWith< cWorld, cPlayer, &cWorld::DoWithPlayer>);
tolua_function(tolua_S, "FindAndDoWithPlayer", tolua_DoWith< cWorld, cPlayer, &cWorld::FindAndDoWithPlayer>);
tolua_function(tolua_S, "ForEachBlockEntityInChunk", tolua_ForEachInChunk<cWorld, cBlockEntity, &cWorld::ForEachBlockEntityInChunk>);
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 773d522c4..45c8216be 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -82,6 +82,14 @@ bool cPluginLua::Initialize(void)
lua_pushstring(m_LuaState, GetName().c_str());
lua_setglobal(m_LuaState, LUA_PLUGIN_NAME_VAR_NAME);
+ // Add the plugin's folder to the package.path and package.cpath variables (#693):
+ m_LuaState.AddPackagePath("path", FILE_IO_PREFIX + GetLocalFolder() + "/?.lua");
+ #ifdef _WIN32
+ m_LuaState.AddPackagePath("cpath", GetLocalFolder() + "\\?.dll");
+ #else
+ m_LuaState.AddPackagePath("cpath", FILE_IO_PREFIX + GetLocalFolder() + "/?.so");
+ #endif
+
tolua_pushusertype(m_LuaState, this, "cPluginLua");
lua_setglobal(m_LuaState, "g_Plugin");
}
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index c6c8c081e..c7df6357e 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -56,7 +56,7 @@ void cPluginManager::ReloadPlugins(void)
void cPluginManager::FindPlugins(void)
{
- AString PluginsPath = FILE_IO_PREFIX + AString( "Plugins/" );
+ AString PluginsPath = GetPluginsPath() + "/";
// First get a clean list of only the currently running plugins, we don't want to mess those up
for (PluginMap::iterator itr = m_Plugins.begin(); itr != m_Plugins.end();)
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index c78bceda1..44bc5a8d7 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -266,6 +266,10 @@ public: // tolua_export
Returns false if plugin not found, and the value that the callback has returned otherwise. */
bool DoWithPlugin(const AString & a_PluginName, cPluginCallback & a_Callback);
+ /** Returns the path where individual plugins' folders are expected.
+ The path doesn't end in a slash. */
+ static AString GetPluginsPath(void) { return FILE_IO_PREFIX + AString("Plugins"); } // tolua_export
+
private:
friend class cRoot;