Please help me find the bug for MAGS game fast :(

Started by Icey, Mon 31/12/2012 09:27:06

Previous topic - Next topic

Icey

I've encountered a serious error. It's not so serious but I need to solve it fast so if you figure it out then post it here or email me @ isiahsweeting@gmail.com

So this sorta just came out of no where and 4am and I can't really see the problem cause I tired but I don't think I really did it. It could just be AGS, butI really hope it's fixable.

So when I press a GUI button the menu is supposed to fade out and the battle sequence plays. problem is, after the troll attacks the game just stops reading the script. Now if the player has lost all HP from the attack then the death sequence will play but it will stop fine.

I need the function to follow through all the way to the bottom and not just finish reading at line 2208

Code: AGS
function Button16_OnClick(GUIControl *control, MouseButton button)
{
  Troll.Baseline = 5;
  mouse.Visible = false;
//gGui3.TweenTransparency(0.5, 100, eLinearTween, eBlockTween);
Davex = Dave.x;
DaveY = Dave.y;
Dave.SetWalkSpeed(10, 10);
Dave.Walk(102, 164, eBlock, eAnywhere);
Dave.ChangeView(35);
Dave.Animate(1, 5, eOnce, eBlock);
Dave.x = Davex;
Dave.y = DaveY;
damage.Text = String.Format("%d",DaveATK);



   gGui4.Visible = false;
   gGui4.Transparency = 100;
   gGui4.SetPosition(61, 106);
   gGui4.Visible = true;
   gGui4.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
   gGui4.TweenPosition(0.8, 61, 81, eEaseOutTween, eBlockTween);
      gGui4.Visible = false;


trolllordHP -= DaveATK;
Dave.ChangeView(40);
/// DAWN

DisplayAt(115, 10, 200, "Pyraga");

Dawn.ChangeView(8);
Dawn.Animate(1, 5, eOnce, eBlock);
object[9].TweenTransparency(0.4, 50, eLinearTween, eBlockTween);

object[14].Visible = true; 
object[14].SetView(41);
object[14].Animate(0, 4, eOnce, eBlock);
object[14].Visible = false;
Dawn.ChangeView(7);


DawnMGK += fire;

damage.Text = String.Format("%d",DawnMGK);


   gGui4.Visible = false;
   gGui4.Transparency = 100;
   gGui4.SetPosition(61, 106);
   gGui4.Visible = true;
   gGui4.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
   gGui4.TweenPosition(0.8, 61, 81, eEaseOutTween, eBlockTween);
      gGui4.Visible = false;


trolllordHP -= DawnMGK;
DawnMGK -= fire;
object[9].TweenTransparency(0.4, 100, eLinearTween, eNoBlockTween);
PlayerMP -= 18;


//
if(trolllordHP <= 0){
  Troll.SayAt(8, 167, 320,"No, this can not be!");
  Troll.SayAt(8, 167, 320,"I've come so far! I've done so much!");
  Troll.SayAt(8, 167, 320,"I can't fail my master now...");
  Troll.SayAt(8, 167, 320,"Fools! take this.");
  Troll.ChangeView(42);
Troll.Animate(2, 5, eOnce, eBlock);

object[15].Visible = true;
object[15].TweenTransparency(0.3, 100, eLinearTween, eBlockTween);
object[9].TweenTransparency(0.4, 50, eLinearTween, eBlockTween);
object[6].Visible = true;  
object[6].Transparency = 0;
object[6].SetView(5);
object[6].Animate(0, 5, eOnce, eBlock);
Dawn.ChangeView(44);
Dave.ChangeView(13);
object[6].Visible = false;
Troll.ChangeView(42);
  object[9].TweenTransparency(0.4, 100, eLinearTween, eNoBlockTween);
  Dawn.SayAt(8, 167, 320,"He's...getting stronger, at this rate we-");
  Dave.SayAt(8, 167, 320,"No! don't say it, remember what you said.");
  Dave.SayAt(8, 167, 320,"We gott keep thinking positive, we believe there's a chance.");
  Dave.SayAt(8, 167, 320,"We take what he gives us and we send it back 1000 times stronger!");
  
  Troll.SayAt(8, 167, 320,"You fools...now your time here is over!");
  Troll.SayAt(8, 167, 320,"I call to the, comet of the dying star!");
  
  Dave.ChangeView(43);
  
  Dawn.SayAt(8, 167, 320,"Dave what are you doing! you must flee at once!");
  Dave.SayAt(8, 167, 320,"Like hell I am! we're in this together!");
  Dave.SayAt(8, 167, 320,"My quest is to save the world, and that means protecting you.");
  Dawn.SayAt(8, 167, 320,"But why Dave, why put yourself in harms way?");
  Dave.SayAt(8, 167, 320,"Cause your my friend!");
  Troll.Animate(2, 5, eOnce, eBlock);

object[15].Visible = true;
object[15].TweenTransparency(0.3, 100, eLinearTween, eBlockTween);
object[9].TweenTransparency(0.4, 50, eLinearTween, eBlockTween);
object[11].Visible = true;  
  object[11].TweenPosition(1.10, 172, 137, eEaseInTween, eBlockTween);
  
  
  FadeOut(1);
  Dave.ChangeRoom(20, 0, 0);
}

else if(trolllordHP >= 1){
if(Game.DoOnceOnly("first strike")){
  Troll.SayAt(8, 167, 320,"A splendid combo!");
  Troll.SayAt(8, 167, 320,"But alas, your still no match.");
  Troll.SayAt(8, 167, 320,"Now, stagger with PAIN!");
  
}
if(ATK2trol >= 5){
  DisplayAt(115, 10, 200, "Graviga");
  
  if(Game.DoOnceOnly("666")){
  Troll.SayAt(8, 167, 320,"I control your fate!");
  Troll.SayAt(8, 167, 320,"Now DIE");
}
  ATK2trol -= 5;
Troll.ChangeView(42);
Troll.Animate(2, 5, eOnce, eBlock);

object[15].Visible = true;
object[15].TweenTransparency(0.3, 100, eLinearTween, eBlockTween);
object[9].TweenTransparency(0.4, 50, eLinearTween, eBlockTween);
object[6].Visible = true;  
object[6].Transparency = 0;
object[6].SetView(5);
object[6].Animate(0, 5, eOnce, eBlock);
object[6].Visible = false;
Troll.ChangeView(42);

damage.Text = String.Format("%d",Gravity);


   gGui4.Visible = false;
   gGui4.Transparency = 100;
   gGui4.SetPosition(254, 116);
   gGui4.Visible = true;
   gGui4.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
   gGui4.TweenPosition(0.8, 254, 86, eEaseOutTween, eBlockTween);
      gGui4.Visible = false;


PlayerHP -= Gravity;

object[9].TweenTransparency(0.4, 100, eLinearTween, eNoBlockTween);
  
  return;
}
else if(ATK2trol <= 4){
    DisplayAt(115, 10, 200, "Darkra");
 ATK2trol += 1;
Troll.ChangeView(42);
Troll.Animate(2, 5, eOnce, eBlock);

object[15].Visible = true;
object[15].TweenTransparency(0.3, 100, eLinearTween, eBlockTween);
object[9].TweenTransparency(0.4, 50, eLinearTween, eBlockTween);
object[16].SetPosition(-40, 1);
object[16].TweenPosition(1.9, 318, 284, eEaseOutTween, eBlockTween);
Troll.ChangeView(42);

damage.Text = String.Format("%d",Darkra);


   gGui4.Visible = false;
   gGui4.Transparency = 100;
   gGui4.SetPosition(254, 116);
   gGui4.Visible = true;
   gGui4.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
   gGui4.TweenPosition(0.8, 254, 86, eEaseOutTween, eBlockTween);
      gGui4.Visible = false;


PlayerHP -= Darkra;

object[9].TweenTransparency(0.4, 100, eLinearTween, eNoBlockTween);
 return;

}



} 

if(PlayerHP <= 0){
  Dawn.ChangeView(44);
Dave.ChangeView(13);
  
  Dave.SayAt(8, 167, 320,"Could this, really be it?");
  BBlack.Transparency = 100;
  BBlack.Visible = true;
  BBlack.TweenTransparency(0.9, 0, eLinearTween, eBlockTween);
  SetFadeColor(0, 0, 0);
  RestartGame();
  
  
}
//it keeps stoping here

if(Button15.Width == 1){
  Button15.Width = 5;
  return;
}
else if(Button15.Width == 5){
  Button15.Width = 10;
 return;
}
else if(Button15.Width == 10){
  Button15.Width = 15;
  return;
}
else if(Button15.Width == 15){
  Button15.Width = 20;
  return;
}
else if(Button15.Width == 20){
  Button15.Width = 25;
  return;
}
else if(Button15.Width == 25){
  Button15.Width = 30;
  return;
}
else if(Button15.Width == 30){
  Button15.Width = 35;
  return;
}
else if(Button15.Width == 35){
  Button15.Width = 40;
  return;
}
else if(Button15.Width == 40){
  Button15.Width = 45;
  return;
}
else if(Button15.Width == 45){
  Button15.Width = 50;
  return;
}
else if(Button15.Width == 50){
  Button15.Width = 55;
  return;
}
else if(Button15.Width == 55){
  Button15.Width = 60;
  return;
}
else if(Button15.Width == 60){
  Button15.Width = 65;
  return;
}
else if(Button15.Width == 65){
  Button15.Width = 70;
  return;
}
else if(Button15.Width == 70){
  Button15.Width = 75;
  return;
}
else if(Button15.Width == 75){
  Button15.Width = 78;
    if(Game.DoOnceOnly("Assault")){
  Dawn.SayAt(8, 167, 320,"Dave, now is our chance!");
  Dave.SayAt(8, 167, 320,"Let's show him what light can really do!");
}
Button17.Visible = true;
  return;
}










gGui3.Visible = true;
gGui3.TweenTransparency(0.5, 0, eLinearTween, eBlockTween);
mouse.Visible = true;


}

geork

As far as I can see, it's because you're calling return when changing the button width, which terminates the function at that point.
Code: AGS
if(Button15.Width == 1){
  Button15.Width = 5;
  return; //EG here!
}

You also have instances of calling return before this (lines 2159 and 2187), although I guess they don't execute when you tested it.

Hope that helps!

Khris

Also, 13 separate else ifs for what is essentially
Code: ags
	else if(Button15.Width >= 5 && Button15.Width. <= 70){
		Button15.Width += 5;
		return;
	}


Are you still this code-tarded?

And you're still blaming AGS for your own logic errors, claiming it'll exit a function without any prompt to do so...? WTF is wrong with you.

Icey

It's cool I figured it out when I woke up.

Also Khris, I've been trying to figure that out all year but no one really knew how to do it so you can't blame me there. I didn't know there was a way to check for a  value in between. And try to keep in mind that I was up to 4 working on this and the error came out of know where, I thought it was something else wrong I did but it wasn't. Also let's not make it seem AGS is so perfect cause there's been times I've got errors but AGS didn't notice them. You may not understand or not even believe me but it's cool, you are entitled to your own opinion ;)


In conclusion, thank you geork and Khris :)

