the text box

Started by Terrorcell, Wed 22/08/2007 23:01:01

Previous topic - Next topic

Terrorcell

Im trying to use the code btnSavegame.Enable = true;.
I wanted to know what the code for a text box is. e.g. txtSavegame.Enable = true; or something.

Khris

There's no special prefix for GUI objects; that's just sometimes used in the manual to distinguish between objects better.

Just use the scriptname you entered in the top of the properties window.

Ashen

Also check your spelling - it'd be txtSavegame.Enabled, not txtSavegame.Enable.

What was the problem, or had you not tried?
I know what you're thinking ... Don't think that.

Terrorcell

Sorry, I have another problem.
When I try to use this code, it doesnt work:
Code: ags
  if (player.Room==4) 
  if (Parser.Said("use [the] helm controls")) {
  character[EGO].Walk(144, 145);
  while (character[EGO].Moving) Wait(1);
    character[EGO].FaceLocation(character[EGO].x - 50, character[EGO].y);
    Display("Close the controls after you are finished.");
    gTextbox.Visible = true;
    gHelmcontrol.Visible = true;
    GT.Enabled = false;
    LT.Enabled = false;
    XT.Enabled = false;
    YT.Enabled = false;
    engineT.Enabled = false;
    Display("Now I must type in the co-ordinates for G and the others!");
  }
  if (player.Room==4) 
  if (Parser.Said("enable controls")) {
    GT.Enabled = true;
    LT.Enabled = false;
    XT.Enabled = false;
    YT.Enabled = false;
    engineT.Enabled = false;
    gTextbox.Visible = false;
  }    
  if (player.Room==4) 
  if (Parser.Said("103.6")) {
    Display("Good. Now for L.");
    GT.Enabled = false;
    LT.Enabled = true;
    XT.Enabled = false;
    YT.Enabled = false;
    engineT.Enabled = true;
  }
  if (player.Room==4) 
  if (Parser.Said("790.0")) {
    Display("Good. Now X.");
    GT.Enabled = false;
    LT.Enabled = false;
    XT.Enabled = true;
    YT.Enabled = false;
    engineT.Enabled = true;
  }
  if (player.Room==4) 
  if (Parser.Said("473")) {
    Display("Ok. Now Y.");
    GT.Enabled = false;
    LT.Enabled = false;
    XT.Enabled = false;
    YT.Enabled = true;
    engineT.Enabled = true;
  }
  if (player.Room==4) 
  if (Parser.Said("502")) {
    Display("Excellent. Now I must start the engines. I think ill start on 15.");
    GT.Enabled = false;
    LT.Enabled = false;
    XT.Enabled = false;
    YT.Enabled = false;
    engineT.Enabled = true;
  }
  if (player.Room==4) 
  if (Parser.Said("15")) {
    Display("Sir! Thrusters are at fifteen percent and we are on a course to Verdania!");
    GT.Enabled = false;
    LT.Enabled = false;
    XT.Enabled = false;
    YT.Enabled = false;
    engineT.Enabled = false;
    gTextbox.Visible = true;
    gHelmcontrol.Visible = false;
  }

This is the GUI that Im using.


When I type 'enable controls' it enables 'G' but if I type '103.6' or '103' it doesnt enable any of the others. I dont know why.
I want to know what changes have to be made to fix this.

Khris

Please show the line in which you are calling "Parser.ParseText(command);", best together with the function it's contained in.

Also, putting a single
Code: ags
  if (player.Room==4) {
  
    ... // parsing

  }

around the whole stuff is enuff.

Recluse

The only problem I see with this is that the player could very easily type: "15" and automatically get to the end of the sequence.

Also, make sure you've added all the strings to the parser. I've recently worked with the parser in 2.8 and it won't let you save until this is done, but I'm not sure if that's the case with the version you're using.

What KhrisMUC said is that before you call any Parser.Said functions you must first call Parser.ParseText.

If you're only calling Parser.ParseText once, and it's not called each time the player enters various commands, there will be problems with ALL of your code.
All your verbcoin are belong to us.

Terrorcell

QuoteThe only problem I see with this is that the player could very easily type: "15" and automatically get to the end of the sequence.
Yes but the player wont know that, im already planning on fixing that.
QuoteAlso, make sure you've added all the strings to the parser. I've recently worked with the parser in 2.8 and it won't let you save until this is done, but I'm not sure if that's the case with the version you're using.
Im using 2.72 still. I havnt got 2.8.
QuoteWhat KhrisMUC said is that before you call any Parser.Said functions you must first call Parser.ParseText.

If you're only calling Parser.ParseText once, and it's not called each time the player enters various commands, there will be problems with ALL of your code.
Do you mean at the beggining of every Parser code?

Ashen

Quote
Do you mean at the beggining of every Parser code?

Whenever you 'get' the text to be checked - so it'd either be the Activate functions for the TextBoxes, or the Click function for a Button if you 're doing it that way. Where exactly is the code you posted, and how is it called?

Quote
Yes but the player wont know that, I'm already planning on fixing that.
I wouldn't rely on the player supposedly not knowing something. Even if they're not trying to cheat, it's too easy for them to enter something out of sequence and get tangled up. The easiest way, if you weren't sure how to fix it, would probably be to just add a check of which box is currently active, e.g.:
Code: ags

  if (Parser.Said("103.6") && GT.Enabled == true) {
    Display("Good. Now for L.");
   // ...
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk