Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
#632785 22/10/17 06:58 AM
Joined: Jun 2013
addict
OP Offline
addict
Joined: Jun 2013
Is there a way to pass variables in dialogs ?

Like, "You have <xNumberLeft> left to bring me before quest completion"
or "Hello, <Name>"


Un chemin de 1000 lieues commence par un premier pas.

Project:
Steam workshop Frontiere
Joined: May 2017
enthusiast
Offline
enthusiast
Joined: May 2017
What you want are dialog variables. You create them in the dialog variable menu (inside the dialog editor), then assign them values once dialog has started:
Code
IF
DialogStarted("LLAB_Dialog_Settings", _Instance)
AND
DialogGetInvolvedPlayer(_Instance, 1, (CHARACTERGUID)_Player)
AND
CharacterGetDisplayName(_Player, _Handle, _Ref)
THEN
DialogSetVariableStringForInstance(_Instance, "AutoBags_CharacterName_400b56ed-9303-4af7-a905-eedec3ff528b", _Ref);

You use the dialog variable GUID (much like root templates) to specify what variable to set. The dialog variables themselves have a few different value types. Notice I used the "set for instance" function version. I assumed this is just so it applies only to this specific dialog instance, and not all of them (so other players won't see this character's name by default). There's another version of the same method that just sets it in the dialog file as a whole.

To finally use the variable, you insert the dialog variable GUID into text inside the dialog node, enclosed in brackets:
Code
Welcome [AutoBags_CharacterName_400b56ed-9303-4af7-a905-eedec3ff528b]!


Here's another example from an official script (RC_BI_ThePresence_Contract.txt):
Code
IF
DialogStarted("RC_BI_DwarfDemonTrader",_DlgInst)
AND
DB_RC_BI_DwarfDemon_Bet(_Bet)
THEN
DialogSetVariableInt("RC_BI_DwarfDemonTrader","GEN_CheckPocketGold_SpeakerIndex_8504b4e0-886e-4912-9525-fbe559c5f8ff",2);
DialogSetVariableInt("RC_BI_DwarfDemonTrader","GEN_CheckMagicPocketGold_6057ad05-9492-4630-9f0a-be548b134c54",_Bet);

Joined: Jun 2013
addict
OP Offline
addict
Joined: Jun 2013
Crap, amazing, you rock, thank you so much.


Un chemin de 1000 lieues commence par un premier pas.

Project:
Steam workshop Frontiere
Joined: May 2017
enthusiast
Offline
enthusiast
Joined: May 2017
Your question has great timing, as I just figured this out today, haha. grin I was wondering the same thing this week (wondering how to pass external values into dialog text).

Dialogs can also have "script variables". Not sure what those are all about yet.

Joined: Mar 2016
Location: Belgium
T
addict
Offline
addict
T
Joined: Mar 2016
Location: Belgium
I've just finished transcribing our internal documentation of the dialog editor. Both dialog variables and script variables are explained there now.

Joined: May 2017
enthusiast
Offline
enthusiast
Joined: May 2017
Nice, thank you.

Though, looking at it briefly, one thing that seems missing is how you actually use the variables (once you create & set them). I didn't see anywhere mentioning that you can place the variable UUIDs inside brackets, inside a node's text, to display the value. A simple mention of the usage would probably clear some future confusion.

Joined: Mar 2016
Location: Belgium
T
addict
Offline
addict
T
Joined: Mar 2016
Location: Belgium
Good point, added.

Joined: Jun 2013
addict
OP Offline
addict
Joined: Jun 2013
Thanks a lot, so useful, cheers


Un chemin de 1000 lieues commence par un premier pas.

Project:
Steam workshop Frontiere

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.5