int CLuaVector4Defs::Eq ( lua_State* luaVM ) { CLuaVector4D* pVector1 = NULL; CLuaVector4D* pVector2 = NULL; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pVector1 ); argStream.ReadUserData ( pVector2 ); if ( !argStream.HasErrors () ) { lua_pushboolean ( luaVM, pVector1 == pVector2 ); return 1; } else { m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() ); } lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFunctionDefs::InjectBrowserMouseWheel ( lua_State* luaVM ) { // bool injectMouseWheel ( browser webBrowser, int scrollVertical, int scrollHorizontal ) CClientWebBrowser* pWebBrowser; int iScrollVert; int iScrollHorz; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pWebBrowser ); argStream.ReadNumber ( iScrollVert ); argStream.ReadNumber ( iScrollHorz ); if ( !argStream.HasErrors() ) { pWebBrowser->InjectMouseWheel ( iScrollVert, iScrollHorz ); lua_pushboolean ( luaVM, true ); return 1; } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFileDefs::fileRead ( lua_State* luaVM ) { // string fileRead ( file theFile, int count ) CScriptFile* pFile; unsigned long ulCount = 0; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pFile ); argStream.ReadNumber ( ulCount ); if ( !argStream.HasErrors () ) { // Reading zero bytes from a file results in an empty string if ( ulCount == 0 ) { lua_pushstring ( luaVM, "" ); return 1; } // Allocate a buffer to read the stuff into and read some :~ into it CBuffer buffer; long lBytesRead = pFile->Read ( ulCount, buffer ); if ( lBytesRead != -1 ) { // Push the string onto the Lua stack. Use pushlstring so we are binary // compatible. Normal push string takes zero terminated strings. lua_pushlstring ( luaVM, buffer.GetData(), lBytesRead ); return 1; } m_pScriptDebugging->LogBadPointer ( luaVM, "file", 1 ); } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); // Error lua_pushnil ( luaVM ); return 1; }
int CLuaVector4Defs::Destroy ( lua_State* luaVM ) { CLuaVector4D* pVector = NULL; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pVector ); if ( !argStream.HasErrors () ) { delete pVector; lua_pushboolean ( luaVM, true ); return 1; } else { m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() ); } lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFunctionDefs::ExecuteCommandHandler ( lua_State* luaVM ) { // bool executeCommandHandler ( string commandName, player thePlayer, [ string args ] ) SString strKey; CElement* pElement; SString strArgs; CScriptArgReader argStream ( luaVM ); argStream.ReadString ( strKey ); argStream.ReadUserData ( pElement ); argStream.ReadString ( strArgs, "" ); if ( !argStream.HasErrors () ) { // Grab our VM CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( pLuaMain ) { CClient* pClient = NULL; if ( pElement->GetType () == CElement::PLAYER ) pClient = static_cast <CClient*> ( static_cast <CPlayer*> ( pElement ) ); if ( pClient ) { // Call it if ( m_pRegisteredCommands->ProcessCommand ( strKey, strArgs, pClient ) ) { lua_pushboolean ( luaVM, true ); return 1; } } } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaPlayerDefs::GetPlayerPing ( lua_State* luaVM ) { // int getPlayerPing ( player thePlayer ) CClientPlayer* pPlayer; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pPlayer ); if ( !argStream.HasErrors () ) { // Grab his ping unsigned int uiPing = pPlayer->GetPing (); lua_pushnumber ( luaVM, uiPing ); return 1; } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); // Failed lua_pushboolean ( luaVM, false ); return 1; }
int CLuaResourceDefs::GetResourceRootElement ( lua_State* luaVM ) { // Verify arguments CResource* pResource = NULL; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pResource, NULL ); // No resource given, get this resource's root if ( !argStream.HasErrors () ) { if ( !pResource ) { // Find our vm and get the root CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( pLuaMain ) { pResource = pLuaMain->GetResource (); } } // Did we find a resource? if ( pResource ) { // Grab the root element of it and return it if it existed CClientEntity* pEntity = pResource->GetResourceEntity (); if ( pEntity ) { lua_pushelement ( luaVM, pEntity ); return 1; } } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); // Failed lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFunctionDefs::SetWeaponClipAmmo ( lua_State* luaVM ) { CClientWeapon * pWeapon = NULL; int iAmmo = 0; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pWeapon ); argStream.ReadNumber ( iAmmo ); if ( !argStream.HasErrors() ) { if ( CStaticFunctionDefinitions::SetWeaponClipAmmo( pWeapon, iAmmo ) ) { lua_pushboolean ( luaVM, true ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFunctionDefs::SetWeaponState ( lua_State* luaVM ) { CClientWeapon * pWeapon; eWeaponState weaponState; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pWeapon ); argStream.ReadEnumString ( weaponState ); if ( !argStream.HasErrors () ) { if ( CStaticFunctionDefinitions::SetWeaponState ( pWeapon, weaponState ) ) { lua_pushboolean ( luaVM, true ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() ); lua_pushboolean ( luaVM, false ); return 1; }
// // Material/string // void MixedReadMaterialString(CScriptArgReader& argStream, CClientMaterial*& pMaterialElement) { pMaterialElement = NULL; if (!argStream.NextIsString()) argStream.ReadUserData(pMaterialElement); else { SString strFilePath; argStream.ReadString(strFilePath); // If no element, auto find/create one CLuaMain* pLuaMain = g_pClientGame->GetLuaManager()->GetVirtualMachine(argStream.m_luaVM); CResource* pParentResource = pLuaMain ? pLuaMain->GetResource() : NULL; if (pParentResource) { CResource* pFileResource = pParentResource; SString strPath, strMetaPath; if (CResourceManager::ParseResourcePathInput(strFilePath, pFileResource, &strPath, &strMetaPath)) { SString strUniqueName = SString("%s*%s*%s", pParentResource->GetName(), pFileResource->GetName(), strMetaPath.c_str()).Replace("\\", "/"); pMaterialElement = g_pClientGame->GetManager()->GetRenderElementManager()->FindAutoTexture(strPath, strUniqueName); if (pMaterialElement) { // Check if brand new if (!pMaterialElement->GetParent()) // Make it a child of the resource's file root ** CHECK Should parent be pFileResource, and element added to pParentResource's // ElementGroup? ** pMaterialElement->SetParent(pParentResource->GetResourceDynamicEntity()); } else argStream.SetCustomError(strFilePath, "Error loading image"); } else argStream.SetCustomError(strFilePath, "Bad file path"); } } }
int CLuaOOPDefs::DxGetTextWidth ( lua_State* luaVM ) { // float dxGetTextWidth ( string text, [float scale=1, mixed font="default", bool colorCoded=false] ) SString strText; float fScale; CClientDxFont* pDxFontElement; bool bColorCoded; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pDxFontElement ); argStream.ReadString ( strText ); argStream.ReadNumber ( fScale, 1 ); argStream.ReadBool ( bColorCoded, false ); if ( !argStream.HasErrors () ) { ID3DXFont* pD3DXFont = CStaticFunctionDefinitions::ResolveD3DXFont ( FONT_DEFAULT, pDxFontElement ); // Retrieve the longest line's extent std::stringstream ssText ( strText ); std::string sLineText; float fWidth = 0.0f, fLineExtent = 0.0f; while ( std::getline ( ssText, sLineText ) ) { fLineExtent = g_pCore->GetGraphics ()->GetDXTextExtent ( sLineText.c_str (), fScale, pD3DXFont, bColorCoded ); if ( fLineExtent > fWidth ) fWidth = fLineExtent; } // Success lua_pushnumber ( luaVM, fWidth ); return 1; } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); // Failed lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFileDefs::fileSetPos ( lua_State* luaVM ) { // bool fileSetPos ( file ) // Grab the file pointer CScriptFile* pFile = NULL; unsigned long ulPosition = 0; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pFile ); argStream.ReadNumber ( ulPosition ); if ( !argStream.HasErrors ( ) ) { if ( pFile ) { long lResultPosition = pFile->SetPointer ( ulPosition ); if ( lResultPosition != -1 ) { // Set the position and return where we actually got it put lua_pushnumber ( luaVM, lResultPosition ); } else { m_pScriptDebugging->LogBadPointer ( luaVM, "file", 1 ); lua_pushnil ( luaVM ); } return 1; } else m_pScriptDebugging->LogBadPointer ( luaVM, "file", 1 ); } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() ); // Error lua_pushnil ( luaVM ); return 1; }
int CLuaBanDefs::SetBanNick ( lua_State* luaVM ) { CBan* pBan; SString strNick; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pBan ); argStream.ReadString ( strNick ); if ( !argStream.HasErrors () ) { if ( CStaticFunctionDefinitions::SetBanNick ( pBan, strNick ) ) { lua_pushboolean ( luaVM, true ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaMatrixDefs::SetUp ( lua_State* luaVM ) { CLuaMatrix* pMatrix = NULL; CVector vecUp; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pMatrix ); argStream.ReadVector3D ( vecUp ); if ( !argStream.HasErrors () ) { pMatrix->vUp = vecUp; lua_pushboolean( luaVM, true ); return 1; } else { m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() ); } lua_pushboolean( luaVM, false ); return 1; }
int CLuaMatrixDefs::TransformDirection ( lua_State* luaVM ) { CLuaMatrix* pMatrix1 = NULL; CVector vector; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pMatrix1 ); argStream.ReadVector3D ( vector ); if ( !argStream.HasErrors () ) { lua_pushvector ( luaVM, *pMatrix1 * vector ); return 1; } else { m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() ); } lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFunctionDefs::GetObjectScale ( lua_State* luaVM ) { // float getObjectScale ( object theObject ) CClientObject* pObject; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pObject ); if ( !argStream.HasErrors () ) { float fScale; if ( CStaticFunctionDefinitions::GetObjectScale ( *pObject, fScale ) ) { lua_pushnumber ( luaVM, fScale ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, SString ( "Bad argument @ '%s' [%s]", "getObjectScale", *argStream.GetErrorMessage () ) ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFunctionDefs::SetObjectStatic ( lua_State* luaVM ) { // bool setObjectStatic ( object theObject, bool toggle ) CClientEntity* pEntity; bool bStatic; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pEntity ); argStream.ReadBool ( bStatic ); if ( !argStream.HasErrors () ) { if ( CStaticFunctionDefinitions::SetObjectStatic ( *pEntity, bStatic ) ) { lua_pushboolean ( luaVM, true ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, SString ( "Bad argument @ '%s' [%s]", "setObjectStatic", *argStream.GetErrorMessage () ) ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFunctionDefs::SetObjectScale ( lua_State* luaVM ) { // bool setObjectScale ( object theObject, float scale ) CClientEntity* pEntity; float fScale; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pEntity ); argStream.ReadNumber ( fScale ); if ( !argStream.HasErrors () ) { if ( CStaticFunctionDefinitions::SetObjectScale ( *pEntity, fScale ) ) { lua_pushboolean ( luaVM, true ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, SString ( "Bad argument @ '%s' [%s]", "setObjectScale", *argStream.GetErrorMessage () ) ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaRadarAreaDefs::SetRadarAreaFlashing ( lua_State* luaVM ) { // bool setRadarAreaFlashing ( radararea theRadarArea, bool flash ) CClientRadarArea* pRadarArea; bool bFlash; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pRadarArea ); argStream.ReadBool ( bFlash ); if ( !argStream.HasErrors () ) { if ( CStaticFunctionDefinitions::SetRadarAreaFlashing ( pRadarArea, bFlash ) ) { lua_pushboolean ( luaVM, true ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFunctionDefs::SetTeamFriendlyFire ( lua_State* luaVM ) { CTeam* pElement; bool bFriendlyFire; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pElement ); argStream.ReadBool ( bFriendlyFire ); if ( !argStream.HasErrors () ) { if ( CStaticFunctionDefinitions::SetTeamFriendlyFire ( pElement, bFriendlyFire ) ) { lua_pushboolean ( luaVM, true ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaXMLDefs::xmlNodeSetValue ( lua_State* luaVM ) { CXMLNode* pNode = nullptr; SString strValue = ""; bool bUseCDATA; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pNode ); argStream.ReadString ( strValue ); argStream.ReadBool ( bUseCDATA, false ); if ( !argStream.HasErrors () ) { pNode->SetTagContent ( strValue, bUseCDATA ); lua_pushboolean ( luaVM, true ); return 1; } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFunctionDefs::IsObjectStatic ( lua_State* luaVM ) { // bool isObjectStatic ( object theObject ) CClientObject* pObject; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pObject ); if ( !argStream.HasErrors () ) { bool bStatic; if ( CStaticFunctionDefinitions::IsObjectStatic ( *pObject, bStatic ) ) { lua_pushboolean ( luaVM, bStatic ); return 1; } } else m_pScriptDebugging->LogBadType ( luaVM ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFunctionDefs::ToggleObjectRespawn ( lua_State* luaVM ) { // bool toggleObjectRespawn ( object theObject, bool respawn ) CClientEntity* pEntity; bool bRespawn; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pEntity ); argStream.ReadBool ( bRespawn ); if ( !argStream.HasErrors () ) { if ( CStaticFunctionDefinitions::ToggleObjectRespawn ( *pEntity, bRespawn ) ) { lua_pushboolean ( luaVM, true ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaBanDefs::SetUnbanTime ( lua_State* luaVM ) { CBan* pBan; time_t tUnbanTime; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pBan ); argStream.ReadNumber ( tUnbanTime ); if ( !argStream.HasErrors () ) { if ( CStaticFunctionDefinitions::SetUnbanTime ( pBan, tUnbanTime ) ) { lua_pushboolean ( luaVM, true ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFunctionDefs::SetObjectMass ( lua_State* luaVM ) { // bool setObjectMass ( object theObject, float fMass ) CClientEntity* pEntity; float fMass; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pEntity ); argStream.ReadNumber ( fMass ); if ( !argStream.HasErrors () ) { if ( CStaticFunctionDefinitions::SetObjectMass ( *pEntity, fMass ) ) { lua_pushboolean ( luaVM, true ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaACLDefs::aclDestroy ( lua_State* luaVM ) { // bool aclDestroy ( acl theACL ) CAccessControlList* pACL; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pACL ); if ( !argStream.HasErrors () ) { // Delete it CLogger::LogPrintf ( "ACL: %s: ACL '%s' deleted\n", GetResourceName ( luaVM ), pACL->GetName () ); m_pACLManager->DeleteACL ( pACL ); // Return true lua_pushboolean ( luaVM, true ); return 1; } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaXMLDefs::xmlUnloadFile ( lua_State* luaVM ) { CXMLNode* pNode = nullptr; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pNode ); if ( !argStream.HasErrors () ) { CLuaMain * luaMain = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( luaMain ) { luaMain->DestroyXML ( pNode ); lua_pushboolean ( luaVM, true ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaACLDefs::aclDestroyGroup ( lua_State* luaVM ) { // bool aclDestroyGroup ( aclgroup aclGroup ) CAccessControlListGroup* pGroup; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pGroup ); if ( !argStream.HasErrors () ) { // Delete it CLogger::LogPrintf ( "ACL: %s: Group '%s' deleted\n", GetResourceName ( luaVM ), pGroup->GetGroupName () ); m_pACLManager->DeleteGroup ( pGroup ); // Return success lua_pushboolean ( luaVM, true ); return 1; } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaVector4Defs::GetNormalized ( lua_State* luaVM ) { CLuaVector4D* pVector = NULL; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pVector ); if ( !argStream.HasErrors () ) { CVector4D vector ( *pVector ); vector.Normalize (); lua_pushvector ( luaVM, vector ); return 1; } else { m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() ); } lua_pushboolean ( luaVM, false ); return 1; }
int CLuaRadarAreaDefs::SetRadarAreaSize ( lua_State* luaVM ) { // bool setRadarAreaSize ( radararea theRadararea, float x, float y ) CClientRadarArea* pRadarArea; CVector2D vecSize; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pRadarArea ); argStream.ReadVector2D ( vecSize ); if ( !argStream.HasErrors () ) { if ( CStaticFunctionDefinitions::SetRadarAreaSize ( pRadarArea, vecSize ) ) { lua_pushboolean ( luaVM, true ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }