本文整理汇总了C++中CElementGroup::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ CElementGroup::Add方法的具体用法?C++ CElementGroup::Add怎么用?C++ CElementGroup::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CElementGroup
的用法示例。
在下文中一共展示了CElementGroup::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateMarker
int CLuaMarkerDefs::CreateMarker(lua_State* luaVM)
{
CVector vecPosition;
float fSize;
SColorRGBA color(0, 0, 255, 255);
SString strType;
CElement* pVisibleTo;
CScriptArgReader argStream(luaVM);
argStream.ReadVector3D(vecPosition);
argStream.ReadString(strType, "default");
argStream.ReadNumber(fSize, 4.0f);
argStream.ReadNumber(color.R, color.R);
argStream.ReadNumber(color.G, color.G);
argStream.ReadNumber(color.B, color.B);
argStream.ReadNumber(color.A, color.A);
if (argStream.NextIsBool() || argStream.NextIsNil())
{
pVisibleTo = NULL;
}
else
argStream.ReadUserData(pVisibleTo, m_pRootElement);
if (!argStream.HasErrors())
{
CLuaMain* pLuaMain = g_pGame->GetLuaManager()->GetVirtualMachine(luaVM);
if (pLuaMain)
{
CResource* pResource = pLuaMain->GetResource();
if (pResource)
{
// Create it
CMarker* pMarker = CStaticFunctionDefinitions::CreateMarker(pResource, vecPosition, strType, fSize, color, pVisibleTo);
if (pMarker)
{
CElementGroup* pGroup = pResource->GetElementGroup();
if (pGroup)
{
pGroup->Add(pMarker);
}
lua_pushelement(luaVM, pMarker);
return 1;
}
}
}
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
lua_pushboolean(luaVM, false);
return 1;
}
示例2: CreateObject
int CLuaFunctionDefs::CreateObject ( lua_State* luaVM )
{
// object createObject ( int modelid, float x, float y, float z, [float rx, float ry, float rz, bool lowLOD] )
ushort usModelID; CVector vecPosition; CVector vecRotation; bool bLowLod;
CScriptArgReader argStream ( luaVM );
argStream.ReadNumber ( usModelID );
argStream.ReadNumber ( vecPosition.fX );
argStream.ReadNumber ( vecPosition.fY );
argStream.ReadNumber ( vecPosition.fZ );
argStream.ReadNumber ( vecRotation.fX, 0 );
argStream.ReadNumber ( vecRotation.fY, 0 );
argStream.ReadNumber ( vecRotation.fZ, 0 );
argStream.ReadBool ( bLowLod, false );
if ( !argStream.HasErrors () )
{
if ( CClientObjectManager::IsValidModel ( usModelID ) )
{
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( pLuaMain )
{
CResource* pResource = pLuaMain->GetResource ();
if ( pResource )
{
CClientObject* pObject = CStaticFunctionDefinitions::CreateObject ( *pResource, usModelID, vecPosition, vecRotation, bLowLod );
if ( pObject )
{
CElementGroup * pGroup = pResource->GetElementGroup();
if ( pGroup )
{
pGroup->Add ( ( CClientEntity* ) pObject );
}
lua_pushelement ( luaVM, pObject );
return 1;
}
}
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, SString ( "Bad argument @ '%s' [%s]", "createObject", "Invalid model id" ) );
}
else
m_pScriptDebugging->LogCustom ( luaVM, SString ( "Bad argument @ '%s' [%s]", "createObject", *argStream.GetErrorMessage () ) );
lua_pushboolean ( luaVM, false );
return 1;
}
示例3: CreateRadarArea
int CLuaRadarAreaDefs::CreateRadarArea(lua_State* luaVM)
{
// radararea createRadarArea ( float startPosX, float startPosY, float sizeX, float sizeY, [ int r = 255, int g = 0, int b = 0, int a = 255, element
// visibleTo = getRootElement() ] )
CVector2D vecPosition;
CVector2D vecSize;
float dRed;
float dGreen;
float dBlue;
float dAlpha;
CElement* pVisibleTo;
CScriptArgReader argStream(luaVM);
argStream.ReadVector2D(vecPosition);
argStream.ReadVector2D(vecSize);
argStream.ReadNumber(dRed, 255);
argStream.ReadNumber(dGreen, 0);
argStream.ReadNumber(dBlue, 0);
argStream.ReadNumber(dAlpha, 255);
argStream.ReadUserData(pVisibleTo, m_pRootElement);
if (!argStream.HasErrors())
{
CLuaMain* pLuaMain = g_pGame->GetLuaManager()->GetVirtualMachine(luaVM);
CResource* pResource = pLuaMain ? pLuaMain->GetResource() : NULL;
if (pResource)
{
SColorRGBA color(dRed, dGreen, dBlue, dAlpha);
// Create it
CRadarArea* pRadarArea = CStaticFunctionDefinitions::CreateRadarArea(pResource, vecPosition, vecSize, color, pVisibleTo);
if (pRadarArea)
{
CElementGroup* pGroup = pResource->GetElementGroup();
if (pGroup)
{
pGroup->Add(pRadarArea);
}
lua_pushelement(luaVM, pRadarArea);
return 1;
}
}
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
lua_pushboolean(luaVM, false);
return 1;
}
示例4: CreateColTube
int CLuaColShapeDefs::CreateColTube ( lua_State* luaVM )
{
CVector vecPosition;
float fRadius = 0.1f, fHeight = 0.1f;
CScriptArgReader argStream ( luaVM );
argStream.ReadVector3D ( vecPosition );
argStream.ReadNumber ( fRadius );
argStream.ReadNumber ( fHeight );
if ( fRadius < 0.0f )
{
fRadius = 0.1f;
}
if ( fHeight < 0.0f )
{
fHeight = 0.1f;
}
if ( !argStream.HasErrors () )
{
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( pLuaMain )
{
CResource* pResource = pLuaMain->GetResource ();
if ( pResource )
{
// Create it and return it
CClientColTube* pShape = CStaticFunctionDefinitions::CreateColTube ( *pResource, vecPosition, fRadius, fHeight );
if ( pShape )
{
CElementGroup * pGroup = pResource->GetElementGroup ();
if ( pGroup )
{
pGroup->Add ( (CClientEntity*) pShape );
}
lua_pushelement ( luaVM, pShape );
return 1;
}
}
}
}
else
m_pScriptDebugging->LogBadType ( luaVM );
lua_pushboolean ( luaVM, false );
return 1;
}
示例5: CreateColRectangle
int CLuaColShapeDefs::CreateColRectangle ( lua_State* luaVM )
{
CVector2D vecPosition;
CVector2D vecSize;
CScriptArgReader argStream ( luaVM );
argStream.ReadVector2D ( vecPosition );
argStream.ReadVector2D ( vecSize );
if ( vecSize.fX < 0.0f )
{
vecSize.fX = 0.1f;
}
if ( vecSize.fY < 0.0f )
{
vecSize.fY = 0.1f;
}
if ( !argStream.HasErrors () )
{
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( pLuaMain )
{
CResource* pResource = pLuaMain->GetResource ();
if ( pResource )
{
// Create it and return it
CClientColRectangle* pShape = CStaticFunctionDefinitions::CreateColRectangle ( *pResource, vecPosition, vecSize );
if ( pShape )
{
CElementGroup * pGroup = pResource->GetElementGroup ();
if ( pGroup )
{
pGroup->Add ( (CClientEntity*) pShape );
}
lua_pushelement ( luaVM, pShape );
return 1;
}
}
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例6: CreateLight
int CLuaPointLightDefs::CreateLight ( lua_State* luaVM )
{
// light createLight ( int lightType, float posX, float posY, float posX, [ float radius = 3, int r = 255, int g = 0, int b = 0, float dirX = 0, float dirY = 0, float dirZ = 0, bool createsShadow = false ] )
int iMode;
CVector vecPosition;
float fRadius;
SColor color;
CVector vecDirection;
bool bCreatesShadow;
CScriptArgReader argStream ( luaVM );
argStream.ReadNumber ( iMode );
argStream.ReadVector3D ( vecPosition );
argStream.ReadNumber ( fRadius, 3.0f );
argStream.ReadNumber ( color.R, 255 );
argStream.ReadNumber ( color.G, 0 );
argStream.ReadNumber ( color.B, 0 );
argStream.ReadVector3D ( vecDirection, vecDirection );
argStream.ReadBool ( bCreatesShadow, false );
if ( !argStream.HasErrors () )
{
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
CResource* pResource = pLuaMain ? pLuaMain->GetResource () : NULL;
if ( pResource )
{
// Create it
CClientPointLights* pLight = CStaticFunctionDefinitions::CreateLight ( *pResource, iMode, vecPosition, fRadius, color, vecDirection );
if ( pLight )
{
CElementGroup * pGroup = pResource->GetElementGroup ();
if ( pGroup )
{
pGroup->Add ( (CClientEntity*) pLight );
}
lua_pushelement ( luaVM, pLight );
return 1;
}
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, SString ( "Bad argument @ '%s' [%s]", lua_tostring ( luaVM, lua_upvalueindex ( 1 ) ), *argStream.GetErrorMessage () ) );
lua_pushboolean ( luaVM, false );
return 1;
}
示例7: CreateColTube
int CLuaColShapeDefs::CreateColTube(lua_State* luaVM)
{
CVector vecPosition;
float fHeight, fRadius;
CScriptArgReader argStream(luaVM);
argStream.ReadVector3D(vecPosition);
argStream.ReadNumber(fRadius);
argStream.ReadNumber(fHeight);
if (!argStream.HasErrors())
{
if (fRadius < 0.0f)
fRadius = 0.1f;
if (fHeight < 0.0f)
fHeight = 0.1f;
CLuaMain* pLuaMain = g_pGame->GetLuaManager()->GetVirtualMachine(luaVM);
if (pLuaMain)
{
CResource* pResource = pLuaMain->GetResource();
if (pResource)
{
// Create it and return it
CColTube* pShape = CStaticFunctionDefinitions::CreateColTube(pResource, vecPosition, fRadius, fHeight);
if (pShape)
{
CElementGroup* pGroup = pResource->GetElementGroup();
if (pGroup)
{
pGroup->Add(pShape);
}
lua_pushelement(luaVM, pShape);
return 1;
}
}
}
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
lua_pushboolean(luaVM, false);
return 1;
}
示例8: CreateTeam
int CLuaFunctionDefs::CreateTeam ( lua_State* luaVM )
{
SString strName;
unsigned char ucRed;
unsigned char ucGreen;
unsigned char ucBlue;
CScriptArgReader argStream ( luaVM );
argStream.ReadString ( strName );
argStream.ReadNumber ( ucRed, 235 );
argStream.ReadNumber ( ucGreen, 221 );
argStream.ReadNumber ( ucBlue, 178 );
if ( !argStream.HasErrors () )
{
CLuaMain* pLuaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
if ( pLuaMain )
{
CResource* pResource = pLuaMain->GetResource ();
if ( pResource )
{
CTeam* pTeam = CStaticFunctionDefinitions::CreateTeam ( pResource, strName, ucRed, ucGreen, ucBlue );
if ( pTeam )
{
CElementGroup * pGroup = pResource->GetElementGroup ();
if ( pGroup )
{
pGroup->Add ( pTeam );
}
lua_pushelement ( luaVM, pTeam );
return 1;
}
}
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例9: CreatePed
int CLuaPedDefs::CreatePed ( lua_State* luaVM )
{
unsigned short usModel;
CVector vecPosition;
float fRotation;
bool bSynced;
CScriptArgReader argStream ( luaVM );
argStream.ReadNumber ( usModel );
argStream.ReadVector3D ( vecPosition );
argStream.ReadNumber ( fRotation, 0.0f );
argStream.ReadBool ( bSynced, true );
if ( !argStream.HasErrors () )
{
CLuaMain * pLuaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
if ( pLuaMain )
{
CResource * pResource = pLuaMain->GetResource ();
if ( pResource )
{
// Create the ped and return its handle
CPed* pPed = CStaticFunctionDefinitions::CreatePed ( pResource, usModel, vecPosition, fRotation, bSynced );
if ( pPed )
{
CElementGroup * pGroup = pResource->GetElementGroup ();
if ( pGroup )
{
pGroup->Add ( pPed );
}
lua_pushelement ( luaVM, pPed );
return 1;
}
}
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例10: CreateColPolygon
int CLuaColShapeDefs::CreateColPolygon ( lua_State* luaVM )
{
CVector2D vecPosition;
CScriptArgReader argStream ( luaVM );
argStream.ReadVector2D ( vecPosition );
if ( !argStream.HasErrors () )
{
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( pLuaMain )
{
CResource* pResource = pLuaMain->GetResource ();
if ( pResource )
{
// Create it and return it
CClientColPolygon* pShape = CStaticFunctionDefinitions::CreateColPolygon ( *pResource, vecPosition );
if ( pShape )
{
// Get the points
while ( argStream.NextCouldBeNumber () && argStream.NextCouldBeNumber ( 1 ) )
{
argStream.ReadVector2D ( vecPosition );
pShape->AddPoint ( vecPosition );
}
CElementGroup * pGroup = pResource->GetElementGroup ();
if ( pGroup )
{
pGroup->Add ( pShape );
}
lua_pushelement ( luaVM, pShape );
return 1;
}
}
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例11: CreateColPolygon
int CLuaColShapeDefs::CreateColPolygon(lua_State* luaVM)
{
// colshape createColPolygon ( float fX, float fY, float fX1, float fY1, float fX2, float fY2, float fX3, float fY3, ... )
std::vector<CVector2D> vecPointList;
CScriptArgReader argStream(luaVM);
for (uint i = 0; i < 4 || argStream.NextCouldBeNumber(); i++)
{
CVector2D vecPoint;
argStream.ReadVector2D(vecPoint);
vecPointList.push_back(vecPoint);
}
if (!argStream.HasErrors())
{
CLuaMain* pLuaMain = g_pGame->GetLuaManager()->GetVirtualMachine(luaVM);
if (pLuaMain)
{
CResource* pResource = pLuaMain->GetResource();
if (pResource)
{
CColPolygon* pShape = CStaticFunctionDefinitions::CreateColPolygon(pResource, vecPointList);
if (pShape)
{
CElementGroup* pGroup = pResource->GetElementGroup();
if (pGroup)
{
pGroup->Add(pShape);
}
lua_pushelement(luaVM, pShape);
return 1;
}
}
}
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
lua_pushboolean(luaVM, false);
return 1;
}
示例12: CreateSearchLight
int CLuaSearchLightDefs::CreateSearchLight(lua_State* luaVM)
{
// searchlight createSearchLight ( float startX, float startY, float startZ, float endX, float endY, float endZ, float startRadius, float endRadius [, bool
// renderSpot = true ] )
CVector vecStart, vecEnd;
float startRadius, endRadius;
bool renderSpot;
CScriptArgReader argStream(luaVM);
argStream.ReadVector3D(vecStart);
argStream.ReadVector3D(vecEnd);
argStream.ReadNumber(startRadius);
argStream.ReadNumber(endRadius);
argStream.ReadBool(renderSpot, true);
if (!argStream.HasErrors())
{
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine(luaVM);
CResource* pResource = pLuaMain ? pLuaMain->GetResource() : nullptr;
if (pResource)
{
auto pLight = CStaticFunctionDefinitions::CreateSearchLight(*pResource, vecStart, vecEnd, startRadius, endRadius, renderSpot);
if (pLight)
{
CElementGroup* pGroup = pResource->GetElementGroup();
if (pGroup)
pGroup->Add(pLight);
lua_pushelement(luaVM, pLight);
return 1;
}
}
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
lua_pushboolean(luaVM, false);
return 1;
}
示例13: CreateWeapon
int CLuaFunctionDefs::CreateWeapon ( lua_State* luaVM )
{
CVector vecPos;
eWeaponType weaponType;
CScriptArgReader argStream ( luaVM );
argStream.ReadEnumStringOrNumber ( weaponType );
argStream.ReadNumber ( vecPos.fX );
argStream.ReadNumber ( vecPos.fY );
argStream.ReadNumber ( vecPos.fZ );
if ( !argStream.HasErrors () )
{
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( pLuaMain )
{
CResource* pResource = pLuaMain->GetResource ();
if ( pResource )
{
CClientWeapon * pWeapon = CStaticFunctionDefinitions::CreateWeapon ( *pResource, weaponType, vecPos );
if ( pWeapon )
{
CElementGroup * pGroup = pResource->GetElementGroup();
if ( pGroup )
{
pGroup->Add ( ( CClientEntity* ) pWeapon );
}
lua_pushelement ( luaVM, pWeapon );
return 1;
}
}
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
lua_pushboolean ( luaVM, false );
return 1;
}
示例14: CreateProjectile
int CLuaFunctionDefs::CreateProjectile ( lua_State* luaVM )
{
if ( ( lua_istype ( luaVM, 1, LUA_TLIGHTUSERDATA ) ) &&
( lua_istype ( luaVM, 2, LUA_TNUMBER ) || lua_istype ( luaVM, 2, LUA_TSTRING ) ) )
{
CClientEntity* pCreator = lua_toelement ( luaVM, 1 );
if ( pCreator )
{
unsigned char ucWeaponType = static_cast < unsigned char > ( lua_tonumber ( luaVM, 2 ) );
CVector vecOrigin;
pCreator->GetPosition ( vecOrigin );
float fForce = 1.0f;
CClientEntity* pTarget = NULL;
CVector *pvecRotation = NULL, *pvecMoveSpeed = NULL;
unsigned short usModel = 0;
if ( ( lua_istype ( luaVM, 3, LUA_TNUMBER ) || lua_istype ( luaVM, 3, LUA_TSTRING ) ) &&
( lua_istype ( luaVM, 4, LUA_TNUMBER ) || lua_istype ( luaVM, 4, LUA_TSTRING ) ) &&
( lua_istype ( luaVM, 5, LUA_TNUMBER ) || lua_istype ( luaVM, 5, LUA_TSTRING ) ) )
{
vecOrigin = CVector ( static_cast < float > ( lua_tonumber ( luaVM, 3 ) ),
static_cast < float > ( lua_tonumber ( luaVM, 4 ) ),
static_cast < float > ( lua_tonumber ( luaVM, 5 ) ) );
if ( lua_istype ( luaVM, 6, LUA_TNUMBER ) || lua_istype ( luaVM, 6, LUA_TSTRING ) )
{
fForce = static_cast < float > ( lua_tonumber ( luaVM, 6 ) );
if ( lua_istype ( luaVM, 7, LUA_TLIGHTUSERDATA ) )
{
CClientEntity* pTemp = lua_toelement ( luaVM, 7 );
if ( pTemp )
{
pTarget = pTemp;
}
else
m_pScriptDebugging->LogBadPointer ( luaVM, "createProjectile", "element", 7 );
}
int iArgument8 = lua_type ( luaVM, 8 );
int iArgument9 = lua_type ( luaVM, 9 );
int iArgument10 = lua_type ( luaVM, 10 );
if ( ( iArgument8 == LUA_TSTRING || iArgument8 == LUA_TNUMBER ) &&
( iArgument9 == LUA_TSTRING || iArgument9 == LUA_TNUMBER ) &&
( iArgument10 == LUA_TSTRING || iArgument10 == LUA_TNUMBER ) )
{
pvecRotation = new CVector ( static_cast < float > ( lua_tonumber ( luaVM, 8 ) ),
static_cast < float > ( lua_tonumber ( luaVM, 9 ) ),
static_cast < float > ( lua_tonumber ( luaVM, 10 ) ) );
}
int iArgument11 = lua_type ( luaVM, 11 );
int iArgument12 = lua_type ( luaVM, 12 );
int iArgument13 = lua_type ( luaVM, 13 );
if ( ( iArgument11 == LUA_TSTRING || iArgument11 == LUA_TNUMBER ) &&
( iArgument12 == LUA_TSTRING || iArgument12 == LUA_TNUMBER ) &&
( iArgument13 == LUA_TSTRING || iArgument13 == LUA_TNUMBER ) )
{
pvecMoveSpeed = new CVector ( static_cast < float > ( lua_tonumber ( luaVM, 11 ) ),
static_cast < float > ( lua_tonumber ( luaVM, 12 ) ),
static_cast < float > ( lua_tonumber ( luaVM, 13 ) ) );
int iArgument14 = lua_type ( luaVM, 14 );
if ( iArgument14 == LUA_TSTRING || iArgument14 == LUA_TNUMBER )
{
usModel = static_cast < unsigned short > ( lua_tonumber ( luaVM, 14 ) );
}
}
}
}
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( pLuaMain )
{
CResource * pResource = pLuaMain->GetResource();
if ( pResource )
{
CClientProjectile * pProjectile = CStaticFunctionDefinitions::CreateProjectile ( *pResource, *pCreator, ucWeaponType, vecOrigin, fForce, pTarget, pvecRotation, pvecMoveSpeed, usModel );
if ( pProjectile )
{
CElementGroup * pGroup = pResource->GetElementGroup();
if ( pGroup )
{
pGroup->Add ( ( CClientEntity* ) pProjectile );
}
if ( pvecRotation )
{
delete pvecRotation;
pvecRotation = NULL;
}
if ( pvecMoveSpeed )
{
delete pvecMoveSpeed;
pvecMoveSpeed = NULL;
}
lua_pushelement ( luaVM, pProjectile );
return 1;
}
}
}
//.........这里部分代码省略.........
示例15: fileCreate
int CLuaFileDefs::fileCreate ( lua_State* luaVM )
{
// file fileCreate ( string filePath )
SString filePath;
CScriptArgReader argStream ( luaVM );
argStream.ReadString ( filePath );
if ( !argStream.HasErrors () )
{
// Grab our lua VM
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( !g_pNet->ValidateBinaryFileName ( filePath ) )
{
argStream.SetCustomError ( SString ( "Filename not allowed %s", *filePath ), "File error" );
}
else
if ( pLuaMain )
{
SString strAbsPath;
SString strMetaPath;
CResource* pThisResource = pLuaMain->GetResource ();
CResource* pResource = pThisResource;
if ( CResourceManager::ParseResourcePathInput ( filePath, pResource, strAbsPath, strMetaPath ) )
{
// Inform file verifier
g_pClientGame->GetResourceManager()->FileModifedByScript( strAbsPath );
// Make sure the destination folder exist so we can create the file
MakeSureDirExists ( strAbsPath.c_str () );
// Create the file to create
eAccessType accessType = filePath[0] == '@' ? eAccessType::ACCESS_PRIVATE : eAccessType::ACCESS_PUBLIC;
CScriptFile* pFile = new CScriptFile( pThisResource->GetScriptID( ), strMetaPath.c_str(), DEFAULT_MAX_FILESIZE, accessType);
assert ( pFile );
// Try to load it
if ( pFile->Load ( pResource, CScriptFile::MODE_CREATE ) )
{
// Make it a child of the resource's file root
pFile->SetParent ( pResource->GetResourceDynamicEntity () );
// Add it to the scrpt resource element group
CElementGroup* pGroup = pThisResource->GetElementGroup ();
if ( pGroup )
{
pGroup->Add ( pFile );
}
// Success. Return the file.
lua_pushelement ( luaVM, pFile );
return 1;
}
else
{
// Delete the file again
delete pFile;
// Output error
argStream.SetCustomError ( SString ( "Unable to create %s", *filePath ), "File error" );
}
}
}
}
if ( argStream.HasErrors () )
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
// Failed
lua_pushboolean ( luaVM, false );
return 1;
}