Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-20-2007, 10:52 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Level copy

HTML Code:
function onCreated()
{
  this.searchid = 0;
  scheduleevent(0.25, "renameFiles", NULL, NULL);
}
function onrenameFiles() 
{ 
  temp.folderName = "levels/vs/currentworld/*.nw";
  temp.copyFolder = "levels/newleveltest/";
  temp.newName = "world2";
  temp.oldName = "illuminati2";  
  temp.levelList.loadfolder(temp.folderName, 0);
   
  if ((this.searchid * 50) >= temp.levelList.size()) 
  {   
    echo("All finished...");
    return true;
  }
  
  for (temp.s = (this.searchid * 50); temp.s < ((this.searchid + 1) * 50); temp.s++) 
  {    
      
    temp.curLinec = 0;
    temp.curLevel = temp.levelList[temp.s];
    if (!temp.curLevel.starts(temp.oldName))
    {
      continue;
    }
    temp.levelDetails.loadlines(temp.folderName.substring(0, (temp.folderName.length() - 4)) @ temp.curLevel);     
    for (temp.curLine: temp.levelDetails)
    {
      if (temp.curLine.starts("LINK " @ temp.oldName))
      {
        temp.newLine = "LINK" SPC temp.newName @ temp.curLine.substring(5 + temp.oldName.length());
        temp.levelDetails[temp.curLinec] = temp.newLine;
      }
      temp.curLinec++;
    }
    temp.levelName = temp.newName @ temp.curLevel.substring(temp.oldName.length());
    temp.levelDetails.savelines(temp.copyFolder @ temp.levelName, 0); 
    echo("NC: Copied" SPC temp.curLevel SPC "to" SPC temp.levelName);
  }
  
  this.searchid++; 
  scheduleevent(0.25, "renameFiles", NULL, NULL); 
}
Appreciation goes for Yen, for creating a way to stop the annoying loop error. Here's a level copy script, basically you just re-name the four main things
HTML Code:
  temp.folderName = "levels/vs/currentworld/*.nw"; //Folders to where they are
  temp.copyFolder = "levels/newleveltest/"; //New folder name
  temp.newName = "world2"; //New level names
  temp.oldName = "illuminati2"; //Old level names 
It'll then copy all of the scripts, and also links and paste the levels in the new folder location
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:43 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.