Khris

Look, you don't even need a check for the value being in between. You add 5 to the global variable you're supposed to use, clamp it to the allowed range, then assign its value to the button's width. This is all there is, it's really easy, and you already know how to do it, at least in theory.
Your problem is that you're unable to apply solution A to problem B. It's called "transfer of learning" and it's an essential skill for programming. Yet you continue to display a complete lack of it. (Which is and has always been the main source of my frustration with your threads. Because they only ever solve the problem at hand, but will never prevent you from making the same error the next time around.)

You're trying to build an elaborate machine, yet you keep using a hammer for everything, whether it's screws, nuts or bolts.
And every time the entire thing blows up in your face, you'll blame the hammer, the toolbox, or -and this is where it just got ridiculous and insulting- the guys who taught you how to use the hammer. It's never your own fault of course.
And the fact that you actually expect AGS to detect game logic errors, as opposed to typos or misplaced braces, is baffling.

I really don't understand why you keep doing this. It's clear that you're no good at it and never will be.

Also, if you figured out the problem right when you woke up, why did you open this thread right before going to sleep? Why not wait until morning and try again?
No, you just went ahead and dumped this steaming piece of code on us. Let them work it out while I sleep.

In conclusion, thank you for another episode of how not to do it with a vengeance.

TheBitPriest

