Jump to content


Photo

Noob question about writing dialogue in .d


  • Please log in to reply
5 replies to this topic

#1 Vakarian89

Vakarian89
  • Member
  • 54 posts

Posted 28 September 2021 - 05:26 AM

I try to write my first dialogue in .d for first Baldur's Gate (classic, not EE) and I have a noob question. I could just try it out in the game, but I haven't gotten far enough yet to making .cre files or compiling dialogues, so I'd rather ask for your help. Namely, is the first script below good or is it must be done the way it's done in the second one?

 

First script

IF ~~ THEN BEGIN 0
  SAY ~Heya.~
  IF ~~ THEN REPLY ~Yo.~ GOTO 1
END
 
IF ~Gender(Player1,MALE)~ THEN BEGIN 1
  SAY ~See ya.~  
  IF ~~ THEN EXIT
END

IF ~Gender(Player1,FEMALE)~ THEN BEGIN 1
  SAY ~Goodbye.~  
  IF ~~ THEN EXIT
END

 

Second script

IF ~~ THEN BEGIN 0
  SAY ~Heya.~
  IF ~Gender(Player1,MALE)~ THEN REPLY ~Yo.~ GOTO 1
  IF ~Gender(Player1,FEMALE)~ THEN REPLY ~Yo.~ GOTO 2
END
 
IF ~~ THEN BEGIN 1
  SAY ~See ya.~  
  IF ~~ THEN EXIT
END

IF ~~ THEN BEGIN 2
  SAY ~Goodbye.~  
  IF ~~ THEN EXIT
END


#2 Gwendolyne

Gwendolyne
  • Staff
  • 994 posts

Posted 28 September 2021 - 07:37 AM

2d one. ;)


CARPE DIEM ....
 

In progress : Menace sur le Royaume de Diamant Éternel there.

#3 Vakarian89

Vakarian89
  • Member
  • 54 posts

Posted 28 September 2021 - 09:53 AM

Thank you, Gwendolyne. I thought that myself, 'cause I didn't find anything like my first script in any mod I have checked. But why exactly the first script won't work? I have no problem in using the second solution, but it would be nice to know why the first one isn't good.



#4 jastey

jastey
  • Staff
  • 2525 posts

Posted 28 September 2021 - 11:48 AM

Your 1st example doesn't work because every state needs an own number. There can't be two states with the number "1". I understand what you are trying to do, but the correct syntax is the 2nd example.

If a dialoge state has a state trigger, it can be called by a script. That's what the state trigger is for. If you want to have the diffrenciation inside a dialogue, you need to go the different paths according to the transaction triggers, like it is in your 2nd example.

Just a hint: I would not give the states numbers but names. The installer will number the states upon install. But in your d-file, I recommend naming the states something that makes reading them easier, like

IF ~~ THEN BEGIN first_greeting
  SAY ~Heya.~
  IF ~Gender(Player1,MALE)~ THEN REPLY ~Yo.~ GOTO reply_male
  IF ~Gender(Player1,FEMALE)~ THEN REPLY ~Yo.~ GOTO reply_female
END
 
IF ~~ THEN BEGIN reply_male
  SAY ~See ya.~  
  IF ~~ THEN EXIT
END

IF ~~ THEN BEGIN reply_female
  SAY ~Goodbye.~  
  IF ~~ THEN EXIT
END


 



#5 Vakarian89

Vakarian89
  • Member
  • 54 posts

Posted 29 September 2021 - 10:18 AM

@jastey

Thank you very much for a clear, easy to understand answer! Bit of a shame that it can't be done the way I was trying to, but it's nothing critical. As for your suggestion to name states and not to number them, I was thinking about it from the start. But knowing me, I would spend more time thinking about how to name those states appropriately than creating/scripting dialogues. :lol:



#6 jastey

jastey
  • Staff
  • 2525 posts

Posted 29 September 2021 - 09:54 PM

Hahaha! You could always go with something like dlgname_1 etc. I still think it's better than to work with numbers inside the d-file, but that's just me.