@@ -16,6 +16,7 @@ void CLuaEngineDefs::LoadFunctions ( void )
16
16
CLuaCFunctions::AddFunction ( " engineLoadTXD" , EngineLoadTXD );
17
17
CLuaCFunctions::AddFunction ( " engineLoadCOL" , EngineLoadCOL );
18
18
CLuaCFunctions::AddFunction ( " engineLoadDFF" , EngineLoadDFF );
19
+ CLuaCFunctions::AddFunction ( " engineLoadIFP" , EngineLoadIFP );
19
20
CLuaCFunctions::AddFunction ( " engineImportTXD" , EngineImportTXD );
20
21
CLuaCFunctions::AddFunction ( " engineReplaceCOL" , EngineReplaceCOL );
21
22
CLuaCFunctions::AddFunction ( " engineRestoreCOL" , EngineRestoreCOL );
@@ -278,6 +279,65 @@ int CLuaEngineDefs::EngineLoadTXD ( lua_State* luaVM )
278
279
return 1 ;
279
280
}
280
281
282
+ int CLuaEngineDefs::EngineLoadIFP ( lua_State* luaVM )
283
+ {
284
+ SString strFile = " " ;
285
+ bool bFilteringEnabled = true ;
286
+ CScriptArgReader argStream ( luaVM );
287
+ // Grab the TXD filename or data
288
+ argStream.ReadString ( strFile );
289
+ if ( argStream.NextIsBool () ) // Some scripts have a number here (in error)
290
+ argStream.ReadBool ( bFilteringEnabled, true );
291
+
292
+ if ( !argStream.HasErrors ( ) )
293
+ {
294
+ // Grab our virtual machine and grab our resource from that.
295
+ CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
296
+ if ( pLuaMain )
297
+ {
298
+ // Grab this resource
299
+ CResource* pResource = pLuaMain->GetResource ();
300
+ if ( pResource )
301
+ {
302
+ SString strPath;
303
+ // Is this a legal filepath?
304
+ if ( CResourceManager::ParseResourcePathInput ( strFile, pResource, &strPath ) )
305
+ {
306
+ // Grab the resource root entity
307
+ CClientEntity* pRoot = pResource->GetResourceTXDRoot ();
308
+
309
+ // Create a IFP element
310
+ CClientIFP* pIFP = new CClientIFP ( m_pManager, INVALID_ELEMENT_ID );
311
+
312
+ // Try to load the IFP file
313
+ if ( pIFP->LoadIFP ( strPath ) )
314
+ {
315
+ // Success loading the file. Set parent to IFP root
316
+ pIFP->SetParent ( pRoot );
317
+
318
+ // Return the IFP element
319
+ lua_pushelement ( luaVM, pIFP );
320
+ return 1 ;
321
+ }
322
+ else
323
+ {
324
+ // Delete it again
325
+ delete pIFP;
326
+ argStream.SetCustomError ( strFile, " Error loading IFP" );
327
+ }
328
+ }
329
+ else
330
+ argStream.SetCustomError ( strFile, " Bad file path" );
331
+ }
332
+ }
333
+ }
334
+ if ( argStream.HasErrors () )
335
+ m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
336
+
337
+ // We failed
338
+ lua_pushboolean ( luaVM, false );
339
+ return 1 ;
340
+ }
281
341
282
342
int CLuaEngineDefs::EngineReplaceCOL ( lua_State* luaVM )
283
343
{
0 commit comments