PAUSE function bug/glitch/whatever(SOLVED Thanks Gilbot)

Started by Dualnames, Thu 29/05/2008 14:40:57

Previous topic - Next topic

Dualnames

I usually trace bugs easily since i debug too damn good.
But this one bugs me from sleeping
I'll post a part of the code that bugs it and the result

function repeatedly_execute() {
if (gInventory.Visible==true) {
PauseGame();
}
else {
UnPauseGame();
}

//The above line works perfectly. however.
//This kind of line(type of which exists in every room almost )bugs it.

int counter;//it's a variable for time-event things
function Room_Rep_Exec() {
if (counter!=240) {
counter++;
}
if (counter==240) {
//run event(usually a event that contains blocking functions(cEgo.Say, object[0].animate, etc)
}
}

Result: If counter is below 240 and gui is open the counter keeps increasing
if counter is 240 and gui is open if the event has one blocking function game freezes.

So any solutions?
I was thinking of adding is game paused before each counter to prevent it from increasing while inventory gui is open.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Gilbert

1. I don't know if this has been changed but as far as I remember when a game is "paused", timers are probably still running and/or repeatedly execute scripts in a game still runs (this had once caused bugs in the timed pizzles of beta versions of Pleurghburgh).
2. Also, depends on whether you want that event to occur repeatedly or only once. If it is to occur repeatedly you need to reset the counter to zero once it happens, otherwise, you still need to modify the counter by ++ perhaps, or the event will occur an indefinitely number of times AFTERWARDS. Here I assume you want the former effect.
So, try:
Code: ags

if (!IsGamePaused()
  if (counter<240) { //IMO better use <
    counter++;
  } else if (counter==240) {
    //run event(usually a event that contains blocking functions(cEgo.Say, object[0].animate, etc)
    counter=0;
  }
}

Dualnames

The problem isn't of the event happening , that works fine and as I want it to work. the problem is the variable increases all the time and if the blocking event occurs whilst game is paused then it freezes.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Gilbert

So, didn't you try my suggestion? Even it it's not related to the variable, my codes suggested you to have the blocking events only when the game is unpaused (and I know, my code is missing a closing parathesis in the first line, I'm just lazy to fix it).

Dualnames

Wow, I'm blind. Didn;t noitce the first line...geez. Sorry, mate.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

JpSoft

Rep_exec section occurs even when the game is pause. So, just include all the rep_exec function inside something like this:

Section Rep_exec:

If (IsGamePaused() == 0)
  {
  // Everything you want to happens in the game
  }
else
  {
  // Things you want happens ALWAYS (allow save/restore game, quit game...)
  }

I had a trouble like this and the best way i founded was this.

Jp

Khris

Yeah, Gilbot will find this useful.
Oh wait, no, he wrote the exact same thing a few posts further up.

SMF spam blocked by CleanTalk