Restore/Remove all Walkable Areas in one shot

Started by ProcioneSx, Sun 20/10/2013 22:33:47

Previous topic - Next topic

ProcioneSx

Hi guys,
I wrote a function to restore all walkable areas in a room.
The function is:

Code: ags

function restoreAllWalkableAreas(){
    int i = 1;
    while(i <= 15){
        RestoreWalkableArea(i);
    }
    i++;
}


Unfortunately when I run this function AGS crashes.
The strange thing is that it works if I write it like this:

Code: ags

function restoreAllWalkableAreas(){
    RestoreWalkableArea(1);
    RestoreWalkableArea(2);
    RestoreWalkableArea(3);
    RestoreWalkableArea(4);
    RestoreWalkableArea(5);
    RestoreWalkableArea(6);
    RestoreWalkableArea(7);
    RestoreWalkableArea(8);
    RestoreWalkableArea(9);
    RestoreWalkableArea(10);
    RestoreWalkableArea(11);
    RestoreWalkableArea(12);
    RestoreWalkableArea(13);
    RestoreWalkableArea(14);
    RestoreWalkableArea(15);
  }


But written this way is too tidy.
The problem is: why it crashes if written in the first way?
Thanks

ProcioneSx

Excuse me guys, mine was a stupid mistake, I simply wrote the while cycle in a wrong way...
I put the increment out of the curly brackets. :-[

TMuh

Quote from: ProcioneSx on Sun 20/10/2013 22:53:36
Excuse me guys, mine was a stupid mistake, I simply wrote the while cycle in a wrong way...
I put the increment out of the curly brackets. :-[

It happens :)

monkey0506

Glad you got it sorted. Just FYI though, in cases like this, the actual crash reports are useful. Even if you couldn't make any sense of why it said the game had hung after 150001 loops being run (which would be the error in this case, of course), telling us what the error was is sometimes critical in understanding what went wrong.

You can copy error messages when they appear by pressing Ctrl+C to copy it to the Clipboard. If you then post it into Notepad you can make sure you don't lose it while you bring up the forums and type out your post (accidentally copying something, overwriting the Clipboard happens to the best of us!). You can then put it in-between [quote] and [/quote] tags.

This is an important step when posting these issues, because it helps us track down what happened. ;)

ProcioneSx

Thanks for the tips, I'll remember that for the next times ;) When I got the error was night, I was a bit dazed... not the best time to code :P

SMF spam blocked by CleanTalk