Hi,
Another noob question. All the answers I find are either too basic (how to create a plain dialog) or too advanced, like creating custom GUIs to display a certain way...
My question: How can I create an option inside a dialog that uses a game variable?
I have a Buy/Sell dialog that I want to use in more than one store. So I want my numbered dialog options (on the left) to be: "I want to buy *string variable*"
Thanks.
I'm pretty sure that you *do* have to use custom dialog rendering and insert the item's name into the String that's drawn to the Dialog GUI's surface.
So I can't just use dBuySell(1)=something or dBuySell.Text(1)=something ?
I can customize the replies on the right side easily, but not the options on the left?
Thanks.
The ScrollingDialog module (http://www.adventuregamestudio.co.uk/forums/index.php?topic=27930.0) has this feature built-in:
Quote from: monkey0506 on Mon 31/07/2006 06:33:57One really cool feature that the module includes is dialog option tagging. What that means is that you can create a custom tag that you will later replace with some other text, such as a character's name. You tell the module what you want to replace the tag with (using ScrollingDialog.SetTag), and then when the dialog options are drawn, the module will handle it for you!
cPet.Name = "Spike";
ScrollingDialog.SetTag("%PETNAME%", cPet.Name);
Then if you have a dialog option set to "My dog's name is %PETNAME%." (for example), then the text would be displayed as "My dog's name is Spike.".
There is also a built-in tag for the player name (ScrollingDialog.PlayerNameTag), which is always replaced with the current player name. This will save you from having to change the tag if you change the player, as it will always stay up-to-date with the current player character.
NOTE: If you are using a tagged dialog option, you should always leave the Say check-box unchecked. The module can't overwrite the actual dialog option text, so if the player reads that option, they would end up saying the original text, as set up in the editor. If you want the player to read that option, then instead include a line such as this in your dialog script:
// dialog script
@S
return;
@1 // My dog's name is %PETNAME%.
player.Say(ScrollingDialog.SelectedOption.Text); // say "My dog's name is Spike."
return;
This will ensure that the dialog tags are replaced appropriately.
You would simply call ScrollingDialog.SetTag when you needed to update the value, such as:
ScrollingDialog.SetTag("%BUYSELL%", "something");
The "tag" can be any text, just make sure it's something unique that wouldn't normally appear in your dialog option text.
Quote from: MistrrW on Sat 17/12/2016 02:17:54I can customize the replies on the right side easily, but not the options on the left?
Pretty much, yes.
But a dialog isn't the only way to implement a shop; one could always use a normal GUI and Buttons instead. Button text works just like you want it to:
btnBuy1.Text = String.Format("Buy a %s", inventory[3].Name);
Monkey0506:
I put
ScrollingDialog.SetTag("%BUYSELLOPTION%", "Hi");
Into the game_Start function (just as a test), and I get:
Undefined token 'ScrollingDialog'
What am I missing?
ScrollingDialog is the name of a script module I wrote. Script modules have to be imported into your game (see the manual (http://www.adventuregamestudio.co.uk/manual/index.html?page=ags37.htm#scriptmodules)). If the script has been imported to your game, you have to make sure that the ScrollingDialog script is above the script where you're using the module functions in the Scripts tree.
That said, Khris' suggestion about using an alternative may be an easier approach if this is the only thing you need it for.
Gotcha.
Ok, thank you both very much.
I will get to work designing some GUIs then.
I appreciate your time and I love that this board is here.
Chris