Advancing text with just the space bar

Started by jamesreg, Thu 03/06/2010 22:47:41

Previous topic - Next topic

jamesreg

I currently have my game set up to advance the text with keyboard press using the option in the general settings that ask you if you want to advance text with keyboard mouse or both

I would rather fix it so the text is skipped via the space bar only as players are complaining that sometimes when entering a mini game or new scene they accidently advance the text with the arrow keys or some other interaction.

how do I bypass the settings and script it to just skip the text with the space bar

Khris

In game_start, add
  game.skip_speech_specific_key = eKeySpace;

jamesreg

game.skip_speech_specific_key = eKeySpace;

I tried the above command but it still is skipping text with any press of the keyboard

Dualnames

If I remember correctly you have to set the skip speech to keyboard only for this to work.
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)

Ryan Timothy B

I gave it a shot with my game and it works perfectly fine.  The only key that skips the text is the space bar, also the mouse still works.

Are you sure you put it in the  game_start  function within the global script, like Khris had said?

jamesreg

#5
Yes I have entered the code correctly

does this have anything to do with the fact that I am using displayat vs sayat for my dialogs?

I choose display at cause at the time I was able to set it up pretty easily with font color, size and type of font I wanted

I tested this with changing to sayat and the script works it only skips with space bar but if i use displayat it will skip with any press

all the settings you told me to do are right I need this to work with the displayat command not just the sayat command

jamesreg

Quote from: jamesreg on Sat 05/06/2010 18:53:33
Yes I have entered the code correctly

does this have anything to do with the fact that I am using displayat vs sayat for my dialogs?

I choose display at cause at the time I was able to set it up pretty easily with font color, size and type of font I wanted

I tested this with changing to sayat and the script works it only skips with space bar but if i use displayat it will skip with any press

all the settings you told me to do are right I need this to work with the displayat command not just the sayat command

figured out my problem thanks guys

jamesreg

This is not fixed now I remember why I used the display at command instead of the say at command I couldnt seem to get sayat to display on top of a gui like I need to do as I use gui boxes for my dialogs background

so I need to get this to work with display at command or figure out how to get sayat to display on top of a gui

Ryan Timothy B

Why don't you use a GUI for the speech then?  You can script it to skip by the space bar, or a timer.

jamesreg

How do I do that?

right now we have a gui that has a text box and avatar picture pop up and we was displaying our text using displayat command on top of the gui
but this doesnt work with sayat

Ryan Timothy B

#10
You said Text Box, but I'm assuming you meant Label, because a text box receives text the user inputs.
Quoteright now we have a gui that has a text box and avatar picture pop up
Isn't that what you have the GUI label for, why are you using Display At instead? Also you're being vague and it makes it much harder for us to help you.

Since you were using Display At, which is a blocking call, I'm assuming you still want this to be blocking.  Also assuming this Avatar picture and label IS for the speech, but you weren't using it for some reason.

Assuming the label is called: Label1  and the GUI is called: gTheGUI.  I'm also assuming the Avatar picture is being displayed by a button, so pretend the button is called: Button1.
You can do something along the lines of this:

In the Global Script:
Code: ags

function noloopcheck message(int avatarSprite, String say) {
  Button1.NormalGraphic=avatarSprite;
  Label1.Text = say;
  gTheGUI.Visible=true;
  bool pressedSpace, doNotSkipSpeech;
  if (IsKeyPressed(eKeySpace)) doNotSkipSpeech=true;
  while (!pressedSpace)
  {
    if (IsKeyPressed(eKeySpace)) 
    {
      if (!doNotSkipSpeech) pressedSpace=true;
    } 
    else if (doNotSkipSpeech) doNotSkipSpeech=false;
    wait(1);
  }
  gTheGUI.Visible=false;
}


In the Global Script header:
Code: ags

import function message(int avatarSprite, String say);


When you want to display text with the avatar, you simple just call it by doing this:
Code: ags

message(13, "Hello World!");


The text would actually show the text forever unless the user pressed space, and it's untested because I wrote it in the browser.
You could also use a timer by checking the string length using: String.Length  but that's for another day. :P

Edit: Forgot to fix it to prevent you from holding the space button down before the you display the message, or if you held it during, it'd skip all messages.

jamesreg

I see what your doing no it does not have to block forever right now it times out after awhile or if you press a key

so basicaly what I want is for it to display and then time out if no response (it seems to time out based on the amount of text right now larger text takes longer to time out shorter text it disapears faster guess thats default ags text timeout dont know I like that though)

