Counter script

Started by Icey, Sat 12/03/2011 02:26:29

Previous topic - Next topic

Icey

I am using the counter script and I just dont understand it. well half of it.

Code: ags

// room script file
int playerHP = 100;//always set this here
int EnemyST = 120;//always set this here


function room_Load()
{
  Shiva.Visible = false;
tifa.ChangeRoom(12, 73, 125);
  EnemyST = 50;//always set this here
  Dave.AddInventory(com1);
  tifa.AddInventory(com2);
gGui5.Visible = false;
party.Visible = false;
 commands.CharacterToUse = Dave;
HUD.Visible = false;
mouse.DisableMode(eModeTalkto);
  mouse.DisableMode(eModeWalkto);
  mouse.DisableMode(eModeLookat);
  //-------------------------------------------------------------
CountDown.SetTime(60, 2);//set Timer.

  Dnum.Text = "HH:MM:SS";

//---------------------------------------------------------------
}

function room_AfterFadeIn()
{
  HUD.TweenTransparency(0.1, 100);
    gameover.Visible = false;
  gameover.TweenTransparency(0.1, 100);
  Shiva.TweenTransparency(0.1, 100);
  Dave.SayAt(8, 167, 320,"Dave:Tifa, Your okay.");
tifa.SayAt(8, 167, 320,"Tifa:Dave, I'ma lot stronger then I look remember.");
  Dave.SayAt(8, 167, 320,"Dave:Ha, Like I would that.");
tifa.SayAt(8, 167, 320,"Tifa:Dave what is that light?");
  Dave.SayAt(8, 167, 320,"Dave:It's that last bit of light in this time.");
tifa.SayAt(8, 167, 320,"Tifa:time?");
  Dave.SayAt(8, 167, 320,"Dave:It's a long story. But where is the darkness.");
tifa.SayAt(8, 167, 320,"Tifa:?.");
  Dave.SayAt(8, 167, 320,"Dave:It's the last bit of light and it still looks bright as day.");
tifa.SayAt(8, 167, 320,"Tifa:Hold on. Looks like we got visitors.");
  aBoss1a.Play(eAudioPriorityHigh);
Shiva.TweenTransparency(2.5, 0);
Dave.SayAt(8, 167, 320,"Dave:Remember?");
tifa.SayAt(8, 167, 320,"Tifa:Just like old days.");
//play commence sounds
Display("commence!");
HUD.Visible = true;
HUD.TweenTransparency(1.0, 0);
  gGui5.Clickable = false;
  party.Clickable = false;
    gGui5.TweenTransparency(0.1, 100);
    party.TweenTransparency(0.1, 100);
}

function room_Leave()
{

}

function room_RepExec()
{
  //////////////////
 CountDown.Update(true);
//////////////////
// Character *cat = Character.GetAtScreenXY(mouse.x, mouse.y);
  Object *cat = Object.GetAtScreenXY(mouse.x, mouse.y);
  Object *oat = Object.GetAtScreenXY(mouse.x, mouse.y);
 // enemyHP.Visible = ((cat != null) || (oat != null)); // where gOver is the name of the GUI you want to have turned on or off
if(Shiva.X){
  if(Shiva.Y){
  enemyHP.Visible = ((cat != null) || (oat != null)); // where gOver is the name of the GUI you want to have turned on or off
  target.NormalGraphic = 182;// shiva icon change
  OE.NormalGraphic = 184;
  
}
}
strengths.Text = String.Format("HP: %d", playerHP);//Menu health
    pairHP.Text = String.Format("HP: %d", playerHP);//pair health
   
   enemystats.Text = String.Format("HP: %d", EnemyST);//Enemy health


//adding timer events--------------------------------------------------------------------------                       


  Dnum.Text = "HH:MM:SS";
if ((gameLoops < 0)){                                             _____PART X_____


 Dave.SayAt(8, 167, 320,"Dave:Is this it?.");
adeath.Play(eAudioPriorityHigh);
 Dave.Tint(204, 0, 0, 100, 0);
 tifa.Tint(204, 0, 0, 100, 0)
 Dave.TweenTransparency(1.5, 100);
  tifa.TweenTransparency(1.5, 100);
  aBoss1a.Stop();
  gameover.Visible = true;
  gameover.TweenTransparency(1.0, 0);


}
}
 CountDown.ShowOnLabel;

TimeToGameLoops(60, 2);
//testing timer---------------------------------------------------------------<><><>
}
function Shiva_UseInv()
{
if(Dave.ActiveInventory == com1){//Attack
    Dave.ChangeView(18);
    Dave.Animate(2, 4, eOnce, eBlock, eForwards);
   
  EnemyST -= 5;
   Dave.ChangeView(3);
   Dave.FaceObject(Shiva, eBlock);
  }
 //<Life or death> (2)If plaer is alive continue on below
//----------------------------------------------------------
   // commands.CharacterToUse = tifa;
  //tifa.SetAsPlayer();
  tifa.ChangeView(16);
    tifa.Animate(2, 4, eOnce, eBlock, eForwards);
 playerHP += 7;
 tifa.ChangeView(10);
   tifa.FaceObject(Shiva, eBlock);
  //----------------------------------------------------------
  
  
  if(EnemyST <= 0){
    adeath.Play(eAudioPriorityHigh); //Play death sound
  shiva.TweenTransparency(1.0, 100);
 
  GiveScore(125);
  Shiva.Visible = false;
  HUD.TweenTransparency(0.5, 100);
  HUD.Visible = false;
  mouse.EnableMode(eModeTalkto);
  mouse.EnableMode(eModeWalkto);
  mouse.EnableMode(eModeLookat);
  gGui5.Clickable = true;
  party.Clickable = true;
    gGui5.TweenTransparency(0.1, 0);
    party.TweenTransparency(0.1, 0);
    gGui5.Visible = false;
party.Visible = false;
  RemoveWalkableArea(1);
  
 

Dave.Say("Yeah we did it! Let's head back ok.");
//Play fanfare.
mouse.Visible = true;
gGui12.Visible = true;

}
  //timer death---------------------------------<><><>testing 
  if ((gameLoops < 0)){
  
  
 
  
  }
  
  //--------------------------------------------<><><>
  if(playerHP <= 1){
  playerHP -= 10;//player lose HP (Place here)
if(playerHP <= 0){
 CountDown.Stop();
 Dave.SayAt(8, 167, 320,"Dave:Is this it?.");
adeath.Play(eAudioPriorityHigh);
 Dave.Tint(204, 0, 0, 100, 0);
 tifa.Tint(204, 0, 0, 100, 0)
 Dave.TweenTransparency(1.5, 100);
  tifa.TweenTransparency(1.5, 100);
  aBoss1a.Stop();
  gameover.Visible = true;
  gameover.TweenTransparency(1.0, 0);
  
  
}



Basically I have a gui that has a timer label on it. The timer is consider as the DOOM counter. Which means when the time runs out the music stops and the player dies. See (Part X)

Now I have messed around with it for a bit and I just do know were to put stuff.

monkey0506

I'm sorry, but is there actually a question here? You said you don't understand what this does, at least not entirely, but you haven't posed anything that you specifically need help understanding.

I really don't mean to come across as rude, but you really need to present us with specific questions if you want us to be able to help you.

Icey

Ok, What I need help with is ordering thing from you module in my script. does this clear things up a little.

Icey

I keep getting errors when I try and start the game with stuff from your script.

Icey

Also there is a part in the script that I cant get. I cant put anything for when the counter time is up. I have something like

Example

if(counter.timeUp == true){



}

as you can see I just made this up but it is a example.

monkey0506

#5
What error(s) are you getting?

Looking a bit closer at the bits of your code that are directly pertinent to the CountDown module that I wrote..you're doing things like referencing properties without getting or setting a value, but using them as if they were a function..and calling functions that return values without storing or using the value.. :-\

The provided documentation is, admittedly, lacking in actual code examples (throughout, though there is a collective example at the end), but if you read it, you should understand that, for example, CountDown.ShowOnLabel is used to get or set the label that the count-down is shown on, not whether or not it is shown. It should be used like this:

Code: ags
  CountDown.ShowOnLabel = Dnum;


And TimeToGameLoops does not actually do anything with the counter or anything of the sort..all it does is perform a calculation to convert real time into game loops, and return the result. You would use that like:

Code: ags
  int loops = TimeToGameLoops(55, 2);
  Wait(loops);


That would wait for 2 minutes and 55 seconds (by default, 7000 game loops).

Edit: You posted again while I was typing this, so regarding the time running out, I provided CountDown.TimesUpAnnouncer, CountDown.TimesUpText, CountDown.TimesUpNewRoom, CountDown.TimesUpNewRoomX, and CountDown.TimesUpNewRoomY to allow you to have a specific character announce that the time has expired (or use Display instead), and/or move the player to a new room (optionally at specific coordinates).

I wasn't sure what all else anyone might want to do when the time had run out, and due to limited feedback, nothing else was implemented. Is there anything else that you need? Would you find it beneficial to simply be able to check, for example, a boolean value that would be reset if the count down time was changed or if the count down was stopped? Retrospectively that seems like it would be useful, and not that difficult to implement.

Also, are you aware that it's against the forum rules to triple post? Just thought I'd let you know..

Icey

#6
1)Ok so that's why it wasn't working.

2)I guess I could try an do that. How ever wouldn't it work if I use a int with the label to make a countdown timer like I do with HP?

I could set it in the Rep_ex.
And when it reaches 0 I could have it check then stop and run what ever I want to run thats inside the brackets?

3)No I did not know that. I dont recall seeing it before but it doesn't matter I wont do it again.

monkey0506

I'm not sure specifically what you're responding to with #2 here, but I'm guessing you're referring to the issue with the time running out. For that you could do something like:

Code: ags
// top of room script
bool countDownStarted = false;

// room_Load
  CountDown.SetTime(60, 2); // this is 2 minutes and 60 seconds, which is..3 minutes exactly..?
  countDownStarted = true;

// room_RepExec
  if ((countDownStarted) && (!CountDown.RawTimeRemaining))
  {
    // count down has expired..
  }


The RawTimeRemaining property will tell you the exact number of game loops, which is simpler than checking the Hours, Minutes, and Seconds properties.

As for #3, the reason that double- and triple-posting is against the rules is because it bumps the thread to the top of the beginner's forum, and you're not the only one who needs help! ;) We definitely don't mind helping, and if several days have passed and you still need help then a "bump" is usually considered okay, but we just try to be respectful of others as well.

Icey

Thanks I will try this now.

Also I didn't mean to bump my topic.

Icey



Btw, Thanks it works just fine however it seems when the timer is up for some reason it asks like (While) By this I mean when the time is up I have a game over gui that fades in however I lose control over the game and it just repeats whats inside the

  if ((countDownStarted) && (!CountDown.RawTimeRemaining))
  {
    // count down has expired..
  }

monkey0506

Sorry, I should have let you know.. ::)

Inside that block set countDownStarted to false again:

Code: ags
  if ((countDownStarted) && (!CountDown.RawTimeRemaining))
  {
    // count down has expired..
    // ...
    countDownStarted = false; // prevent this from running more than once!
  }

Icey

Thanks.

it Should work now.

SMF spam blocked by CleanTalk