Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Copylevel (https://forums.graalonline.com/forums/showthread.php?t=73536)

Chandler 04-17-2007 08:53 PM

Copylevel
 
1 Attachment(s)
Doesn't seem to work... the folder exists, with a file already in the folder.

Here's the code: (Database)


HTML Code:

public function copyLevel(origionalName, newName)
{
  temp.levelChecks = {{temp.origionalName, ""}, {temp.newName, true}};
  for (temp.currentLevel: temp.levelChecks)
  {
    if (findlevel(temp.currentLevel[0]) == temp.currentLevel[1])
    {
      temp.alreadyExists = true;
      break;
    }
  }
  if (temp.alreadyExists)
  {
    return false;
  }
  temp.filePath = "levels/world/sanddungeon/";
  copylevel(temp.filePath @ temp.origionalName, temp.filePath @ temp.newName);
 
  echo("CREATED NEW LEVEL!");
}
function onCreated()
{
  this.copyLevel("v_cavelevel.nw", "v_cavelevels.nw");
}

The error that it produces: (via NC)

HTML Code:

The script of NPC Control_LevelGenerator has been updated by Chandler
GraalScript: Loop limit exceeded at line 4 in script of Control_LevelGenerator

Anyone know of why?

Here's the FTP

zokemon 04-17-2007 09:02 PM

because you are reusing the same function over and over again o_o
You redefined the copylevel function therefor you shouldn't be calling it inside of itself.

Chandler 04-17-2007 09:06 PM

Oh duh, I made my own function and one already exists. Thanks! :p

zokemon 04-17-2007 09:23 PM

No problem ;)
It is reasons like that that I almost always head my functions with either on, do, gui or fn
Depending on the purpose of the function of course.

(In your case I would probably call it doCopyLevel())

Chandler 04-17-2007 09:48 PM

Quote:

Originally Posted by zokemon (Post 1300724)
No problem ;)
It is reasons like that that I almost always head my functions with either on, do, gui or fn
Depending on the purpose of the function of course.

(In your case I would probably call it doCopyLevel())

Yeah.
It's weird, I thought there was some error with copy level. I do things like this all of the time :[
Thank you


All times are GMT +2. The time now is 04:15 AM.

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