Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: arthur.com on Sun 22/04/2007 15:48:30

Title: Need help with Text parser
Post by: arthur.com on Sun 22/04/2007 15:48:30
Could someone make a tutorial how do i make text phraser?
Including GUI,scripts and evereything.
Title: Re: Need help with Text phraser
Post by: Akatosh on Sun 22/04/2007 16:54:26
There's one in the manual. Just search for 'Text Parser'.
Title: Re: Need help with Text phraser
Post by: Khris on Sun 22/04/2007 18:11:03
To get you started, here's the on_key_press-code I wrote once.
Add a GUI, name it "PARSER".
Put a textbox on it, name it "command".

String oldline;
String newline;

#sectionstart on_key_press  // DO NOT EDIT OR REMOVE THIS LINE
function on_key_press(int keycode) {
  // called when a key is pressed. keycode holds the key's ASCII code

  // standard AGS keypress stuff here
 
  // parser
  if (keycode==361 && oldline!=null) { // F3
    command.Text=oldline;
    gParser.Visible=true;
  }
  if (keycode==8 && command.Text=="") { // Delete (when empty)
    gParser.Visible=false;
  }
  if (keycode>=65 && keycode<=122 && gParser.Visible==false) { // show box after keypress
    if (keycode<=90 && IsKeyPressed(403)==0 && IsKeyPressed(404)==0) keycode=keycode+32; // shift?
    gParser.Visible=true;
    newline="";
    command.Text=newline.AppendChar(keycode);
  }
}
#sectionend on_key_press  // DO NOT EDIT OR REMOVE THIS LINE
Title: Re: Need help with Text phraser
Post by: arthur.com on Mon 23/04/2007 13:25:04
Thanks.
I really need the text parser because a GUI would be too small for all the options
(STARWARS sim game)

EDIT:
umm.....where EXACTLY do i have to write that? ???


Edit by Ashen: Don't double post.
Title: Re: Need help with Text parser
Post by: Khris on Mon 23/04/2007 14:13:12
Menu: Script -> on_key_press
Now extend the existing function until it looks like the code above.
(Don't delete the contents inside, leave it where I wrote "// standard AGS keypress stuff here").