Icey,

Whoa!  Pass the parmesan cheese, dude!   :smiley:

I'm not totally sure what you were trying to do, but since I was procrastinating this afternoon, I reformatted your code a little bit.   I had to do this in order to read it.   :-\  I think your problem was in the tautology.

You say that it's working now.  Great!  Maybe this reformatting can give you a few ideas for the future... Of course, there's more work to be done in making this code concise and readable.  I just spent a few minutes on it.

BP

Code: AGS
//
//  __attack_graviga()
//
function __attack_graviga()
{
   DisplayAt(115, 10, 200, "Graviga");

   if(Game.DoOnceOnly("666"))
   {
     Troll.SayAt(8, 167, 320,"I control your fate!");
     Troll.SayAt(8, 167, 320,"Now DIE");
   }

   ATK2trol -= 5;
   Troll.ChangeView(42);
   Troll.Animate(2, 5, eOnce, eBlock);

   object[15].Visible = true;
   object[15].TweenTransparency(0.3, 100, eLinearTween, eBlockTween);
   object[9].TweenTransparency(0.4, 50, eLinearTween, eBlockTween);
   object[6].Visible = true;  
   object[6].Transparency = 0;
   object[6].SetView(5);
   object[6].Animate(0, 5, eOnce, eBlock);
   object[6].Visible = false;
   Troll.ChangeView(42);

   damage.Text = String.Format("%d",Gravity);

   gGui4.Visible = false;
   gGui4.Transparency = 100;
   gGui4.SetPosition(254, 116);
   gGui4.Visible = true;
   gGui4.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
   gGui4.TweenPosition(0.8, 254, 86, eEaseOutTween, eBlockTween);
   gGui4.Visible = false;

   PlayerHP -= Gravity;

   object[9].TweenTransparency(0.4, 100, eLinearTween, eNoBlockTween);

}

