Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Mantra of Doom on Fri 19/12/2008 03:38:06

Title: help with hint system code
Post by: Mantra of Doom on Fri 19/12/2008 03:38:06
Hello everyone. I've been working on a little hint system code, so that if a player chooses, they can get in-game help if they get stuck. I always liked the hint guide that came with Sam & Max Hit the Road... the first line gives you a clue, then it goes more specific.

Here's my code so far. I'm using the score to keep track of the progress of the player's action. I know that I'm going about this the hard way. As of right now, the gui has text boxes that the strings populate. If the text is too long though, it will not wrap into the box and if the text is wider than the gui, it'll just not populate at all.

Any ideas how I can clean this up or at least add text wrapping?


//First Hint
function btnHint1_OnClick(GUIControl *control, MouseButton button)
{
  if (game.score==0) //vague hint
  {
    if (button != eMouseLeft) return;  // only react to left-clicks
  String hint1aString = txtHint1.Text;
  txtHint1.Text = String.Format("Vague Hint");
  }
//other points follow with similar code for the first line of hints.
}
 
//Second Hint
function btnHint2_OnClick(GUIControl *control, MouseButton button)
{
   if (game.score==0) //more specific
  {
    if (button != eMouseLeft) return;  // only react to left-clicks
  String hint2aString = txtHint2.Text;
  txtHint1.Text = String.Format("More specific");
  }
}
 
  //Third Hint
function btnHint3_OnClick(GUIControl *control, MouseButton button)
{
  if (game.score==0) //give the answer away
  {
    if (button != eMouseLeft) return;  // only react to left-clicks
  String hint3aString = txtHint3.Text;
  txtHint1.Text = String.Format("I'm just giving you the answer.");
  }
}
Title: Re: help wit hint system code
Post by: Trent R on Fri 19/12/2008 05:01:37
Well, you can use GetText Width and Height to figure the size, then change it dynamically.

Is this gonna be UHS style?


~Trent
Title: Re: help wit hint system code
Post by: Khris on Fri 19/12/2008 09:54:09
I gotta go in a few minutes, so just a few pointers:

This line:
if (button != eMouseLeft) return;  // only react to left-clicks
should go at the very top of the function.

Using the score won't work at all, unless the puzzles are completely linear (which I doubt, and if they are, it's bad design).

You don't need to use String.Format unless you actually format the string.
It's fine to do:
  txtHint1.Text = "Vague Hint";