1
0

Fixed the cWorld:DoWithChestAt(), DoWithDispenserAt() and DoWithFurnaceAt() callbacks binding.

They are now doing what the comment said they are doing.

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1506 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2013-05-25 11:57:28 +00:00
parent 717ad90700
commit e3136c2d0f
4 changed files with 27 additions and 11 deletions

View File

@ -197,10 +197,10 @@ public:
/// Calls the callback for the chest at the specified coords; returns false if there's no chest at those coords, true if found
bool DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback & a_Callback); // Lua-acessible
/// Calls the callback for the dispenser at the specified coords; returns false if there's no dispenser at those coords, true if found
/// Calls the callback for the dispenser at the specified coords; returns false if there's no dispenser at those coords or callback returns true, returns true if found
bool DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDispenserCallback & a_Callback);
/// Calls the callback for the furnace at the specified coords; returns false if there's no furnace at those coords, true if found
/// Calls the callback for the furnace at the specified coords; returns false if there's no furnace at those coords or callback returns true, returns true if found
bool DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceCallback & a_Callback); // Lua-accessible
/// Retrieves the test on the sign at the specified coords; returns false if there's no sign at those coords, true if found

View File

@ -216,10 +216,10 @@ public:
/// Calls the callback for the chest at the specified coords; returns false if there's no chest at those coords, true if found
bool DoWithChestAt (int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback & a_Callback); // Lua-acessible
/// Calls the callback for the dispenser at the specified coords; returns false if there's no dispenser at those coords, true if found
/// Calls the callback for the dispenser at the specified coords; returns false if there's no dispenser at those coords or callback returns true, returns true if found
bool DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDispenserCallback & a_Callback);
/// Calls the callback for the furnace at the specified coords; returns false if there's no furnace at those coords, true if found
/// Calls the callback for the furnace at the specified coords; returns false if there's no furnace at those coords or callback returns true, returns true if found
bool DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceCallback & a_Callback); // Lua-accessible
/// Retrieves the test on the sign at the specified coords; returns false if there's no sign at those coords, true if found

View File

@ -14,6 +14,7 @@
#include "StringMap.h"
#include "ClientHandle.h"
#include "ChestEntity.h"
#include "DispenserEntity.h"
#include "FurnaceEntity.h"
#include "md5/md5.h"
@ -211,8 +212,15 @@ static int tolua_DoWith(lua_State* tolua_S)
}
int s = lua_pcall(LuaState, (TableRef == LUA_REFNIL ? 1 : 2), 1, 0);
report_errors(LuaState, s);
return true;
if (report_errors(LuaState, s))
{
return true; // Abort enumeration
}
if (lua_isboolean(LuaState, -1))
{
return (tolua_toboolean(LuaState, -1, 0) > 0);
}
return false; /* Continue enumeration */
}
lua_State * LuaState;
int FuncRef;
@ -299,8 +307,15 @@ static int tolua_DoWithXYZ(lua_State* tolua_S)
}
int s = lua_pcall(LuaState, (TableRef == LUA_REFNIL ? 1 : 2), 1, 0);
report_errors(LuaState, s);
return true;
if (report_errors(LuaState, s))
{
return true; // Abort enumeration
}
if (lua_isboolean(LuaState, -1))
{
return (tolua_toboolean(LuaState, -1, 0) > 0);
}
return false; /* Continue enumeration */
}
lua_State * LuaState;
int FuncRef;
@ -392,7 +407,7 @@ static int tolua_ForEachInChunk(lua_State* tolua_S)
if (lua_isboolean(LuaState, -1))
{
return (tolua_toboolean( LuaState, -1, 0) > 0);
return (tolua_toboolean(LuaState, -1, 0) > 0);
}
return false; /* Continue enumeration */
}
@ -1160,6 +1175,7 @@ void ManualBindings::Bind( lua_State* tolua_S )
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, "DoWithChestAt", tolua_DoWithXYZ<cWorld, cChestEntity, &cWorld::DoWithChestAt>);
tolua_function(tolua_S, "DoWithDispenserAt", tolua_DoWithXYZ<cWorld, cDispenserEntity, &cWorld::DoWithDispenserAt>);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cPlugin");

View File

@ -348,10 +348,10 @@ public:
/// Calls the callback for the chest at the specified coords; returns false if there's no chest at those coords, true if found
bool DoWithChestAt (int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallback & a_Callback); // Exported in ManualBindings.cpp
/// Calls the callback for the dispenser at the specified coords; returns false if there's no dispenser at those coords, true if found
/// Calls the callback for the dispenser at the specified coords; returns false if there's no dispenser at those coords or callback returns true, returns true if found
bool DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDispenserCallback & a_Callback);
/// Calls the callback for the furnace at the specified coords; returns false if there's no furnace at those coords, true if found
/// Calls the callback for the furnace at the specified coords; returns false if there's no furnace at those coords or callback returns true, returns true if found
bool DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceCallback & a_Callback); // Exported in ManualBindings.cpp
/// Retrieves the test on the sign at the specified coords; returns false if there's no sign at those coords, true if found