Using dialogue scripts without options?

Started by Noto, Wed 24/02/2016 04:58:00

Previous topic - Next topic

Noto

For organization and convenience, I strongly prefer to keep a lot of my character's interaction in dialogue script. I don't have any options programmed, and strictly have a @S and "stop" at each end of the interaction (which holds several regular game codes as well). However, it seems that they don't work that way, as any time I've tried to launch the game it would always give me an error of "Nested functions not supported". It gives me no particular line, and instead points to the entire dialogue script. This perplexed me for several hours, because there's nothing wrong with the code itself.  It also seemingly did this to only one of my dialogue scripts, and not the others. It was only after deleting it did I see then that it had the same issue with the others too, just didn't say it.

My question is this: Is there a work-around to being able to use dialogue scripts in such a way? My game is almost exclusively based around character interaction, so having to use "cCharacter.Say" codes for everything would be extremely tedious.

Danvzare

#1
Hmm, I can't fathom what the problem is, because having no dialog options certainly works for me.

The test code I'm using is as follows:
Code: ags
// Dialog script file
@S  // Dialog startup entry point
ego: "I am very happy today because it's my birthday."
cChar1: "No you're not!"
ego: "Yes I am!"
stop


and in the talk interaction of a character I made:
Code: ags
dDialog0.Start();


It works without a problem. So unless your code doesn't conform to that standard in some way, it should work.
Unless... you haven't got multiple starts and stops do you? Like this:
Code: ags
// Dialog script file
@S  // Dialog startup entry point
ego: "I am very happy today because it's my birthday."
stop

@S  // Dialog startup entry point
ego: "I'm very sad today because it's not my birthday."
stop

@S  // Dialog startup entry point
ego: "I'm dead."
stop


Because AGS doesn't work like that. You can only have one start and one stop in each dialog script. Otherwise the program won't know where to begin.

If you post the code for one of these non-working dialog scripts of yours, I should be able to point out the problem much quicker. :)
Although right now, I'm starting to think that maybe you've been using functions to move the characters around and do things, inside the dialog scripts. Which if you have, well... there's your problem.

Crimson Wizard

#2
Quote from: Noto on Wed 24/02/2016 04:58:00It gives me no particular line, and instead points to the entire dialogue script. This perplexed me for several hours, because there's nothing wrong with the code itself.
It would be nice if you could show the example of such dialog script.


Quote from: Danvzare on Wed 24/02/2016 09:24:19
Although right now, I'm starting to think that maybe you've been using functions to move the characters around and do things, inside the dialog scripts. Which if you have, well... there's your problem.

You are allowed to do common script commands in dialog scripts, if you indent them by a space, e.g.
Code: ags

@S  // Dialog startup entry point
ego: "I am very happy today because it's my birthday."
 cEgo.Walk(100, 50);
stop

Danvzare

Quote from: Crimson Wizard on Wed 24/02/2016 10:30:22
You are allowed to do common script commands in dialog scripts, if you indent them by a space.

Oh, thanks for that. You learn something new everyday. :-D

Khris

I remember somebody else having a similar problem, and it turned out there was an unclosed multi-line comment in one of the dialog scripts that screwed up everything.

The basic idea is fine and should work as expected; one could even use a single dialog script for several interactions by turning on the relevant option before calling .Start() (and setting AGS up to auto-select it if there's only one active option).

Noto

Thank you so much, everybody. This was such a bizarre problem, and even as I was posting it I had doubts of whether this issue was really stemming from where I thought it was.

I'm really relieved to hear at the very least that it *should* be working fine and as intended normally. That explains why I didn't have any luck searching threads on it.

Quote from: Danvzare on Wed 24/02/2016 09:24:19
If you post the code for one of these non-working dialog scripts of yours, I should be able to point out the problem much quicker. :)
Although right now, I'm starting to think that maybe you've been using functions to move the characters around and do things, inside the dialog scripts. Which if you have, well... there's your problem.

I do have regular code in them, but as Crimson noted they're indented. As for showing an example, I was tentative to provide an example because every single interaction is very long and very intimate in regards to characters in the game. But for the sake of figuring out what's wrong, it's probably best I do it anyway.

Code: ags

// Dialog script file
@S  
   if (Desktop) {
Shane: You're finally ready now?
Will: Yes, Shane, I'm finally ready. 
   }
   
   
Will: And... What?
Will: You want to hear an explanation?
  Wait(30);
Will: Honestly, I wouldn't know where to start.
Shane: A formal introduction may help.
Shane: Although we know each other well enough, don't we?
Will: Sure... I'll go with it.
Shane: Let's start with your name.
Will: Will.
Will: Will Rivlain.
Shane: Your age now?
Will: I'm 26 years-old.
Shane: Why are you here in my office now, Will?
Will: Because I have to be.
  Wait(40);
