;

PDA

Click to See Complete Forum and Search --> : Failure to Run


NidoKing
04-03-2008, 11:38 AM
I am writing a RPG battle program in Flash. I haven't gotten very far but I am stuck on part. Each time I test the program, I get this error:

Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
at Battle_fla::MainTimeline/Battle_fla::frame1()

The code looks like this:
var hp1:int = 100;
var hp2:int = 75;
var hpdr:int = 500;
var hpgi:int = 200;
var attack1:int = 15;
var attack2:int = 5;
var attackdr:int = 30;
var attackgi:int = 20;
var defence1:int = 10;
var defence2:int = 5;
var defencedr:int = 20;
var defencegi:int = 10;
var magic1:int = 5;
var magic2:int = 15;
var magicdr:int = 20;
var magicgi:int = 0;
var spirit1:int = 5;
var spirit2:int = 10;
var spiritdr:int = 15;
var spiritgi:int = 5;*/
var spd1:int = 5;
var spd2:int = 10;
var spddr:int = 2;
var spdgi:int = 4;
var mp1:int = 15;
var mp2:int = 50;
var mpdr:int = 30;
var mpgi:int = 0;*/
var monster:int = 2;
var time1:int = 0
var time2:int = 0
var timedr:int = 0
var timegi:int = 0

if (monster == 1) {
Dragon.x = 280
Dragon.y = 80
}
else if (monster == 2) {
Giant.x = 280
Giant.y = 80
}
while (hp1 >= 1 || hp2 >= 1)
{
time1 +spd1
time2 +spd2
timedr +spddr
timegi +spdgi

while (time1 >= 100) {
var mag:int = 0;
if (mag == 0) {
Atk.x = 10
Atk.y = 5
mag++
}
time1 = 0
}
hp1 = 0
}


Is it failing because of the insane number of variables? Because of the while loops? In any event assistence would be quite welcome.

cancerinform
04-03-2008, 11:56 AM
You can test that by deleting certain parts of the script.

neznein9
04-03-2008, 12:01 PM
Your immediate problem...in your while loop you are waiting for both of your hp values to drop below 1, but you never change the value of hp2, it remains at 75 forever.

On a grander scale, that type of programming is going to get really messy really fast. Try using Objects for each of your monsters and attaching all those attributes as object properties. Then tuck each monster object into an array so you can automatically keep a count of how many mobs are in play. The goal should be writing code that can be used more flexibly and can be repeated for different circumstances.

NidoKing
04-03-2008, 12:05 PM
I tested it, and it has something to do with the main while loop. I am just unsure what.

neznein9
04-03-2008, 12:47 PM
in your while loop you are waiting for both of your hp values to drop below 1, but you never change the value of hp2, it remains at 75 forever.

NidoKing
04-04-2008, 11:26 AM
The original idea of the while loop was that it would loop, increasing time counters until it was someones turn. Once it was there turn, you would have a button based menu that let you pick your attacks and spells and stuff. Once your turn was over it would go back and loop until it was another person's turn.
It probably is a fairly inefficient system but it's the best I have been able to come up with. I am quite unfamiliar with action script and this is only my third project using it. Could you please explain what an object is, and how to assign values to them. Any help you could give me with the code would be most helpful. Thank you for the information you have already provided, but I don't really know any other way of doing it.