1
0

Fixed OnProjectileHitBlock bindings.

Also sorted the various cLuaState::Push() functions.
This commit is contained in:
madmaxoft 2014-06-03 19:29:04 +02:00
parent 62ea8615b7
commit d92520016d
3 changed files with 213 additions and 184 deletions

View File

@ -372,11 +372,11 @@ void cLuaState::Push(const AStringVector & a_Vector)
void cLuaState::PushUserType(void * a_Object, const char * a_Type)
void cLuaState::Push(const cCraftingGrid * a_Grid)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_Object, a_Type);
tolua_pushusertype(m_LuaState, (void *)a_Grid, "cCraftingGrid");
m_NumCurrentFunctionArgs += 1;
}
@ -384,23 +384,11 @@ void cLuaState::PushUserType(void * a_Object, const char * a_Type)
void cLuaState::Push(int a_Value)
void cLuaState::Push(const cCraftingRecipe * a_Recipe)
{
ASSERT(IsValid());
tolua_pushnumber(m_LuaState, a_Value);
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(double a_Value)
{
ASSERT(IsValid());
tolua_pushnumber(m_LuaState, a_Value);
tolua_pushusertype(m_LuaState, (void *)a_Recipe, "cCraftingRecipe");
m_NumCurrentFunctionArgs += 1;
}
@ -420,35 +408,11 @@ void cLuaState::Push(const char * a_Value)
void cLuaState::Push(bool a_Value)
void cLuaState::Push(const cItems & a_Items)
{
ASSERT(IsValid());
tolua_pushboolean(m_LuaState, a_Value ? 1 : 0);
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(cWorld * a_World)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_World, "cWorld");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(cPlayer * a_Player)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_Player, "cPlayer");
tolua_pushusertype(m_LuaState, (void *)&a_Items, "cItems");
m_NumCurrentFunctionArgs += 1;
}
@ -468,6 +432,90 @@ void cLuaState::Push(const cPlayer * a_Player)
void cLuaState::Push(const HTTPRequest * a_Request)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPRequest");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(const HTTPTemplateRequest * a_Request)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPTemplateRequest");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(const Vector3d & a_Vector)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, (void *)&a_Vector, "Vector3d");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(bool a_Value)
{
ASSERT(IsValid());
tolua_pushboolean(m_LuaState, a_Value ? 1 : 0);
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(cBlockEntity * a_BlockEntity)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_BlockEntity, "cBlockEntity");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(cChunkDesc * a_ChunkDesc)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_ChunkDesc, "cChunkDesc");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(cClientHandle * a_Client)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_Client, "cClientHandle");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(cEntity * a_Entity)
{
ASSERT(IsValid());
@ -480,23 +528,11 @@ void cLuaState::Push(cEntity * a_Entity)
void cLuaState::Push(cProjectileEntity * a_ProjectileEntity)
void cLuaState::Push(cHopperEntity * a_Hopper)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_ProjectileEntity, "cProjectileEntity");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(cMonster * a_Monster)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_Monster, "cMonster");
tolua_pushusertype(m_LuaState, a_Hopper, "cHopperEntity");
m_NumCurrentFunctionArgs += 1;
}
@ -528,23 +564,11 @@ void cLuaState::Push(cItems * a_Items)
void cLuaState::Push(const cItems & a_Items)
void cLuaState::Push(cMonster * a_Monster)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, (void *)&a_Items, "cItems");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(cClientHandle * a_Client)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_Client, "cClientHandle");
tolua_pushusertype(m_LuaState, a_Monster, "cMonster");
m_NumCurrentFunctionArgs += 1;
}
@ -564,59 +588,11 @@ void cLuaState::Push(cPickup * a_Pickup)
void cLuaState::Push(cChunkDesc * a_ChunkDesc)
void cLuaState::Push(cPlayer * a_Player)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_ChunkDesc, "cChunkDesc");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(const cCraftingGrid * a_Grid)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, (void *)a_Grid, "cCraftingGrid");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(const cCraftingRecipe * a_Recipe)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, (void *)a_Recipe, "cCraftingRecipe");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(TakeDamageInfo * a_TDI)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_TDI, "TakeDamageInfo");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(cWindow * a_Window)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_Window, "cWindow");
tolua_pushusertype(m_LuaState, a_Player, "cPlayer");
m_NumCurrentFunctionArgs += 1;
}
@ -636,35 +612,11 @@ void cLuaState::Push(cPluginLua * a_Plugin)
void cLuaState::Push(const HTTPRequest * a_Request)
void cLuaState::Push(cProjectileEntity * a_ProjectileEntity)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPRequest");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(cWebAdmin * a_WebAdmin)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_WebAdmin, "cWebAdmin");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(const HTTPTemplateRequest * a_Request)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPTemplateRequest");
tolua_pushusertype(m_LuaState, a_ProjectileEntity, "cProjectileEntity");
m_NumCurrentFunctionArgs += 1;
}
@ -684,6 +636,78 @@ void cLuaState::Push(cTNTEntity * a_TNTEntity)
void cLuaState::Push(cWebAdmin * a_WebAdmin)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_WebAdmin, "cWebAdmin");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(cWindow * a_Window)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_Window, "cWindow");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(cWorld * a_World)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_World, "cWorld");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(double a_Value)
{
ASSERT(IsValid());
tolua_pushnumber(m_LuaState, a_Value);
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(int a_Value)
{
ASSERT(IsValid());
tolua_pushnumber(m_LuaState, a_Value);
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(TakeDamageInfo * a_TDI)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_TDI, "TakeDamageInfo");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(Vector3i * a_Vector)
{
ASSERT(IsValid());
@ -696,6 +720,18 @@ void cLuaState::Push(Vector3i * a_Vector)
void cLuaState::Push(Vector3d * a_Vector)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_Vector, "Vector3d");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(void * a_Ptr)
{
UNUSED(a_Ptr);
@ -715,23 +751,12 @@ void cLuaState::Push(void * a_Ptr)
void cLuaState::Push(cHopperEntity * a_Hopper)
void cLuaState::PushUserType(void * a_Object, const char * a_Type)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_Hopper, "cHopperEntity");
m_NumCurrentFunctionArgs += 1;
}
void cLuaState::Push(cBlockEntity * a_BlockEntity)
{
ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_BlockEntity, "cBlockEntity");
tolua_pushusertype(m_LuaState, a_Object, a_Type);
m_NumCurrentFunctionArgs += 1;
}

