Make Telephone GUI for AGS v3.2.1

Started by Arjunaz78, Tue 01/11/2011 08:59:13

Previous topic - Next topic

Arjunaz78

I just search the topic about using Telephone GUI in the forum search & found the right one that the Grundislav have post before

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=18314.0

(it's almost than 7 years ago..huhu..) but it's for the old AGS editor,besides many of that old code has been obsolete since the new version of editor now..however i already download an old version of AGS Editor (v2.7.2) but i don't feel easy to use it besides i already feel that the latest one is more suite to me to use it plus it's  have a nice program interface.. :)

Well...what i want is the same that Grundislav told before in her topic thread,besides i got confuse when view the scorpiorus post on that thread with the starting code with wierd 'Ã,' letter? how can i coding the script on the new version of AGS..how come?

..In the making of Silent Hill: The Hospital..

https://www.facebook.com/ArjunazGamesStudio

Khris

The messed up code is due to the board transfer, that's supposed to be a tab character.

Code: ags
// how long wait before dialing:
#define DIALING_DELAY 150

// max length of a phone number:
#define NUMBER_LENGTH_MAX 8

String strPhoneNumber;
int dialingCounter = 0;

// use this function to handle calls:
function OnNumberCalled(string number) {
 
  if (number == "911") {
    player.Say("help!1!11");
    ...
  }
  else if (number == "1337") {
    player.Say("blah blah");
    ..
  }
  else {
    Display("beep... beep... beep... Wrong number!");
  }
}

function repeatedly_execute() {
 // put anything you want to happen every game cycle here

  if (strPhoneNumber.Length > 0) {
    if (dialingCounter >= DIALING_DELAY) {
      OnNumberCalled(strPhoneNumber);
      strPhoneNumber == "";
      dialingCounter = 0;
    }
    else dialingCounter++;
  }
}

function Keypad_OnClick(GUIControl*theControl, MouseButton button) {
 
  if (button != eMouseLeft) return;
  button = theControl.ID;

  if (button >= 0 && button <= 9 && strPhoneNumber.Length < NUMBER_LENGTH_MAX) strPhoneNumber = String.Format("%s%d", strPhoneNumber, button);

  if (button == 10) strPhoneNumber == "";

  dialingCounter = 0;

  lblPhone.Text = strPhoneNumber;
}


Make sure that in your phone GUI, each button's keypad number is the same as the button's ID. Create button 0 first, then button 1, etc.
Then create button 10 to clear the display.
Finally, create a lbl called lblPhone to show the dialed number.

For each button, enter "Keypad_OnClick" without the quotes into the field next to its on click event.

(Also, please tell me that you weren't actually considering switching back to 2.X just to use that code...!? Seriously, what the hell.)

SMF spam blocked by CleanTalk