Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Dannymac247 on Fri 29/05/2015 22:51:35

Title: (Solved) Turning Dialog options on and off
Post by: Dannymac247 on Fri 29/05/2015 22:51:35
Another case of "I can't figure out what I'm doing wrong." I found another thread here where someone asked what I think was the same question back in 2009, and found an answer, but they never said what precisely they were doing wrong. Something about a return. Anyway...

Below is the complete script for a dialog I am writing. Only the first option is selected as "See" and "Say," everything else is Say only, needing to be activated first.

The idea is that the first time the player talks to this character, they begin with option one, and then have a choice between options 2-5. Then, after picking one of those options, the dialog ends, and if they talk to that character again, they only have option 6 available.

It isn't working, and I'm not sure why. As an experiment, I switched every "stop" in options 2-5 to "return". Within the context of one dialog, it SEEMS to be working, in that you open with option one, have a choice from options 2-5, and then finish with option 6. But when you talk to that character again, you once again open with option one, and then have choices of 2-6! That last bit is really confusing me... there is nothing in option 1 that can activate 6, so if 6 is simply being activated and left on, shouldn't it be there as an option, along with option 1, at the start of the conversation?





Code (ags) Select

// dialog script file
@S  // dialog startup entry point
@1  // option 1
ego:Are you watching me?
paint: Of course. You didn't think this was a room we felt needed decorating, did you?
option-off-forever 1
option-on 2
option-on 3
option-on 4
option-on 5
return
@2  // option 2
paint: Amusing. Joking, even when on the verge of panic. Perhaps he was right in his choice.
Ego: He? He who?
paint: Patience, young one. You'll meet him soon enough. Until then, might as well make yourself comfortable.
option-on 6
option-off 2
option-off 3
option-off 4
option-off 5
stop
@3  // option 3
paint: Alas, I cannot. I never have quite gotten the knack of opening doors. You'll just have to wait until he comes.
ego: He? He who?
paint: Trust me, you'll meet him soon enough.
option-on 6
option-off 2
option-off 3
option-off 4
option-off 5
stop
@4  // option 4
paint: Ah, yes. Such an observant young mind. I see why he chose you.
ego: You mean the one who brought me here. Who is he?
paint: I'm afraid it is not to me to give you the answers you seek. Ponder the puzzle while you wait... you'll meet him soon enough.
option-on 6
option-off 2
option-off 3
option-off 4
option-off 5
stop
@5  // option 5
paint: Or what? You'll yell at me? Throw something at me? CRY?
ego: I'm warning you. You won't get away with this.
paint:Such spirit! No wonder he chose you. Watch that temper, however. He does not approve of tantrums.
ego: Who is he? Tell me!
paint: No.
Narrator: He laughs.
paint: But do keep threatening me. It will help pass the time.
option-on 6
option-off 2
option-off 3
option-off 4
option-off 5
stop
@6  // option 6
paint: I don't think I will, actually. Watching you is much more fun.
ego: Great.
stop


Solution found! In the above code, the "start" text (marked by @s) requires a return command. Thank you, Khris and Snarky!
Title: Re: Turning Dialog options on and off
Post by: Dannymac247 on Fri 29/05/2015 23:14:38
Here (http://www.adventuregamestudio.co.uk/forums/index.php?topic=38543.msg508178#msg508178) is the link to the previous post I was talking about, in case that is helpful.
Title: Re: Turning Dialog options on and off
Post by: Khris on Fri 29/05/2015 23:44:57
You're missing the "return" after @S:

@S  // dialog startup entry point
return
@1
...


I'm not really sure why things get screwed up like that if you don't have the "return", but adding it fixed it for me.

(And please always state how the code fails, don't just tell us it isn't working. And don't double-post, you can edit your posts.)
Title: Re: Turning Dialog options on and off
Post by: Snarky on Fri 29/05/2015 23:47:05
I'm not very well versed in the AGS dialog system, but I suspect what's happening here is what we call "fall-through": When the conversation starts, it plays @S, but because that section doesn't have anything (not even a stop or return command), it moves right on to @1. And when it runs @1 it turns on options 2-5. I think you should put anything that goes into the start of the conversation (before any dialog options) under the @S label, and be sure to put in the "return".

(Edit: As Khris says.)

You could probably achieve what you describe with a lot of code, but if the second time you talk to him the conversation and the dialog option(s) are completely different, shouldn't it simply be a separate dialog? So the first time you speak to him, it launches the first dialog, and subsequent times it launches the second. You can script this quite easily like so:

Code (ags) Select
if(Game.DoOnceOnly("First talk to painter"))
{
  // run the first dialog
}
else
{
  // run the second dialog
}
Title: Re: Turning Dialog options on and off
Post by: Dannymac247 on Sat 30/05/2015 00:29:51
Got it, thanks. Works now! I'll also stick to edits instead of double posting, and try to be more informative of the problem, in the future. Thank you for your patience!