Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Level copy (https://forums.graalonline.com/forums/showthread.php?t=71587)

Chandler 01-20-2007 10:52 PM

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 :)

Gambet 01-21-2007 02:15 AM

You do know there is a built-in copylevel command right?

x-x

Rapidwolve 01-21-2007 02:47 AM

Quote:

Originally Posted by Gambet (Post 1266941)
You do know there is a built-in copylevel command right?

x-x

*****

zaboomafoo.

Riot 01-21-2007 03:01 AM

Quote:

Originally Posted by Gambet (Post 1266941)
You do know there is a built-in copylevel command right?

x-x

But does copylevel change the links to match those of the new filenames and do a mass amount of levels?

Inverness 01-21-2007 03:46 AM

I don't know about automated link-changing. But if that is the case simply make the links scripted ones. Use this.level or level.name to get that and fine the ID of the instance from that and have the warp function executed appropriately. Or you could use database communication.

Gambet 01-21-2007 04:38 AM

Quote:

Originally Posted by Riot (Post 1266966)
But does copylevel change the links to match those of the new filenames and do a mass amount of levels?


It makes a copy of the level, and creates it in a new folder. I've never used it, but I'd assume that it would copy everything in the level, or at least the important stuff.

Admins 01-21-2007 05:53 AM

The built-in command copies the file, but is not modifying levels. The built-in command currently has the advantage that the gserver is directly seeing the file, while with the scripted version you need to do /refreshfilelist, although that could be changed.

Chandler 01-21-2007 11:52 AM

Quote:

Originally Posted by Gambet (Post 1266941)
You do know there is a built-in copylevel command right?

x-x

Doesn't edit the links. Feel free to try it.


All times are GMT +2. The time now is 06:07 PM.

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