Text Timer and GuiPortrait Problem (or when Inventory GUI is open)**SOLVED**

Started by Knox, Wed 02/12/2009 03:38:41

Previous topic - Next topic

Knox

Hi,

Ive got this little problem when Im trying to display an emotion with SierraStyle dialog. I can get it to work no problems when Im in normal gameplay, but as soon as I try to get it to work when my inventory GUI is open and Im using the GuiPortrait module, something seems wrong with the timer.

Here is what I do when Im in normal gameplay (this works):

Code: ags

// room script file

int Lampost_counter;

function hLampPost_Look()
{
 if (Lampost_counter == 0) 
 {
  Display("You see a lampost.");
 }
 if (Lampost_counter == 1) 
 {
   Display("Looking closer, you see theres a piece of gum stuck to it.");  
 }
 if (Lampost_counter == 2) 
 {
  cEgo.SpeechView = 17;
  Game.MinimumTextDisplayTimeMs = 2500;
  cEgo.SayCustomFont("Nasty...");
  Game.MinimumTextDisplayTimeMs = 1000;
  SetOfficerSpeechView_Neutral();
 }
 if (Lampost_counter == 3) 
 {
   Display("You notice nothing else of interest about the lampost.."); 
 }
 if (Lampost_counter < 3) 
 {
   Lampost_counter += 1;
 }
}


I change the speech view to 17, which is a grimacing face, and I change the TextDisplayTime to 2500ms, say "Nasty" and then revert the speech view back to default. This works, when the player says "Nasty", the text timer closes the portrait and the textbox "Nasty" also closes automatically after a short time (how I want it).

However, when I try the exact same thing, but while the inventory GUI is opened (when looking at an inventory item), the timer doesnt seem to close the portrait image nor the textbox automatically at all...you absolutely MUST "close it" manually by pressing the "enter" key (as if skipping the speech with the timer no longer works).

What could be the problem here? I can give any other information that might be missing to help me debug this...:P


***EDIT***

It seems linked to the fact that the Inventory GUI pauses the game...if I unpause, then it works...

Anyway to get it to work but still keeping the GUI paused?
--All that is necessary for evil to triumph is for good men to do nothing.

GarageGothic

I have no experience with the GuiPortrait module, but can it be that the timer isn't running while the game is paused? Bringing up the inventory GUI presumably pauses the game, so that would explain it. If that's the case, adding an extra conditional to the timer (if (!IsGamePaused()) || (gInventory.Visible == true)) should solve it.

Knox

Hey GarageGothic,

Im not sure if I have access to the game's text timer to do that...I think that if the game is paused, the text timer is also paused, so if you display speech during that time with the module, the timer becomes unavailable. I guess Ill try to figure out a way to force it, or some other way.

On another note, what reasons would one want to have the game paused while the inventory is opened? Have any other people here used their inventory GUI's without pausing the game? I cant think of a reason why I would want to pause the game while the inventory is opened, other than stopping the character from walking while youre in that GUI.
--All that is necessary for evil to triumph is for good men to do nothing.

GarageGothic

Ah, so does the module use AGS' internal text timer? Without looking at the code I just assumed it had its own timer that you could add further conditionals to.

As for why the inventory should pause the game, of course that depends on your design. But it seems pretty standard that opening GUIs pauses background or idle animations, and of course interrupts any timed events (e.g. a bad guy is approaching you and you open the inventory to select your gun - most users would probably expect to be 'safe' while scrolling through the inventory items).

Knox

Yes I think it uses AGS's internal text timer...

True...a bad guy approches the player and you need to go into your inventory to get your gun...you would want it paused, eh!

I guess what I could do is put the pause on things manually, that way I can still use AGS's internal text timer...Like when the GUI is open I can do "if badguy is approaching and inventory gui is opened, pause badguy animation"...and then when the player leaves the inventory I can just resume the badguy approching animation.

I guess I have no choice :P

Thnx for your help!
--All that is necessary for evil to triumph is for good men to do nothing.

GarageGothic

Another solution would be to simply call PauseGame() when the "open inventory" button is clicked. The you can do an UnPauseGame() right before running the Say command. Since Say is blocking, the bad guy wouldn't move in the meantime and once the function finishes you simply call PauseGame() again.

Knox

Hey that sounds like a good idea! Im going to give it a try now!

;D

**EDIT**

Great, this works...very smart GarageGothic....nice.
--All that is necessary for evil to triumph is for good men to do nothing.

Knox

Double-posting...but its cause I dont want to start a new thread...:P

In Mel scripting, when I create a variable, I use this format:

Code: ags

string $sMyVariable = "MyVariable";
int $iMyIntVariable = "5";


Etc...
Ive searched the manual "Script language keywords" but couldnt find the answer to this:

When I try to use the dollar sign in AGS, doesnt seem I cant...is it reserved for something else? I know I can declare a variable without it, Im just wondering "why" I cant use it..
--All that is necessary for evil to triumph is for good men to do nothing.

Khris

Afaik, variable names can only contain alphanumerical letters.

Knox

Ah ok, its just one of those "rules" "thats just the way it is" kinda deal.
--All that is necessary for evil to triumph is for good men to do nothing.

monkey0506

Variable names in AGS follow the same guidelines as C-style languages. Khris is almost right. The rules for variable naming is as follows:

-Variable names can have ONLY alphanumeric characters and/or underscores.
-Variable names may not start with a number.

Understandably this is different from some languages, such as I know PHP variables all start with a $ to distinguish them from...well, everything else. However AGS simply doesn't allow this character in variable names.

SMF spam blocked by CleanTalk