Will: Because I... Relapsed.
Shane: Why did you relapse?
Will: Because I couldn't cope.
Will: I still can't.
  Wait(120);
Will: I'm sorry, I'm just getting my thoughts together.
  
    if (Fantasy == false) {
Shane:  We don't really need to do this right away. Do you need some time to walk around a bit?
  Wait(10);
  Triedonce = true;
  dExtratime.Start();
  
    }
    
    
    if (Fantasy) {
Shane: If you're really not up for starting yet, maybe you should take some more time to clear your head.
    dExtratime.Start();
    Triedonce = true;
  
    }

 
  if (TherapTalk == 1) {
  

Will: God...
  Wait(20);
Will:  Okay...
  Wait(20);
Will: Okay.
Will: You probably see lots of different patients.
Will: You see, from my vantage point, there are also different kinds of junkies.
Will: There are the kind that live on by spur-of-the-moment nirvana highs and rock-bottom lows.
Will: There are those who go up slow and go down even slower.
Will: But once they hit the bottom, the only way to go is further down.
Will: So they go lower.
  Wait(50);
Will: And... They die.
Will: Some die croaking.
Will: Some go without a peep.
Will: In a bitter fuckin' silence...
  Wait(120);
Will: Some go out in not-so-loving company.
Will: And some... Completely alone.
Will: It really sucks, you know?
Will: It's fucking sad.
  Wait(40);
Will: It's... So sad...
  Wait(120);
Will: It's so sad...
// Play video here.
  Wait(120);
Will: You know... I hate talking about myself.
Shane: It doesn't seem that way... From where I'm sitting.
Shane: But that's not a bad thing, believe me, Will.
Will: No, no, I know.
Will: You're right.
Will: I just say I don't because I'm insecure about it.
Will: The truth is I love talking about myself.
Will: And I love talking about people like me.
Will: Because I'm not speaking for me.
Will: I'm speaking for me, and my brother.

Shane: The one who... Passed away?

Will: Who else?
Will: 'The one who passed away', hell.
Will: Yes, Shane, the one who passed away.
Will: He died alone, unloved, depressed, in silence.
Will: He was that kind of junkie!
Will: And if he was still here... He would tell you the same thing.
Will: He would tell you just how stupid this all this.
Will: Yeah, there are different 'kinds' of us, but it's all fucking absurd.
Will: Because, still, we're all the same.
Will: We're a guilty species, the whole lot of us.
Will: Everyone I have vehemently referred to as a 'junkie' was once free.
Will: But somewhere in his or her life they decided they didn't want that.
Will: For one reason or another, they didn't want their life.
Will: But they don't want to die.
Will: So they decide to live like puppets.
Will: They give their life away thinking the drugs know how to live it better than they do.
Will: With synthetic joy and hope.
Will: It's a deadly sin, for many.
Will: Being addicted is being under voluntary possession.
Will: That's what I believe.
Will: And that's why I relapsed.
Will: I didn't want to be Will anymore.
Will: I wanted to be free again.

 Wait(40);

Shane: Do you still not want to be 'Will'?
Will: I don't know.
Will: I don't fuckin' know.
Will: I certainly don't want to live Will's life, that's for sure.

 Wait(40);

Shane: Why not?
Will: Because Will's exhausted all his options.
Will: He lives a hell.
Will: And I worry about him.
Will: When I use, I feel sorry for him.
Will: And I thank God I'm not him.

 Wait(120);

Shane: You don't have to be the kind of person you're picturing, Will.
Will: When I'm without hope.
Will: When I've become the flailing puppet.
Will: When my only comfort comes from knowing that I am closer to death.
Will: Then, I do.

 Wait(40);

Will: Either way, there's my explanation.
Shane: Well, Will...
Shane: Would you like to know what I think?

Will: I do.
Will: Go ahead.

Shane: I think there's hope for you, Will. I sincerely believe there is.
Shane: There are people here that can help you, I have no doubt of that.
Shane: It's exactly as you say. There are many others like you, and they are all suffering.
Shane: But that's okay, you're anything but alone.
Shane: Very many of them don't die. Many of them recover, and go on to live prosperous and fulfilling lives.
Shane: I believe you are more than capable of doing that as well, Will.

 Wait(200);

Will: Well...

 Wait(120);

Will: Thank you...

 Wait(120);

Will: Thank you...
  
  }
  
stop


So, knowing now there should be no problem at all with the actual dialogue script handling a script with no options, I started a new game and put that exact script in, but took out all the "If" statements as the new game had none of the variables I set in the real one. It seemed to work perfectly, so this leads me to believe there's an issue somewhere in the "If" statements, although I don't see any, and the script if I recall seemed to run fine in the actual room script versus the dialogue script. Very odd.

Crimson Wizard

#6
The general issue is that when AGS compiles dialog scripts, it gathers all of them together and converts them into a huge normal script, where one dialog follows another. IIRC the dialogs are "wrapped" into functions themselves.
So, if you have a non-matching IF brackets somewhere in the middle of random dialog, that will break all of them.

