cCharacter.say. Message flashing up to quickly when using IsKeyPressed.

Started by RetroJay, Mon 08/12/2014 23:15:48

Previous topic - Next topic

RetroJay

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: ags
function Interact_Objects() {
// INTERACT WITH OBJECTS SCRIPT.

  if (AreThingsOverlapping(DAN, 1021)) {
    if (IsKeyPressed(eKeyZ) && gMansion_Map.Visible == false && gQuit_Dialog.Visible == false ) {
      oKey.Visible = false;
      cDan.AddInventory(inventory[1]);     
      cDan.Say("Blah...Blah."); // Use Z key to pick up object.
    }
    
    else{
      if (IsKeyPressed(eKeyA) && gMansion_Map.Visible == false && gQuit_Dialog.Visible == false )
      cDan.Say("Blah...Blah."); // Use A key to look at object.
    }
  }
  // Etc...(There is a considerable amount of script after this.)


To make the Function work I have called it from the rooms 'RepExec'.
Code: ags
function room_RepExec() {
  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.

Vincent

There may be many reasons which occurs this - bug :)
Especially when you say that :)

Quote from: RetroJay on Mon 08/12/2014 23:15:48
Code: ags

  // 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: ags


bool first_time;

function region1_WalksOnto()
{
   if ( !gMansion_Map.Visible && !gQuit_Dialog.Visible )
   {
       if ( IsKeyPressed(eKeyA)  &&  first_time )
       {      
          player.LookAtObj(oObject1.X, oObject1.Y, "Bla Bla Bla");
          first_time = false;
       }
    }
}

/////////////////////////////////////////////////////////////////////////////////////////
// function LookAtObj(this Character*, int x, int y, String Text)
// {
//     player.Walk(x, y, eBlock);
//     player.SayBackground(Text);
//     // eventually face location / add-lose inventory item / etc etc
//  }
////////////////////////////////////////////////////////////////////////////////////////


Have you tried with region or hotspot already ?

RetroJay

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.

RetroJay

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.

Vincent

Ciao RetroJay, :)

You are very nice and kind.

Quote from: RetroJay on Tue 09/12/2014 04:20:54
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...

Quote from: RetroJay on Tue 09/12/2014 02:09:21
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 -

Cassiebsg

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

Hi Cassiebsg.
QuoteWhat 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.



Cassiebsg

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

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.

SMF spam blocked by CleanTalk