Suppose that the player can enter a name for EGO, is there a way to have this name (character[EGO].name) show up in dialogs or in dialog options?
I recommend storing the player-entered name in a global variable, and calling that:
// global variable playername stores player's name
player.say("My name is %s", playername);
Quote from: WHAM on Mon 09/05/2011 09:06:17
player.say("My name is %s", playername);
That's not a dialog, though.
Putting a space before the command inside the dialog should work.
Edit: I didn't read carefully, and I don't think you can include variables directly in the dialog lines, you'd have to use a script command to display the text with variable content.
I also misunderstood, but shouldn't something like this work:
@1
player.say("My name is %s", playername);
I just got the idea from an earlier thread where Studio3 was trying to use SayAt commands in dialogue and this was offered to him as a solution by Barefoot:
@1
cDave.SayAt(8, 167, 320,"Dave: I like waffles.");
Sorry if I was unhelpful here, I haven't used the dialogue system much. =(
EDIT: To clarify, if I understand this correctly, the idea and t he only way is to replace the dialogue text by a script command like Sepiroth said above.
Yeah, I figured as much. That would mean writing my own "select answer" GUI, too.
Maybe you could create a function that will "fill" the textbox/label used for speech instead of the classic lines 'player: "blah"' then you would replace these lines with your own display function, this would not work for dialog options tho, and I don't see how you could dynamically change the dialog options text, unless you have, once again, your own dialog options display function.
Even the 'DialogOptionsRenderingInfo" doesn't have a .SetOptionText(int optionId);
Actually there's no technical reason that if you're using the custom dialog rendering that you couldn't just do a replace for custom tags before writing the text onto the DrawingSurface:
function dialog_options_render(DialogOptionsRenderingInfo *info)
{
// Clear the area yellow
info.Surface.Clear(14);
int i = 1, ypos = 0;
// Render all the options that are enabled
while (i <= info.DialogToRender.OptionCount)
{
if (info.DialogToRender.GetOptionState(i) == eOptionOn)
{
if (info.ActiveOptionID == i) info.Surface.DrawingColor = 13;
else info.Surface.DrawingColor = 4;
String optionText = info.DialogToRender.GetOptionText(i);
optionText = optionText.Replace("%PLAYERNAME%", player.Name);
info.Surface.DrawStringWrapped(5, ypos, info.Width - 10, eFontFont0, eAlignLeft, optionText);
ypos += GetTextHeight(optionText, eFontFont0, info.Width - 10);
}
i++;
}
}
With that (and of course the rest of the custom rendering functions in-place), you could type %PLAYERNAME% into a dialog option (in the editor) and it would be replaced in-game with the player's name. If you compare the above example to the one in the manual (which I copied :P) the only difference is that I store the current option text and then use String.Replace to replace the custom tag. With this you could create any custom tag. You could even create variable tags like:
String needle = "%CHARNAME:"; // full tag is %CHARNAME:CHARID% where CHARID is the Character.ID
int index = optionText.IndexOf(needle);
while (index != -1)
{
String buffer = optionText.Substring(index + needle.Length);
int end = buffer.IndexOf("%");
buffer = buffer.Truncate(end);
int charID = buffer.AsInt;
optionText = optionText.Replace(optionText.Substring(index, index + needle.Length + end), character[charID].Name);
index = optionText.IndexOf(needle);
}
I haven't actually tested this, but the basic principle applies.
Oh, and WHAM, I wanted to point out that Character.Name is writable, so there's no need to create a separate variable for it.
Quote from: monkey_05_06 on Mon 09/05/2011 16:40:21
Oh, and WHAM, I wanted to point out that Character.Name is writable, so there's no need to create a separate variable for it.
Oh, goot to know!