//
//  __attack_darkra()
//
function __attack_darkra()
{
   DisplayAt(115, 10, 200, "Darkra");
   
   ATK2trol += 1;
   Troll.ChangeView(42);
   Troll.Animate(2, 5, eOnce, eBlock);

   object[15].Visible = true;
   object[15].TweenTransparency(0.3, 100, eLinearTween, eBlockTween);
   object[9].TweenTransparency(0.4, 50, eLinearTween, eBlockTween);
   object[16].SetPosition(-40, 1);
   object[16].TweenPosition(1.9, 318, 284, eEaseOutTween, eBlockTween);
   Troll.ChangeView(42);

   damage.Text = String.Format("%d",Darkra);

   gGui4.Visible = false;
   gGui4.Transparency = 100;
   gGui4.SetPosition(254, 116);
   gGui4.Visible = true;
   gGui4.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
   gGui4.TweenPosition(0.8, 254, 86, eEaseOutTween, eBlockTween);
   gGui4.Visible = false;

   PlayerHP -= Darkra;

   object[9].TweenTransparency(0.4, 100, eLinearTween, eNoBlockTween);

}


//
//  __troll_lord_death()
//
function __troll_lord_death()
{
   Troll.SayAt(8, 167, 320,"No, this can not be!");
   Troll.SayAt(8, 167, 320,"I've come so far! I've done so much!");
   Troll.SayAt(8, 167, 320,"I can't fail my master now...");
   Troll.SayAt(8, 167, 320,"Fools! take this.");
   Troll.ChangeView(42);
   Troll.Animate(2, 5, eOnce, eBlock);

   object[15].Visible = true;
   object[15].TweenTransparency(0.3, 100, eLinearTween, eBlockTween);
   object[9].TweenTransparency(0.4, 50, eLinearTween, eBlockTween);
   object[6].Visible = true;  
   object[6].Transparency = 0;
   object[6].SetView(5);
   object[6].Animate(0, 5, eOnce, eBlock);
   Dawn.ChangeView(44);
   Dave.ChangeView(13);
   object[6].Visible = false;
   Troll.ChangeView(42);
   object[9].TweenTransparency(0.4, 100, eLinearTween, eNoBlockTween);
   Dawn.SayAt(8, 167, 320,"He's...getting stronger, at this rate we-");
   Dave.SayAt(8, 167, 320,"No! don't say it, remember what you said.");
   Dave.SayAt(8, 167, 320,"We gott keep thinking positive, we believe there's a chance.");
   Dave.SayAt(8, 167, 320,"We take what he gives us and we send it back 1000 times stronger!");

   Troll.SayAt(8, 167, 320,"You fools...now your time here is over!");
   Troll.SayAt(8, 167, 320,"I call to the, comet of the dying star!");

   Dave.ChangeView(43);

   Dawn.SayAt(8, 167, 320,"Dave what are you doing! you must flee at once!");
   Dave.SayAt(8, 167, 320,"Like hell I am! we're in this together!");
   Dave.SayAt(8, 167, 320,"My quest is to save the world, and that means protecting you.");
   Dawn.SayAt(8, 167, 320,"But why Dave, why put yourself in harms way?");
   Dave.SayAt(8, 167, 320,"Cause your my friend!");
   Troll.Animate(2, 5, eOnce, eBlock);

   object[15].Visible = true;
   object[15].TweenTransparency(0.3, 100, eLinearTween, eBlockTween);
   object[9].TweenTransparency(0.4, 50, eLinearTween, eBlockTween);
   object[11].Visible = true;  
   object[11].TweenPosition(1.10, 172, 137, eEaseInTween, eBlockTween);

   FadeOut(1);
   Dave.ChangeRoom(20, 0, 0); // leave room
}

//
//  __player_death()
//
fuction __player_death()
{
   Dawn.ChangeView(44);
   Dave.ChangeView(13);

   Dave.SayAt(8, 167, 320,"Could this, really be it?");
   BBlack.Transparency = 100;
   BBlack.Visible = true;
   BBlack.TweenTransparency(0.9, 0, eLinearTween, eBlockTween);
   SetFadeColor(0, 0, 0);
   RestartGame();  // restart game
}

//
//  __setup_dave()
//
function __setup_dave()
{
   //  Dave walks to the correct position
   Davex = Dave.x;
   DaveY = Dave.y;
   Dave.SetWalkSpeed(10, 10);
   Dave.Walk(102, 164, eBlock, eAnywhere);
   Dave.ChangeView(35);
   Dave.Animate(1, 5, eOnce, eBlock);
   Dave.x = Davex;
   Dave.y = DaveY;
   damage.Text = String.Format("%d",DaveATK);
  
   // Gui 4 fade in 
   gGui4.Visible = false;
   gGui4.Transparency = 100;
   gGui4.SetPosition(61, 106);
   gGui4.Visible = true;
   gGui4.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
   gGui4.TweenPosition(0.8, 61, 81, eEaseOutTween, eBlockTween);
   gGui4.Visible = false;
 
   // Remove DaveATK hit points from the Troll Lord
   trolllordHP -= DaveATK;
   Dave.ChangeView(40);
}


//
//  __setup_dawn()
//
function __setup_dawn()
{ 
   DisplayAt(115, 10, 200, "Pyraga");
   Dawn.ChangeView(8);
   Dawn.Animate(1, 5, eOnce, eBlock);
   object[9].TweenTransparency(0.4, 50, eLinearTween, eBlockTween);
    
   object[14].Visible = true; 
   object[14].SetView(41);
   object[14].Animate(0, 4, eOnce, eBlock);
   object[14].Visible = false;
   Dawn.ChangeView(7);
  
   DawnMGK += fire;
 
   damage.Text = String.Format("%d",DawnMGK);
 
   gGui4.Visible = false;
   gGui4.Transparency = 100;
   gGui4.SetPosition(61, 106);
   gGui4.Visible = true;
   gGui4.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
   gGui4.TweenPosition(0.8, 61, 81, eEaseOutTween, eBlockTween);
   gGui4.Visible = false;
 
 
   trolllordHP -= DawnMGK;
   DawnMGK -= fire;
   object[9].TweenTransparency(0.4, 100, eLinearTween, eNoBlockTween);
}