if space is pushed then that advances the text too is what I want

this is getting very close to what I want yes thank you.


jamesreg

Quote from: jamesreg on Sat 05/06/2010 22:46:44
I see what your doing no it does not have to block forever right now it times out after awhile or if you press a key

so basicaly what I want is for it to display and then time out if no response (it seems to time out based on the amount of text right now larger text takes longer to time out shorter text it disapears faster guess thats default ags text timeout dont know I like that though)

if space is pushed then that advances the text too is what I want

this is getting very close to what I want yes thank you.

one thing If Im understanding this correctly I would create a text label on the gui thats basicaly used as my dialog box and would not have a need to specify coordinates when calling up the text as the text label is already where it needs to be right



Ryan Timothy B

#13
That's exactly what I mean.  You create a GUI with a text label which will display the text.  
You can also get all fancy and have it change the text color and such depending on the character.  I'm assuming this isn't a regular adventure game setting, correct?  Because I've been under the impression it's for a mini game part of the adventure game, not the whole thing.

If it is you could always make it so that you could do this:  player.Message("Hello World.");
Let me know if it's supposed to be characters talking or if it's only like a narrator message.


Also, since you asked so nicely.  ::)  I'll show you how to make a timer which will clear the message after the certain time.

Code: ags

function message(String say) {
  Label2.Text = say;
  gGui1.Visible=true;
  int timer=60+(say.Length*2);
  bool pressedSpace, doNotSkipSpeech;
  if (IsKeyPressed(eKeySpace)) doNotSkipSpeech=true;
  while (!pressedSpace && timer>0)
  {
    if (IsKeyPressed(eKeySpace)) 
    {
      if (!doNotSkipSpeech) pressedSpace=true;
    } 
    else if (doNotSkipSpeech) doNotSkipSpeech=false;
    timer--;
    Wait(1);
  }
  gGui1.Visible=false;
}


Edit: Yeah, like I said before.  I really don't understand exactly what these messages are displaying for.  Are they supposed to be the character talking?

jamesreg

Its adventure game and characters talking its for the Star Trek Adventures game we been making and plan as a series of games.
We are nearing completion and going back and treaking things we have problems with and bugs and the dialog system we had before was ok
for away team missions and such but for our mini games and space battles its proved a problem cause players automaticaly start moving the arrow keys and stuff to do the mini games and skip text then dont know whats happening.

Right now we have functions in our global that is set up for each character such as spock kirk mccoy etc.

id like to set this up so that I could still do that so i could still do something simple like

Scotty_Speak("Detecting a vessel moving on a course in line with the planet.");

thats how we have it now and have a different function for each character so we can call it up fast

makes it easy so dont have to remember sprite numbers for avatars and all that

what you have here should allow me to set it up that way

Ryan Timothy B

#15
If these people talking are all characters, instead of having dozens and dozens of duplicate functions all doing the same thing, you could simply do this:

Code: ags

function Message(this Character*, String say) {
  if (this==cScotty) Button1.NormalGraphic=12;
  else if (this==cKirk) Button1.NormalGraphic=13;
  //etc...
  
  Label2.Text = say;
  gGui1.Visible=true;
  int timer=60+(say.Length*2);
  bool pressedSpace, doNotSkipSpeech;
  if (IsKeyPressed(eKeySpace)) doNotSkipSpeech=true;
  while (!pressedSpace && timer>0)
  {
    if (IsKeyPressed(eKeySpace)) 
    {
      if (!doNotSkipSpeech) pressedSpace=true;
    } 
    else if (doNotSkipSpeech) doNotSkipSpeech=false;
    timer--;
    Wait(1);
  }
  gGui1.Visible=false;
}


And in the header it would now be:
Code: ags

import function Message(this Character*, String say);


Then to call this function you simply just do this:
Code: ags

cScotty.Message("Hello, I'm Scotty!");
cKirk.Message("Hello, I'm Kirk!");



Also, now that I know these are characters talking, I'm not sure why you didn't just use your own custom Display box with Avatar picture for each character.  It's already setup for doing so in AGS... although I've never used it myself.

jamesreg

#16
This is working perfectly and how I wanted it except with one slight problem and that is if my text does not confine itself to the textbox it overflows the list box when i was using the display at I would us DisplayAt(98, 511, 325, says); if that helps

SMF spam blocked by CleanTalk