I would propose to make a copy of your game, and in that copy just start deleting dialogs one by one until compilation succeeds. That may be the fastest way to at least find out which dialog has a mistake.

As for looking for the mistake inside a dialog, you may try deleting every line except those containing { / } brackets, then count latter down.

jwalt

I'm curious about the color change following his apostrophes? I'm not seeing that in my one and only dialog tree. It almost looks like it's seeing those as comments?

Crimson, is it worth asking for a block comment delimiter (as in /* and */ )? It would help tracking down lines with problems. Or is there already something that comments out a bunch of code without the // before every line?

Crimson Wizard

Quote from: jwalt on Thu 25/02/2016 00:36:09
I'm curious about the color change following his apostrophes? I'm not seeing that in my one and only dialog tree. It almost looks like it's seeing those as comments?
That might be error in how this forums do syntax highlight for ags scripts. This has little relevance to actual AGS comments.


Quote from: jwalt on Thu 25/02/2016 00:36:09
Crimson, is it worth asking for a block comment delimiter (as in /* and */ )? It would help tracking down lines with problems. Or is there already something that comments out a bunch of code without the // before every line?
/**/ is already supported in normal scripts, but I do not remember about dialog scripts.

jwalt

#9
Quote from: Crimson Wizard on Thu 25/02/2016 00:43:34
/**/ is already supported in normal scripts, but I do not remember about dialog scripts.

Just played with it, and indented, it looks like the block delimiters will also work in dialog. Didn't compile it, but it changes the color of the lines between them. I appreciate the info. Thanks.

Edit: I notice a couple of calls, in Noto's code (35, 42), to other dialogs without the goto stuff. Are his calls an alternate way to do it?

Edit2: I'm getting suspicious about the comment in line 76. It may need to be indented like the script commands are. Might be wrong, and probably should be keeping my mouth shut about stuff I know next to nothing about.

Noto

Quote from: Crimson Wizard on Thu 25/02/2016 00:17:55
The general issue is that when AGS compiles dialog scripts, it gathers all of them together and converts them into a huge normal script, where one dialog follows another. IIRC the dialogs are "wrapped" into functions themselves.
So, if you have a non-matching IF brackets somewhere in the middle of random dialog, that will break all of them.

I would propose to make a copy of your game, and in that copy just start deleting dialogs one by one until compilation succeeds. That may be the fastest way to at least find out which dialog has a mistake.

As for looking for the mistake inside a dialog, you may try deleting every line except those containing { / } brackets, then count latter down.

This makes a lot of sense, and this looks like the best way of going about trying to fix it. I'll be going ahead and doing that then, I appreciate it!

Thanks everyone!

Crimson Wizard

Quote from: jwalt on Thu 25/02/2016 01:15:22
Edit: I notice a couple of calls, in Noto's code (35, 42), to other dialogs without the goto stuff. Are his calls an alternate way to do it?
Oh, I missed that.
It must be noted that it won't work in AGS, unfortunately. Second dialog cannot start while first one is going on.
What will happen instead will be: the current dialog script will be continue running, and the called dialog will start only when the first one ended.
If you try starting several dialogs in a row, only first called one will play (after current one is finished).

The solution could be, possibly, to reorganize this dialog contents into several dialogs called one after another.
I do not think there is a difference between doing "goto-dialog" (dialog script command) and dDialogName.Start() (normal script command).
In any case such commands should be the last command performed in the script.

Noto

Quote from: jwalt on Thu 25/02/2016 01:15:22
Edit: I notice a couple of calls, in Noto's code (35, 42), to other dialogs without the goto stuff. Are his calls an alternate way to do it?

Edit2: I'm getting suspicious about the comment in line 76. It may need to be indented like the script commands are. Might be wrong, and probably should be keeping my mouth shut about stuff I know next to nothing about.

Sorry, I missed these! I haven't actually got to testing that far to see if those (35, 42) work, but as Crimson points out later, now that I think about it they almost certainly won't. And, I don't think there's any problem with line 76, as far as I know.

Quote from: Crimson Wizard on Thu 25/02/2016 07:02:30
Oh, I missed that.
It must be noted that it won't work in AGS, unfortunately. Second dialog cannot start while first one is going on.
What will happen instead will be: the current dialog script will be continue running, and the called dialog will start only when the first one ended.
If you try starting several dialogs in a row, only first called one will play (after current one is finished).

The solution could be, possibly, to reorganize this dialog contents into several dialogs called one after another.
I do not think there is a difference between doing "goto-dialog" (dialog script command) and dDialogName.Start() (normal script command).
In any case such commands should be the last command performed in the script.

I'm really glad you picked this up! I'll be looking for a fix to it.

SMF spam blocked by CleanTalk