View File

@ -173,38 +173,42 @@ public:
/** Returns true if a_FunctionName is a valid Lua function that can be called */
bool HasFunction(const char * a_FunctionName);
// Push a value onto the stack
// Push a const value onto the stack (keep alpha-sorted):
void Push(const AString & a_String);
void Push(const AStringVector & a_Vector);
void Push(int a_Value);
void Push(double a_Value);
void Push(const char * a_Value);
void Push(bool a_Value);
void Push(cWorld * a_World);
void Push(cPlayer * a_Player);
void Push(const cPlayer * a_Player);
void Push(cEntity * a_Entity);
void Push(cProjectileEntity * a_ProjectileEntity);
void Push(cMonster * a_Monster);
void Push(cItem * a_Item);
void Push(cItems * a_Items);
void Push(const cItems & a_Items);
void Push(cClientHandle * a_ClientHandle);
void Push(cPickup * a_Pickup);
void Push(cChunkDesc * a_ChunkDesc);
void Push(const cCraftingGrid * a_Grid);
void Push(const cCraftingRecipe * a_Recipe);
void Push(TakeDamageInfo * a_TDI);
void Push(cWindow * a_Window);
void Push(cPluginLua * a_Plugin);
void Push(const char * a_Value);
void Push(const cItems & a_Items);
void Push(const cPlayer * a_Player);
void Push(const HTTPRequest * a_Request);
void Push(cWebAdmin * a_WebAdmin);
void Push(const HTTPTemplateRequest * a_Request);
void Push(const Vector3d & a_Vector);
// Push a value onto the stack (keep alpha-sorted):
void Push(bool a_Value);
void Push(cBlockEntity * a_BlockEntity);
void Push(cChunkDesc * a_ChunkDesc);
void Push(cClientHandle * a_ClientHandle);
void Push(cEntity * a_Entity);
void Push(cHopperEntity * a_Hopper);
void Push(cItem * a_Item);
void Push(cItems * a_Items);
void Push(cMonster * a_Monster);
void Push(cPickup * a_Pickup);
void Push(cPlayer * a_Player);
void Push(cPluginLua * a_Plugin);
void Push(cProjectileEntity * a_ProjectileEntity);
void Push(cTNTEntity * a_TNTEntity);
void Push(cWebAdmin * a_WebAdmin);
void Push(cWindow * a_Window);
void Push(cWorld * a_World);
void Push(double a_Value);
void Push(int a_Value);
void Push(TakeDamageInfo * a_TDI);
void Push(Vector3d * a_Vector);
void Push(Vector3i * a_Vector);
void Push(void * a_Ptr);
void Push(cHopperEntity * a_Hopper);
void Push(cBlockEntity * a_BlockEntity);
/** Retrieve value at a_StackPos, if it is a valid bool. If not, a_Value is unchanged */
void GetStackValue(int a_StackPos, bool & a_Value);

View File

@ -1120,7 +1120,7 @@ bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile, int a_Bl
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PROJECTILE_HIT_BLOCK];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
m_LuaState.Call((int)(**itr), &a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, &a_BlockHitPos, cLuaState::Return, res);
m_LuaState.Call((int)(**itr), &a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, a_BlockHitPos, cLuaState::Return, res);
if (res)
{
return true;