// *************************************************************************************
//
//  Button16_OnClick(GUIControl *control, MouseButton button)
//
// *************************************************************************************
function Button16_OnClick(GUIControl *control, MouseButton button)
{
   Troll.Baseline = 5;
   mouse.Visible = false;

   //gGui3.TweenTransparency(0.5, 100, eLinearTween, eBlockTween);

   __setup_dave(); // move Dave to position
   __setup_dawn(); // move Dawn to position
   
   PlayerMP -= 18;
    
   if ( trolllordHP <= 0 )
   {
      // This will execute when the Troll Lord's hitpoints expire.
      
      __troll_lord_death(); // When the troll lord dies, Dave will move to room 20.
   }
   else if( trolllordHP >= 1 )
   {
      // This will execute while the Troll Lord is alive.

      if( Game.DoOnceOnly("first strike") )
      {
         Troll.SayAt(8, 167, 320,"A splendid combo!");
         Troll.SayAt(8, 167, 320,"But alas, your still no match."); // ** your should be you're
         Troll.SayAt(8, 167, 320,"Now, stagger with PAIN!");  
      }

      // ************************************************************************************
      //
      //  I do not know what ATK2trol is, but this fuction will always exit here.  What 
      //  you have coded is a tautology.
      //
      //  This is a simpler version:
      //
      //  if ( ATKtrol > 4 )            // if 5 or greater
      //  {
      //     // do something...
      //  }
      //  else                          // else 4 or less
      //  {
      //    // do something else...
      //  }
      //
      //  The code below the comment "STOP" will never be executed. 
      //
      if( ATK2trol >= 5 )  // if 5 or greater
      {
         __attack_graviga();
         
         return;
      }
      else if( ATK2trol <= 4 ) // else if 4 or less
      {
         __attack_dakra();
         
         return;

      }

   } 
 
   // ***************************************************************
   // STOP
   // ***************************************************************
 
   //
   //  You say that the player death happens, but without me using the crutch of stepping 
   //  through the code in the debugger (i.e. running this in AGS), I cannot see 
   //  how you would ever get here.  I may not have copied your code correctly 
   //  from the forum...
   //
   //  Nevertheless, if you organize your code a little more neatly, it will be easier for
   //  you to debug.
   //
 
   if( PlayerHP <= 0 ) 
   {
      __player_death();
   }
   
   // ** your original comment
//it keeps stoping here
   // ** 
 
 
   //  Yes...  rewrite this.  
   
   if(Button15.Width == 1)
   {
     Button15.Width = 5;
     return;
   }
   else if(Button15.Width == 5)
   {
    Button15.Width = 10;
    return;
   }
   else if(Button15.Width == 10)
   {
     Button15.Width = 15;
     return;
   }
   else if(Button15.Width == 15)
   {
     Button15.Width = 20;
     return;
   }
   else if(Button15.Width == 20)
   {
     Button15.Width = 25;
     return;
   }
   else if(Button15.Width == 25)
   {
     Button15.Width = 30;
     return;
   }
   else if(Button15.Width == 30)
   {
     Button15.Width = 35;
     return;
   }
   else if(Button15.Width == 35)
   {
     Button15.Width = 40;
     return;
   }
   else if(Button15.Width == 40)
   {
     Button15.Width = 45;
     return;
   }
   else if(Button15.Width == 45)
   {
     Button15.Width = 50;
     return;
   }
   else if(Button15.Width == 50)
   {
     Button15.Width = 55;
     return;
   }
   else if(Button15.Width == 55)
   {
     Button15.Width = 60;
     return;
   }
   else if(Button15.Width == 60)
   {
     Button15.Width = 65;
     return;
   }
   else if(Button15.Width == 65)
   {
     Button15.Width = 70;
     return;
   }
   else if(Button15.Width == 70) 
   {
     Button15.Width = 75;
     return;
   }
   else if(Button15.Width == 75)
   {
      Button15.Width = 78;
      if(Game.DoOnceOnly("Assault"))
      {
         Dawn.SayAt(8, 167, 320,"Dave, now is our chance!");
         Dave.SayAt(8, 167, 320,"Let's show him what light can really do!");
      }
      Button17.Visible = true;
      return;
   }
   
   //  Do you only want to get here when the button width is not a mulitple of 5?
   //  Do you set it to such a value somewhere else in your program?
   //  In  the code above, you will only pass by this if/else when you set it to 78.
   
   // Fade GUI 3 onto the screen.  Is this the end of the attack sequence?
     
   gGui3.Visible = true;
   gGui3.TweenTransparency(0.5, 0, eLinearTween, eBlockTween);
   mouse.Visible = true;
  
}

