View Single Post
  #1  
Old 12-18-2007, 11:05 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Level Copy // No scripts

Description:
Copys levels from one folder in to another folder, without the scripts! It's magic


How-to:
this.structure = "levels/levels/overworld/";
The current folder that the levels are in

this.newfolder = "levels/newLevels";
The new folder that the levels will be placed in

Code: [Place as a Database NPC]
PHP Code:
function onCreated() {
  
this.structure "levels/levels/overworld/";
  
temp.folder.loadfolder(this.structure "*"0);
  
this.newfolder "levels/newLevels";
  
  
this.onScan(temp.folder);
}

function 
onScan(folder) {  
  for (
temp.0temp.999temp.g++) {
    if (
temp.temp.folder.size()) {
      break;
    }
    
    
temp.data.loadlines(this.structure temp.folder[temp.g]);
    
    
temp.newfile = new[temp.data.size()];
    
temp.0;

    for (
temp.itemp.data) {     
      if (
temp.i.starts("LIN") || temp.i.starts("BOAR") || temp.i.starts("GLEVN")) {
        
temp.newfile[temp.c] = temp.i;
        
temp.c++;
      }
    }

    for (
temp.temp.ctemp.temp.newfile.size(); temp.i++) {
      
temp.newfile[temp.i] = null;
    }

    
temp.newfile.savelines(this.newfolder temp.folder[temp.g], 0);
    echo(
"Saved:" SPC temp.folder[temp.g]);
    
    
temp.folder.delete(temp.g);
  }
  
  if (
temp.folder.size() > 0) {
    
scheduleevent(1"Scan", {temp.folder});
  } else {
    echo(
"Finished copying levels!");
  }

Oh, and don't forget to give the NPC server rights to each folder!
__________________
Reply With Quote