Advertisement
Terrah

nwnx_dynres

Sep 13th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 6.84 KB | None | 0 0
  1. //void main(){}
  2.  
  3. const string MEM = "                                                                                                                                                                                                                                                                   ";
  4.  
  5. //Adds a file to the dynamic loader
  6. //sFile: must be resref+extension IE: "creature.utc"
  7. //sFullPath: must be the path to a full file IE: "C:/nwn/stuff/creature.utc"
  8. int DYNRES_AddFile( string sFile, string sFullPath );
  9.  
  10. //Removes a file to the dynamic loader
  11. //sFile: resref+extension IE: "creature.utc"
  12. int DYNRES_RemoveFile( string sFile );
  13.  
  14. //Returns the full file the loeader will load when sFile is requested
  15. //sFile: resref+extension IE: "creature.utc"
  16. string DYNRES_GetFullFile( string sFile );
  17.  
  18. //Get first file in the loader list
  19. //!!Spawning resources or using other DYNRES functions will reset the first/next loop!!
  20. string DYNRES_GetFirst( );
  21.  
  22. //Get the next file in the loader list
  23. //!!Spawning resources or using other DYNRES functions will reset the first/next loop!!
  24. string DYNRES_GetNext( );
  25.  
  26. //Returns true if the file exists, must be a full file path with extension
  27. int DYNRES_FileExist( string sFullFile );
  28.  
  29. //This will get the first or next area in the list, only returns area resrefs
  30. //nFirst must be true to reset the list
  31. //returns empty string on error or end of list
  32. string DYNRES_GetFirstNextArea( int nFirst );
  33.  
  34. //Returns the capsule filter, the filter is a list delmited by dots of extensions
  35. string DYNRES_GetFilter( );
  36.  
  37. //Sets a new filter, this has to be a list delmited by dots
  38. //Must start with a dot
  39. //IE: ".ncs.txt.exe.utc.mod.etc.etc.etc"
  40. void DYNRES_SetFilter( string sNewFilter );
  41.  
  42. //Caches a file, the file must be in the register
  43. //sFile: resref+extension IE: "creature.utc"
  44. //Returns true if the file was successfully cached
  45. int DYNRES_CacheFile( string sFile );
  46.  
  47. //Creates sFile, sFile should be a complete path
  48. //sFile will be overwritten if it exsists
  49. //If an extension is provided it'll be overwritten with the object typing
  50. //IE: If a file is specified as "C:/test.txt" for a creature the
  51. //file will be changed to "C:/text.utc"
  52. //This only works on creatures and items
  53. //This function returns the size of the new file in bytes or 0 if it failed
  54. //use DYNRES_LastFile to return the name of the file that was written
  55. int DYNRES_SaveObjectToFile( string sFile, object oObject );
  56.  
  57. //This will return the last file that DYNRES handled
  58. string DYNRES_LastFile( );
  59.  
  60. //Returns the first file inside sCapsule
  61. //sCapsule must be a complete path
  62. //Returns an empty string is none is found
  63. string DYNRES_GetFirstFileInCapsule( string sCapsule );
  64.  
  65. //Get the next file in the capsule defined by DYNRES_GetFirstFileInCapsule
  66. //Returns empty string if no more or invalid
  67. string DYNRES_GetNextFileInCapsule( );
  68.  
  69. //Locates sFile in sCapsule and writes it to sNewFile
  70. //sCapsule and sNewFile must be complete with filepath
  71. //If sNewFile exists it'll be overwritten
  72. //Returns true/false
  73. int DYNRES_ExtractFromCapsule( string sFile, string sCapsule, string sNewFile );
  74.  
  75. int DYNRES_ExtractFromCapsule( string sFile, string sCapsule, string sNewFile ){
  76.  
  77.     SetLocalString( OBJECT_SELF, "NWNX!DYNRES!EXT", sFile+"|"+sCapsule+"|"+sNewFile );
  78.     string nRet = GetLocalString( OBJECT_SELF, "NWNX!DYNRES!EXT" );
  79.     DeleteLocalString( OBJECT_SELF, "NWNX!DYNRES!EXT" );
  80.     return StringToInt( nRet );
  81. }
  82.  
  83. string DYNRES_GetNextFileInCapsule( ){
  84.  
  85.     SetLocalString( OBJECT_SELF, "NWNX!DYNRES!EFN", MEM );
  86.     string nRet = GetLocalString( OBJECT_SELF, "NWNX!DYNRES!EFN" );
  87.     DeleteLocalString( OBJECT_SELF, "NWNX!DYNRES!EFN" );
  88.     return nRet;
  89. }
  90.  
  91. string DYNRES_GetFirstFileInCapsule( string sCapsule ){
  92.  
  93.     SetLocalString( OBJECT_SELF, "NWNX!DYNRES!EFF", sCapsule );
  94.     string nRet = GetLocalString( OBJECT_SELF, "NWNX!DYNRES!EFF" );
  95.     DeleteLocalString( OBJECT_SELF, "NWNX!DYNRES!EFF" );
  96.     return nRet;
  97. }
  98.  
  99. string DYNRES_LastFile( ){
  100.  
  101.     SetLocalString( OBJECT_SELF, "NWNX!DYNRES!LST", MEM );
  102.     string nRet = GetLocalString( OBJECT_SELF, "NWNX!DYNRES!LST" );
  103.     DeleteLocalString( OBJECT_SELF, "NWNX!DYNRES!LST" );
  104.     return nRet;
  105. }
  106.  
  107. int DYNRES_SaveObjectToFile( string sFile, object oObject ){
  108.  
  109.     return StoreCampaignObject( "DYNRES", sFile+"|                               ", oObject );
  110. }
  111.  
  112. int DYNRES_CacheFile( string sFile ){
  113.  
  114.     SetLocalString( OBJECT_SELF, "NWNX!DYNRES!CAC", sFile );
  115.     int nRet = StringToInt( GetLocalString( OBJECT_SELF, "NWNX!DYNRES!CAC" ) );
  116.     DeleteLocalString( OBJECT_SELF, "NWNX!DYNRES!CAC" );
  117.     return nRet;
  118. }
  119.  
  120. void DYNRES_SetFilter( string sNewFilter ){
  121.     SetLocalString( OBJECT_SELF, "NWNX!DYNRES!FIL", sNewFilter );
  122.     DeleteLocalString( OBJECT_SELF, "NWNX!DYNRES!FIL" );
  123. }
  124.  
  125. string DYNRES_GetFilter( ){
  126.  
  127.     SetLocalString( OBJECT_SELF, "NWNX!DYNRES!GIL", MEM );
  128.     string nRet = GetLocalString( OBJECT_SELF, "NWNX!DYNRES!GIL" );
  129.     DeleteLocalString( OBJECT_SELF, "NWNX!DYNRES!GIL" );
  130.     return nRet;
  131. }
  132.  
  133. string DYNRES_GetFirstNextArea( int nFirst ){
  134.  
  135.     SetLocalString( OBJECT_SELF, "NWNX!DYNRES!ARE", IntToString(nFirst)+"                              " );
  136.     string nRet = GetLocalString( OBJECT_SELF, "NWNX!DYNRES!ARE" );
  137.     DeleteLocalString( OBJECT_SELF, "NWNX!DYNRES!ARE" );
  138.     return nRet;
  139. }
  140.  
  141. int DYNRES_FileExist( string sFullFile ){
  142.  
  143.     SetLocalString( OBJECT_SELF, "NWNX!DYNRES!EXI", sFullFile );
  144.     int nRet = StringToInt( GetLocalString( OBJECT_SELF, "NWNX!DYNRES!EXI" ) );
  145.     DeleteLocalString( OBJECT_SELF, "NWNX!DYNRES!EXI" );
  146.     return nRet;
  147. }
  148.  
  149. int DYNRES_AddFile( string sFile, string sFullPath ){
  150.  
  151.     SetLocalString( OBJECT_SELF, "NWNX!DYNRES!ADD", sFile+"|"+sFullPath );
  152.     int nRet = StringToInt( GetLocalString( OBJECT_SELF, "NWNX!DYNRES!ADD" ) );
  153.     DeleteLocalString( OBJECT_SELF, "NWNX!DYNRES!ADD" );
  154.     return nRet;
  155. }
  156.  
  157. int DYNRES_RemoveFile( string sFile ){
  158.  
  159.     SetLocalString( OBJECT_SELF, "NWNX!DYNRES!REM", sFile );
  160.     int nRet = StringToInt( GetLocalString( OBJECT_SELF, "NWNX!DYNRES!REM" ) );
  161.     DeleteLocalString( OBJECT_SELF, "NWNX!DYNRES!REM" );
  162.     return nRet;
  163. }
  164.  
  165. string DYNRES_GetFullFile( string sFile ){
  166.  
  167.     SetLocalString( OBJECT_SELF, "NWNX!DYNRES!GET", sFile+MEM );
  168.     string nRet = GetLocalString( OBJECT_SELF, "NWNX!DYNRES!GET" );
  169.     DeleteLocalString( OBJECT_SELF, "NWNX!DYNRES!GET" );
  170.     return nRet;
  171. }
  172.  
  173. string DYNRES_GetFirst( ){
  174.  
  175.     SetLocalString( OBJECT_SELF, "NWNX!DYNRES!FST", MEM );
  176.     string nRet = GetLocalString( OBJECT_SELF, "NWNX!DYNRES!FST" );
  177.     DeleteLocalString( OBJECT_SELF, "NWNX!DYNRES!FST" );
  178.     return nRet;
  179. }
  180.  
  181. string DYNRES_GetNext( ){
  182.  
  183.     SetLocalString( OBJECT_SELF, "NWNX!DYNRES!NXT", MEM );
  184.     string nRet = GetLocalString( OBJECT_SELF, "NWNX!DYNRES!NXT" );
  185.     DeleteLocalString( OBJECT_SELF, "NWNX!DYNRES!NXT" );
  186.     return nRet;
  187. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement