I have trouble starting the text parser.

Started by Global Lint, Sun 18/06/2006 23:16:14

Previous topic - Next topic

Global Lint

The manual said that I needed a GUI for the player's input, but I couldn't find anything else on the subject.  So I have a blank GUI sitting at the bottom of the screen, very useless.  How do I change it so it can be used for text input?

-Thanks!

Faith
Spaz ate the dopefish.

Akumayo

Look up "TextBoxes" in the manual.  That should get you started.

Oh, and welcome to the forums  :)
"Power is not a means - it is an end."

Global Lint

Spaz ate the dopefish.

Ashen

#3
You may also be intersted in Magintz's Text Parser Template (V2.71+ needed), and I think there's a few other example games out there - I can't remember who by at the moment, but a search should turn them up.
I know what you're thinking ... Don't think that.

Global Lint

#4
The manual doesn't have anything useful as far as I can tell.  Is there a more specific tutorial on the text parser?
Spaz ate the dopefish.

Ashen

Not as far as I know.
I think there's a bit of a vicious circle with the parser - it's not very well documented and a little tricky to use, so not many people use it, so it stays un-documented and tricky to use...

lo_res_man asked for help with it just recently, and he didn't really get a straight answer either. I'll also quote Bernie, from that thread:
QuoteIt's hard to help you if you're not getting more specific. What do you have problems with? The parser commands? Or maybe with creating a GUI for text input?

The same applys to you - unless there's a Parser Tutorial around that I don't know about (which is possible, it's not something I've ever really thought about), your best bet is to ask questions about specific problems you're having. (Actually, that's pretty much ALWAYS a good idea.) For example, I'm sure you had an error message quoted in your post, before editing it. What exactly where you doing when you got it? What bits of the manual have you looked at, that aren't that useful?
I know what you're thinking ... Don't think that.

Global Lint

#6
 In order...:

The error message popped up when I was going into the 'edit script' for the GUI I wanted to use as a text box.Ã,  It said:

(Exception 0x00000000 at EIP = 0x00000000, AGSEDIT v2.71631, SIP = 26)

But I started another game up and tried making a textbox in that one.Ã,  I named it "TextBox".Ã,  But another error popped up saying "This should never happen.Ã,  Try downloading the most recent version of AGS."Ã,  Is 2.71 the most recent version?Ã, 

I also tried not naming it at all, and I looked in the manual for textboxes.Ã,  A part of it said 'String Textbox.Text;' meant using it would let the parser take what was typed.Ã,  I tried saving and it said 'Variable 'Textbox' is already defined.'Ã,  I don't know how to fix that.

(Someone in that thread said something about an IF newsgroup or forum?  I'd check there if I knew where it was.)
Spaz ate the dopefish.

Ashen

I'm not sure what that error message means. When exactly does it pop up? (When you're first trying to create the script, when you've created it and are trying to access it for editing. Is it the script for the GUI - which your post implies - or for a TextBox object.) Also, if you're talking about the 'Edit script' button on the GUI editor - that's obsolete, you can ignore it. It linked to the (obsolete) interface_click function, and if you really WANT to use that, you can access it via the Global Script (ctrl-G and scroll down a bit, or get there directly through the 'Script' menu). Otherwise, double-clicking a GUI or GUI Control (TextBoxes, Buttons, etc) will open the editor to the proper point, once you've named them.

"TextBox" is a reserved word - AGS uses it (not surprisingly) in refering to the TextBox Control type (e.g. when making a pointer). Re-naming your TextBox object/GUI to something else will fix this. You can then use, for example, Parser.ParseText(myTextBox.Text) (where myTextBox is the script name of, um, your TextBox) to ready the text for Parsing.
(Note that all GUIs and GUI Objects must have unique names.)

V2.71 is the most recent version (although 2.72 is nearing release), that's most likely just a default message that doesn't quite apply in this case.
For an IF newsgroup/forum you might be better trying Google.

If you're still having problems post the code you're using (or trying to ;)), along with the names of the GUIs and Controls you've got.
I know what you're thinking ... Don't think that.

Khris

Here's a working example:

GUI "PARSER" & Textbox "command":


game_start:
Code: ags
#sectionstart game_start // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
Ã,  gParser.Visible=false; // turn it off
}
#sectionend game_start // DO NOT EDIT OR REMOVE THIS LINE


on_key_press:
Code: ags
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
Ã,  if (IsGamePaused() == 1) keycode=0;Ã,  // game paused, so don't react to keypresses
Ã,  if (keycode==17)Ã,  QuitGame(1);Ã,  Ã, // Ctrl-Q
Ã,  if (keycode==363) SaveGameDialog();Ã,  Ã, // F5
Ã,  if (keycode==365) RestoreGameDialog();Ã,  // F7
Ã,  if (keycode==367) RestartGame();Ã,  // F9
Ã,  if (keycode==434) SaveScreenShot("scrnshot.bmp");Ã,  // F12
Ã,  if (keycode==19)Ã,  Debug(0,0);Ã,  // Ctrl-S, give all inventory
Ã,  if (keycode==22)Ã,  Debug(1,0);Ã,  // Ctrl-V, version
Ã,  if (keycode==1)Ã,  Ã, Debug(2,0);Ã,  // Ctrl-A, show walkable areas
Ã,  if (keycode==24)Ã,  Debug(3,0);Ã,  // Ctrl-X, teleport to room
Ã,  
Ã,  // ******parser******
Ã,  if (keycode==361 && oldline!=null) { // F3 (retype last command)
Ã,  Ã,  command.Text=oldline;
Ã,  Ã,  gParser.Visible=true;
Ã,  }
Ã,  if (keycode==8 && command.Text=="") { // Backspace when empty -> turn off
Ã,  Ã,  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); // and insert the letter
Ã,  }
}
#sectionend on_key_pressÃ,  // DO NOT EDIT OR REMOVE THIS LINE


Textbox function (enter textboxes' name, then double-click it to get this):
Code: ags
#sectionstart command_ActivateÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function command_Activate(GUIControl *control) {
Ã,  gParser.Visible=false;
Ã,  oldline=command.Text;
Ã,  Display("%s", oldline);Ã,  // remove this line in the actual game
Ã,  // ******parse here******
}
#sectionend command_ActivateÃ,  // DO NOT EDIT OR REMOVE THIS LINE

SMF spam blocked by CleanTalk