Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Sat 26/02/2011 19:03:27

Title: DoDialog options turned off error... what causes this?
Post by: barefoot on Sat 26/02/2011 19:03:27
Hi

I'de like to clear one major point...

what i generally want to know is the causes of the DoDialog options turned off error... I seem to be getting it... If I know some possible reason i can check.

Can GUI's, even though switched invisible cause Dialog problems?

cheers

barefoot
Title: Re: DoDialog options turned off error... what causes this?
Post by: Khris on Sat 26/02/2011 19:19:57
What are you referring to by "DoDialog"?

Please tell us the exact error message, verbatim.
Title: Re: DoDialog options turned off error... what causes this?
Post by: barefoot on Sat 26/02/2011 19:22:55
Hi Khris

it's that old chestnut..  after doing a dialog with options (3 in all) 2 return and 1 stop.. it all looks correct in the dialog window.. the game starts it then crashes..

It displayed: DoDialog options turned off error

I have not added any other settings...

Im wondering if lower GUI is to blame even though its turned off???

Now I'm getting that funny picture thing with my character image on near the top of the screen.. as with a pervious post.. this is very strange to say the least..

The dialog works fine, its just the look and its in a smallish box..

I tried in a new game and its ok..

If I can't solve this maybe i can work around it with a gui with buttons and questions with conditions for anyone they pick???

barefoot
Title: Re: DoDialog options turned off error... what causes this?
Post by: Khris on Sat 26/02/2011 21:56:08
I was able to produce this error

Error: DoDialog: all options have been turned off

by starting a dialog with all its Show boxes unchecked; obviously, AGS can't display a Dialog with all its option turned off. That's what the error message tells you right there, btw, so the problem is you're either doing the same as I did or are turning off (an) option(s) right after @S in the dialog script.
Title: Re: DoDialog options turned off error... what causes this?
Post by: Ryan Timothy B on Sun 27/02/2011 02:35:13
Quote from: Khris on Sat 26/02/2011 21:56:08
by starting a dialog with all its Show boxes unchecked; obviously, AGS can't display a Dialog with all its option turned off.
I personally think this should be looked as a glitch. The Dialog should just close if their are no options on.
As I don't believe there is any way to close a dialog without doing it within Dialog_Request (that I know of).


If one had a dialog with 2 options, and no matter the order the player selects them in, each option would turn off and return. How would you close the dialog after all options had been selected?

The only thing I can think of is running: run-script 1 (1 being the dialog number), then within the Dialog_Request check if all dialog option are turned off, then close the dialog. Of course you'd have to check the number being passed to the Dialog_Request to see if it's below the actual Dialog count to prevent it from crashing.

Is this the only way?
Title: Re: DoDialog options turned off error... what causes this?
Post by: Khris on Sun 27/02/2011 02:41:26
Maybe StopDialog() can be used inside a dialog script? Didn't test it.

I guess, you could put a space (" ") in a third option, uncheck Say and make that stop the dialog.
Title: Re: DoDialog options turned off error... what causes this?
Post by: Ryan Timothy B on Sun 27/02/2011 04:49:38
Nope. Trying StopDialog within a dialog was the first thing I tried.

The empty dialog line actually works though. I never did think of trying that. But don't use a space, it will actually display that dialog line in the list. It doesn't display blank lines though since there is no height for an empty string so it won't leave spacing. And the space you can click.

But like i said, the dialog should close whenever all the options are turned off.
I imagine the only reason it aborts the game when all options are turned off, is that CJ saw a dialog with no options on, as something programmers should avoid. But from what I've gathered by scouring the manual, there is little way of avoiding this in situations like I've mentioned above, without doing the blank dialog option.
Title: Re: DoDialog options turned off error... what causes this?
Post by: monkey0506 on Sun 27/02/2011 08:57:21
Nevermind, that doesn't work! :=

I thought perhaps you could wrap the stop/return keyword in a conditional..but that drives the compiler insane, regardless of how you try to do it.

Probably the best thing would be to simply allow the StopDialog function to be called directly within a dialog script.
Title: Re: DoDialog options turned off error... what causes this?
Post by: Dualnames on Sun 27/02/2011 14:38:02
Eh, maybe using a conditional? Checking the states of a dialog and returning a boolean value?


The Function you need to check if a dialog option is on

bool IsDialogOptionOn(this Dialog*) {
int b=1;
bool check=false;
while (b!=this.OptionCount) {
if (this.GetOptionState(b) == eOptionOn) check=true;
b++;
}
return check;
}


