Author Topic: cCharacter.say. Message flashing up to quickly when using IsKeyPressed.  (Read 927 times)

RetroJay

  • Posts: 537
  • Frankly, my dear, I'm a Kerbal and Proud of it.
    • RetroJay worked on a game that was nominated for an AGS Award!
Hi All Good Peeps.

I hope you are all well.

My game that I am working on at the moment is almost finished.
It is a kind of Platform/Adventure game and is only controlled by the keyboard.

Arrow keys = Move.
A = Look.
Z = Pick up / Use.

I nearly have everything working just the way I want.
The only thing that is bugging me is the 'cCharacter.Say' parts of my game.
The problem I am having is that, every now and then, when the A or Z key is pressed the 'cDan.Say' message flashes up and disappears in less than a second.???
This doesn't always happen but annoys the hell out of me when it does.

As you will see in the section of script below, I have created a Function for all of the Objects in my room.
Code: Adventure Game Studio
  1. function Interact_Objects() {
  2. // INTERACT WITH OBJECTS SCRIPT.
  3.  
  4.   if (AreThingsOverlapping(DAN, 1021)) {
  5.     if (IsKeyPressed(eKeyZ) && gMansion_Map.Visible == false && gQuit_Dialog.Visible == false ) {
  6.       oKey.Visible = false;
  7.       cDan.AddInventory(inventory[1]);    
  8.       cDan.Say("Blah...Blah."); // Use Z key to pick up object.
  9.     }
  10.    
  11.     else{
  12.       if (IsKeyPressed(eKeyA) && gMansion_Map.Visible == false && gQuit_Dialog.Visible == false )
  13.       cDan.Say("Blah...Blah."); // Use A key to look at object.
  14.     }
  15.   }
  16.   // Etc...(There is a considerable amount of script after this.)

To make the Function work I have called it from the rooms 'RepExec'.
Code: Adventure Game Studio
  1. function room_RepExec() {
  2.   Interact_Objects(); // This calls upon the 'Interact_Objects' script above.

I would be most grateful if someone could shed some light on why this small but irritating bug :-\ happens.

Yours.
Jay.
  Master Decorator

Vincent

  • Posts: 338
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
There may be many reasons which occurs this - bug :)
Especially when you say that :)

Code: Adventure Game Studio
  1.   // Etc...(There is a considerable amount of script after this.)

If this is a platform game however,
I would use hotspot or region to detect this type of interactions
I think they are more flexible and easy to handle.
For example then, you can simply write something like this

Code: Adventure Game Studio
  1.  
  2. bool first_time;
  3.  
  4. function region1_WalksOnto()
  5. {
  6.    if ( !gMansion_Map.Visible && !gQuit_Dialog.Visible )
  7.    {
  8.        if ( IsKeyPressed(eKeyA)  &&  first_time )
  9.        {      
  10.           player.LookAtObj(oObject1.X, oObject1.Y, "Bla Bla Bla");
  11.           first_time = false;
  12.        }
  13.     }
  14. }
  15.  
  16. /////////////////////////////////////////////////////////////////////////////////////////
  17. // function LookAtObj(this Character*, int x, int y, String Text)
  18. // {
  19. //     player.Walk(x, y, eBlock);
  20. //     player.SayBackground(Text);
  21. //     // eventually face location / add-lose inventory item / etc etc
  22. //  }
  23. ////////////////////////////////////////////////////////////////////////////////////////

 Have you tried with region or hotspot already ?

RetroJay

  • Posts: 537
  • Frankly, my dear, I'm a Kerbal and Proud of it.
    • RetroJay worked on a game that was nominated for an AGS Award!
Hi Vincent.

When I say:
Quote
// Etc...(There is a considerable amount of script after this.)
I mean that it is pretty much the same for every object that is in that room.
I have used up my Object Limit !! (There are SHIT loads of them.)  (laugh)

Yes. I have already tried Hotspots but the same thing happens, You press A or Z and the message flashes then disappears.
As I said before, though, this doesn't always happen.

I have Regions set up for other effects... and even used Characters for... More Effects...

The way that you have suggested will not work with what I have.  :(
You see I have tried to be clever and incorporate Platform with Adventure.
It all works beautifully, except for the occasional 'Message' hiccup.

Edit:
What needs to happen is that when you press key (A or Z) the message is shown and the game pauses (still showing the message.)
Then by pressing any of the Arrow keys the game un-pauses and continues. (That would be the ideal setup.)
You see I have Creatures that move to and fro, on each level, that can take away valuable 'Sanity' points, should they collide with you.

Edit:
Sorry for my depressed state earlier.
I am so near to completion and this problem (Niggle) is really PISSING ME OFF !!  (laugh)

Thank you for your help.

Yours.
Jay.
« Last Edit: 09 Dec 2014, 03:46 by RetroJay »
  Master Decorator

RetroJay

  • Posts: 537
  • Frankly, my dear, I'm a Kerbal and Proud of it.
    • RetroJay worked on a game that was nominated for an AGS Award!
Hi Vincent.

I edited my last post as I felt it to be defeatist. :P
I am here, again, and in the words of 'Commander Peter Quincy Taggart' "Never Give Up, Never Surrender". (laugh) ... (I love the film Galaxy Quest.) (roll)

Let's try this again.
Looking at your script 'SayBackground' works well with my script... However...
I wanted to use the Speech Style - 'SierraWithBackground' as I have a nice little portrait to go with the speech.
I should have mentioned this before... Sorry. :-[

If I can't get the Portrait thing to work then I will go with 'SayBackground' instead.

I really appreciate your help, Vincent.
You have helped me before on this game and will receive a credit.  ;)

Yours.
Jay.
« Last Edit: 09 Dec 2014, 04:26 by RetroJay »
  Master Decorator

Vincent

  • Posts: 338
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
Ciao RetroJay, :)

You are very nice and kind.

I wanted to use the Speech Style - 'SierraWithBackground' as I have a nice little portrait to go with the speech.

The SierraWithBackground, as you may have noticed, it puts the game on pause.
And then, it releases on unpause game, so...

What needs to happen is that when you press key (A or Z) the message is shown and the game pauses (still showing the message.)

This might be difficult to do with SierraWithBackground.
Similarly, you can create your own GUI with the portrait and the same GUI will be where the message comes out.


I tried lately to open a default game,
I created an hotspot and the GUI ("where the player speech") and to make the interaction via stand on hotspot
Worked well by pushing for example A, game paused and the label is showed, nothing more.
Then, by pressing any key, it disappear and return to unpause the game..

Maybe there is something wrong with the AreThingsOverlapping ?
Because as you said, you have many in the script that detect every interaction with objects..

AreThingsOverlapping

Checks whether two characters or objects are overlapping each other on screen.
Returns 0 if they are not overlapping, or the overlapping amount if they are.

I hope I helped further, however, I wish you all the peace of this world to make your game done :-D

:EDIT: The Speech style here doesn't matter at all. Character.Say unlike the Character.SayBackground doesn't returns immediately.
I would create only a GUI with a label - where the player speech -
« Last Edit: 09 Dec 2014, 12:35 by Vincent »

Cassiebsg

  • Cavefish
  • Posts: 5,013
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Please disregard if what I'm asking is sooo basic, that doesn't even apply here... but since I noticed advanced users forgetting a few basics I'll ask anyway.

What type of events have you set you for the dialog?
That little line that says "Allow Speech to be skipped by which events", cause maybe that is interfering?

But probably has nothing to do with this, since you wish to let the player type away from the text...
There are those who believe that life here began out there...

RetroJay

  • Posts: 537
  • Frankly, my dear, I'm a Kerbal and Proud of it.
    • RetroJay worked on a game that was nominated for an AGS Award!
Hi Cassiebsg.
Quote
What type of events have you set you for the dialog?
That little line that says "Allow Speech to be skipped by which events", cause maybe that is interfering?
I have it set to 'Keyboard Only' as my game is entirely keyboard controlled.
Thanks for your input.

Vincent:
Thank you ever so much for your help.
The people I have got testing my game can't see a problem... and so...
After all of this I have decided to leave it just the way it is.(laugh)
I think the problem lies with me trying to be too much of a perfectionist and seeing problems where there aren't really any.(roll)

Yours.
Jay.


  Master Decorator

Cassiebsg

  • Cavefish
  • Posts: 5,013
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
RetroJay, maybe you just holding the A key a bit too long, and AGS interprets as 2 key strikes, and thus skips the text? /beats me if this is even the way AGS works).
You could set the dialog to only mouse or only timer, and then see if you can still make the dialog flashing away to happen? Just as a test, not saying you should change game design, but might be useful to make sure it's not a keystroke you're making that you don't even notice. ;)
There are those who believe that life here began out there...

RetroJay

  • Posts: 537
  • Frankly, my dear, I'm a Kerbal and Proud of it.
    • RetroJay worked on a game that was nominated for an AGS Award!
Hi Cassiebsg.

You are absolutely correct.
I have tested every method of this now and it only seems to happen if the key is held down for to long. (on Keyboard Only.)

You see, I have to have it set on 'Keyboard Only' because there are multiple creatures that can hurt you.
By doing it this way you can read the message and escape if a foe gets to near to you.
It's a shame that I can't stop the flickering from happening but... Shit Happens! (laugh)

Thank you for your help.

Yours.
Jay.
  Master Decorator