How can you let the player choose the names of their character?

archerqueen08
15 Jan 2018, 04:51Hi so at the beginning of the game I want to let the player choose what they want to be called but I don't know how and also in the game there will be NPCs calling the player's name so how do I make the name that the player chooses show up there. Thanks

K.V.
15 Jan 2018, 05:13Hello,
This should help you:
http://docs.textadventures.co.uk/quest/guides/character_creation.html

archerqueen08
15 Jan 2018, 13:27Hi I read the guide and I sort of get it now (I'll just copy the thing they did there lol) but I couldn't find where they tell you how to let the text in the game include the name the player chooses? If it did I probably didn't understand it lol

archerqueen08
15 Jan 2018, 14:33It works for the first time I ask that, but if I try in a different part of a game for example, it doesn't work. So it's supposed to go something like this
Whats your name?
(Player types name)
Welcome so and so!
(So and so enters first room, where a message is printed right after entering)
So and so, you have a letter!
(Player opens letter)
Dear So and so blahblahblahblah
Yeah so I can make the welcome part go right but not the rest. Help?

K.V.
15 Jan 2018, 15:08Try using {player.alias}
, entered with the brackets in a text field.
msg ("Hi, {player.alias}.")

archerqueen08
16 Jan 2018, 04:56Ahh it works now! Thanks!!
hegemonkhan
16 Jan 2018, 05:21KV's method uses the 'text processor commands', see here:
http://docs.textadventures.co.uk/quest/text_processor.html
but, you can also use normal scripting too, an example:
msg ("Hi, " + player.alias + ".")
for more detailed guide on using Attributes and the 'if' Script:
http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk
ask if you got any questions

K.V.
16 Jan 2018, 05:29Is there a way to do this without the code?
(from another thread by archerqueen08)
I believe the problem was with the "Print" dropdown setting.
You need to switch it from "message" to "expression" when using this method:
"Hi, " + player.alias + "."
hegemonkhan
16 Jan 2018, 13:51KV's right (forgot to explain '[MESSAGE]' vs '[EXPRESSION]' for the GUI/Editor's script options):
if you're doing it the normal scripting way, then you need to use the '[EXPRESSION]' script option:
print [EXPRESSION] "Hi, " + player.alias + "."
if you're using the 'text processor commands', than I think you can also use the '[MESSAGE]' with it:
print [MESSAGE] Hi, {player.alias}.
// or how'd you use the '[EXPRESSION]' script option and the text process command, together:
print [EXPRESSION] "Hi, {player.alias}."
this is an ERROR however (because the '[MESSAGE]' is for TEXT ONLY, and also text processor commands too):
print [MESSAGE] "Hi, " + player.alias} + "." // ERROR !!!!
the '[EXPRESSION]' let's you do any combination:
- TEXT ONLY:
print [EXPRESSION] "Hi, my name is HK."
- VARIABLE ONLY:
// player.alias = "HK"
print [EXPRESSION] player.alias
- TEXT and VARIABLE:
// player.alias = "HK"
print [EXPRESSION] "Hi, my name is " + player.alias + "."
the '[MESSAGE]' ONLY let's you do TEXT (unless you use a text processor command):
print [MESSAGE] Hi, my name is HK.
// player.alias = "HK"
print [MESSAGE] "Hi, my name is " + player.alias + "." // ERROR !!!!!
// player.alias = "HK"
print [MESSAGE] Hi, my name is {player.alias}.