Skip to content

Commit

Permalink
Add CFFLuaSC::DidReturnNil function
Browse files Browse the repository at this point in the history
  • Loading branch information
squeek502 committed Mar 23, 2015
1 parent 7568ea4 commit c692ca8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
22 changes: 14 additions & 8 deletions dlls/ff/ff_luacontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,27 +299,33 @@ void CFFLuaSC::ClearParams()
}

//---------------------------------------------------------------------------
bool CFFLuaSC::GetBool()
bool CFFLuaSC::GetBool(int idx/* = 0*/)
{
RETURN_OBJECTCAST(bool, false, 0);
RETURN_OBJECTCAST(bool, false, idx);
}

//---------------------------------------------------------------------------
float CFFLuaSC::GetFloat()
float CFFLuaSC::GetFloat(int idx/* = 0*/)
{
RETURN_OBJECTCAST(float, 0.0f, 0);
RETURN_OBJECTCAST(float, 0.0f, idx);
}

//---------------------------------------------------------------------------
int CFFLuaSC::GetInt()
int CFFLuaSC::GetInt(int idx/* = 0*/)
{
RETURN_OBJECTCAST(int, 0, 0);
RETURN_OBJECTCAST(int, 0, idx);
}

//---------------------------------------------------------------------------
luabind::adl::object* CFFLuaSC::GetObject()
luabind::adl::object* CFFLuaSC::GetObject(int idx/* = 0*/)
{
return m_returnVals[0];
return m_returnVals[idx];
}

//---------------------------------------------------------------------------
bool CFFLuaSC::DidReturnNil(int idx/* = 0*/)
{
return luabind::type(*GetObject(idx)) == LUA_TNIL;
}

//---------------------------------------------------------------------------
Expand Down
9 changes: 5 additions & 4 deletions dlls/ff/ff_luacontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ class CFFLuaSC
int GetNumReturns() const { return m_returnVals.Count(); }

// gets the return value
bool GetBool();
float GetFloat();
int GetInt();
bool GetBool(int idx = 0);
float GetFloat(int idx = 0);
int GetInt(int idx = 0);
QAngle GetQAngle();
Vector GetVector();
luabind::adl::object* GetObject();
luabind::adl::object* GetObject(int idx = 0);
bool DidReturnNil(int idx = 0);

public:
static void QuickCallFunction(CBaseEntity* pEntity, const char* szFunctionName);
Expand Down

0 comments on commit c692ca8

Please sign in to comment.