Declare the function

import bool IsDialogOptionOn(this Dialog*);


How to use:

if (dialogscriptnamegoeshere.IsDialogOption()) {//if there is any option that is on
//do sth here
}



In your case
//On the dialog script preferably on @S
if (!dialogscriptnamegoeshere.IsDialogOption()) stop; // or dialogscriptnamegoeshere.StopDialog();


If you still get an error before the @S even starts, then just use a conditional on the where you call the StartDialog.

Title: Re: DoDialog options turned off error... what causes this?
Post by: Ryan Timothy B on Sun 27/02/2011 15:07:46
Dualnames, you can't run stop within a dialog.

The only solution, like I mentioned above (other than using the blank dialog option with a stop, that Khris mentioned), would be to check the dialog of the number you pass through run-script. Because the Dialog_Request function is the Only way I know of that can stop a dialog.

Basically this:

// Dialog script file
@S  // Dialog startup entry point
return
@1
option-off 1
run-script 8
return
@2
option-off 2
run-script 8
return

8 would have to be the dialog number. It would probably be better to import the dialog_request into the Global script header so that you can do: dialog_request(dDialiog.ID);  instead of  run-script, in case you delete a dialog it would cause issues.

Then within your dialog request in the global script:

function dialog_request(int param)
{
  if (param < Game.DialogCount)
  {
    int i = 1;
    bool stop;
    while (i <= dialog[param].OptionCount && !stop)
    {
      if (dialog[param].GetOptionState(i) == eOptionOn) stop = true;
      i++;
    }
    if (!stop) StopDialog();
  }
}


Of course you'd have to change any run-script commands you have.
Unless there is a way in the dialog_request to find out what dialog is currently running, but I can't seem to find anything in the manual. That would be a little better than passing the dialog number through run-script.
Title: Re: DoDialog options turned off error... what causes this?
Post by: Khris on Thu 03/03/2011 22:31:42
By sheer accident I discovered this in the manual today:

QuoteIf you want to conditionally break out of the dialog script, the special tokens RUN_DIALOG_GOTO_PREVIOUS, RUN_DIALOG_RETURN and RUN_DIALOG_STOP_DIALOG are available which you can return from inside a script block. For example:


@1
ego: "Hello. How are you?"
narrator: The man looks you in the eye.
  if (player.HasInventory(iKey)) {
    player.Say("Actually, I'd better go.");
    return RUN_DIALOG_STOP_DIALOG;
  }
otherman: "Here's a key for you."
return
Title: Re: DoDialog options turned off error... what causes this?
Post by: Ryan Timothy B on Fri 04/03/2011 03:56:55
That's crazy. I've honestly checked out that section more than once, but never really read past the dialog command list.
CJ's done an amazing job with the manual so far, but it definitely needs to be updated. It's not very user-friendly when it comes to searching up some stuff.

I haven't tested if it works yet, but I'm assuming it does.
Title: Re: DoDialog options turned off error... what causes this?
Post by: monkey0506 on Fri 04/03/2011 08:02:05
Well I searched the manual and it looks to me as if it only ever references it under:

Contents > Tutorial > Setting up the game > Conversations > Using scripting commands in dialog

It appears that within dialog scripts you can also use the this keyword to reference the currently running dialog..neat! :D

I do agree that certain points with regard to how the way the manual is organized can actually make it harder to find information like this. For example, I think that it would be important to have information like this in the same place as where the Dialog (struct) functions and properties are listed at..but with the current organization those pages list only the functions and properties associated directly with the struct (with the exception of certain things like the "Game / Global functions" section, or the "Multimedia functions" section).

I think largely the information is there, but in some cases, particularly like this one, the organization scheme can actually make it difficult to find.
Title: Re: DoDialog options turned off error... what causes this?
Post by: Dualnames on Fri 04/03/2011 15:58:25
Quote from: Khris on Thu 03/03/2011 22:31:42
By sheer accident I discovered this in the manual today:

QuoteIf you want to conditionally break out of the dialog script, the special tokens RUN_DIALOG_GOTO_PREVIOUS, RUN_DIALOG_RETURN and RUN_DIALOG_STOP_DIALOG are available which you can return from inside a script block. For example:


@1
ego: "Hello. How are you?"
narrator: The man looks you in the eye.
  if (player.HasInventory(iKey)) {
    player.Say("Actually, I'd better go.");
    return RUN_DIALOG_STOP_DIALOG;
  }
otherman: "Here's a key for you."
return

That means we all deserve a RTFM, said to us.  ;)