Text Parser

Started by ian80, Sun 20/03/2005 02:10:24

Previous topic - Next topic

ian80

Hi guys,

I want to make a text parser game. I've gotten the template v 1.1...but don't know where to go from here. Are there good, in-depth tutorials out there for me?

Also, is making a parser game going to entail a LOT more work? Because if it is a huge undertaking, I will probably never finish it.

Any help you can offer to a parser noob would be great!

Thanks,
Ian

magintz

#1
Using a text parser isn;t going to be a lot more work, all you will be doing is replacing the standard mouse commands with written ones. When you start off you need to begin by defining words you will use in the parser tab. It should already include words such as look, take etc... add your own if you want. It's been a while since I wrote the template and I don't even have a copy of it on my PC to help explain it, I'm sure someone else can lend a hand.

If you could e-mail me the template I'll try to update it this weekend.

edit: just got hold of the template. Best thing to do would be to open room 2 up and look at alll the code which is fully comented. It should help you get started. Try to learn to understand what it's doing with each line and why. If you want run the game and test it out. Also I just realised how badl laid out and explained the whole thing is, so i'll try to improve it ASAP, but I got exmas this week so I may have to put it on hold for a week or so.
When I was a little kid we had a sand box. It was a quicksand box. I was an only child... eventually.

ian80

Thanks a lot Magintz!

I am in no rush either, as I have exams now too. I'll start looking through the code and seeing if I can decifer it.

ian80

Okay,

I have a few questions:

1) With the template, the game starts with a loading screen...I don't want there to be options there, I just want it to be the main title. Then, when the player presses any key, the game with start...how would I go about doing this?

2) In the template, there is a period before the text space...is there a way toget rid of it. Also, preferable, I'd like the whole text area to just be black and for you writing to appear in white as you typed. Is this possible.

Thanks!

Ashen

1.
Turn off the options GUI (called START) by setting it's 'Visiblity' property to 'popup modal', and add scripting to do what you want:
Code: ags

function on_key_press (int keycode) {
  NewRoom (2); // or whatever your first room is
  ClaimEvent();
}

Add that somewhere at the top of the title screen's room script, and any keyboard press will take you to room 2, where the game starts.

2.
To clear the period, go to the GUI window, select the PARSER GUI, and clear the text (">>") from object 0 (a label). You could also delete the object, but then you'd have to update a lot of script, so it's easier to just clear the text.

To change the colour of the display, first select the textbox object (object 1) and change the text colour to what you want (white = 15). You may want to hide the border, as well. Then, deselect the textbox, and change the GUI's background colour (black = 16). That should be it - look up GUIs in the manual for move details on editing/creating them.
I know what you're thinking ... Don't think that.

ian80

#5
Thanks a lot Ashen! Worked perfect!

Now, is there a way I can rid of the box around the text? It seems to be paired up with the text, so if the text is white, so is the box.

magintz

You have to go into the GUI tab, choose what you want within the parser GUI (the broder) and then choose the colour, set it to 0 for clear. You can do the same with any of the objects within the gui
When I was a little kid we had a sand box. It was a quicksand box. I was an only child... eventually.

Ashen

Quote from: Ashen on Mon 21/03/2005 01:04:16
You may want to hide the border, as well.
See, I thought of that, I just didn't explain it very well.
The last option for the Textbox is 'Hide Border: No'.  Change that to 'Hide Border: Yes' to, well, hide the border
I know what you're thinking ... Don't think that.

ian80

Thanks again ashen!

Jeez, I really should have been able to figure that out on my own...so thanks for having the patience.

ian80

okay, next problem:

Is there a way to set up a global script for things you always want said in all rooms (ie, "eat self" -- it will always be the same). I tried, but just seemed to screw up the script, so I figure I am doing something wrong.

Also, as it stands, when I make a new room, the parser no longer works. Again, is this something that can be handled in the global script, or is there specific scripting that must be in each room?

Thanks

ian80

Hate to bump, but I can't really work on my game until I get my last questioned sorted out.

Thanks!

Ashen

1. To make global responses, add them to the interface_click command for the PARSER GUI. Should look something like:
Code: ags

if (interface == PARSER) {
  GetTextBoxText(PARSER,0,input); //This gathers the text from the text-box in GUI 0, and from Object1 and to store it in the predefined string "input"
  ParseText(input);

  if (Said("kill self")) { 
    Display("GAME OVER"); QuitGame(0); 
  }
  else if (Said("eat self")) { 
    Display("As you begin to devour your shoe you get a strange feeling that this may be quite hazzardous");
  }
  //Add more 'else if's for other responses
  CallRoomScript(1);
  SetTextBoxText(PARSER,0,""); 
}


2. Parser doesn't work in new rooms.
Have you added the on_call function to the new room's script? You need to add that to every room, to handle the room-specific responses to input.
I know what you're thinking ... Don't think that.

rich

Ok, I recommend not adding global responses the way Ashen describes it and I'll explain why (thanks to Rui Pires for helping me out with this one, check out his SQ2 template). The way the code is set up in Ashen's, the global parsing is done before room parsing. You actually should have room parsing take place before global parsing. Say in one room you want to have a specific response to if(said("eat self")) but in every other room, you want a generic response. You need to do room parsing FIRST for this to happen, otherwise the global response will always happen.

Check out Rui Pires' SQ2 template to see how this is done. Please note his NoMatch() function which is in the Global Script and then imported in the Script Header. It contains the Global Parses. It is called in on_call of a room script if no other matches are found.
I'm so excited!

SMF spam blocked by CleanTalk