Khris

I'm not sure if this is helping.
Why add custom functions but at the same time keep duplicate and superfluous code? Why bother helping like this, undermining my well deserved rant at the same time? Great job really.

This for instance is in there four times, and the only thing that changes is the label's text and the GUI's position.
Code: ags
   damage.Text = String.Format("%d",Gravity);
 
   gGui4.Visible = false;
   gGui4.Transparency = 100;
   gGui4.SetPosition(254, 116);
   gGui4.Visible = true;
   gGui4.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
   gGui4.TweenPosition(0.8, 254, 86, eEaseOutTween, eBlockTween);
   gGui4.Visible = false;


This is what custom functions are for.

Code: ags
// ONCE, at the top
function FadingMessage(String text, int x, int y) {
   damage.Text = text; 
   gGui4.SetPosition(x, y);
   gGui4.TweenTransparency(0.5, 0, eLinearTween, eNoBlockTween);
   gGui4.TweenPosition(0.8, x, y - 30, eEaseOutTween, eBlockTween);
   gGui4.Transparency = 100;
}

  // during battle, four of these
  FadingMessage(String.Format("%d",DaveATK), 254, 116);


This is what makes code readable.
As long as the GUI is set to Transparency = 100 and Visible = true at the start of the game, this will do just fine.

Icey

Khris Khris Khris, settle down, let's have some tea while discuss this. On a serious note. Khris, I posted this only because I knew the forms would be down, But I didn't know how long. I was really desperate and tired and I still had a bit more to finish. I was hoping someone could figure it out and email me the problem. I came back here and the forms were down. I fix the problem out of freaking luck cause I still didn't know what the problem was. I simply removed all the returns (even though they were working fine from the start which is why I didn't know my problem.)

After I fixed it I came back here and the forums was back up. Also I came back here to mark the thread as solved :3

@TheBitPriest: It's not that I didn't think of setting it up that way, however I only wanted to code something something that would only require one room. There's only one battle in the game so I didn't need to go all out. But that setup will help me for future games. ;)

@Khris: I never really worked with custom functions to that extent. It's not like I didn't want to but it's cause I didn't know how to. But I sorta get it now looking at that example.


Khris

To make this clear, return exits the function, no matter where it is called. You can not use it to exit an if block prematurely or something like that.
Usually, return is used to actually return a value:
Code: ags
int Sum(int a, int b) {
  return a + b;
}

  if (8 == Sum(3, 5)) Display("Correct.);


Calling it without a value can be useful to avoid lots of ifs; it's kind of a dirty shortcut though. It's one of those things that should only be used by people who already master the proper way.

Icey


TheBitPriest

I wasn't going to spend any time changing his code.    :)  I just took a few minutes to reorganize what was there in order to help him find his bug.  If you want to rewrite it for him, have at it!  ;)   

Your rant was well deserved.  Throwing that mess up and going to bed was cheap... I'm looking at you Icey.   :)



SMF spam blocked by CleanTalk