character creation
weekendrockstar
15 Oct 2013, 06:25Hello!
I am a very new user of Quest and to authoring IF games in general. I've gotten a good start on my first one but decided that I really wanted to allow users to include their names as the main character's name to be included throughout the game when the main character is addressed as well as use their gender for proper pronouns,
I have been working with the character creation snippet from the QuestWiki and have attempted to make a few changes. I removed the "class" menu as this game does not use such an attribute. But where the original code asked for a player's name I wanted them to enter a first name and then a last name as both are used individually at different times.
Below is the code that was my last best guess which I've tried to correct both in code and with the GUI. I am VERY new to the code although I'd used several other 'languages' over the years but I couldn't figure this out using GUI either.
Running this will have the first two lines and it appears as if nothing happens when you enter a first name but then entering a last name will just double up the last name. When repeating the first name the second time it just prints "Welcome 'firstnamefirstname'".
Any and all help is greatly appreciated!
I am a very new user of Quest and to authoring IF games in general. I've gotten a good start on my first one but decided that I really wanted to allow users to include their names as the main character's name to be included throughout the game when the main character is addressed as well as use their gender for proper pronouns,
I have been working with the character creation snippet from the QuestWiki and have attempted to make a few changes. I removed the "class" menu as this game does not use such an attribute. But where the original code asked for a player's name I wanted them to enter a first name and then a last name as both are used individually at different times.
Below is the code that was my last best guess which I've tried to correct both in code and with the GUI. I am VERY new to the code although I'd used several other 'languages' over the years but I couldn't figure this out using GUI either.
msg ("Let's generate a character...")
msg ("Enter your first name:")
get input {
player.firstname = result
msg ("Hi, " + player.firstname)
msg ("Now enter your last name")
player.lastname = result
msg ("Welcome, " + player.firstname + player.lastname)
show menu ("Your gender?", Split ("Male;Female", ";"), false) {
player.gender = result
msg ("You are " + player.gender)
msg ("Now press a key to begin...")
wait {
ClearScreen
}
}
}
Running this will have the first two lines and it appears as if nothing happens when you enter a first name but then entering a last name will just double up the last name. When repeating the first name the second time it just prints "Welcome 'firstnamefirstname'".
Any and all help is greatly appreciated!

jaynabonne
15 Oct 2013, 07:42You need to have another "get input" after prompting for the last name to actually get the last name from the player:
msg ("Let's generate a character...")
msg ("Enter your first name:")
get input {
player.firstname = result
msg ("Hi, " + player.firstname)
msg ("Now enter your last name")
get input {
player.lastname = result
msg ("Welcome, " + player.firstname + player.lastname)
show menu ("Your gender?", Split ("Male;Female", ";"), false) {
player.gender = result
msg ("You are " + player.gender)
msg ("Now press a key to begin...")
wait {
ClearScreen
}
}
}
}
weekendrockstar
15 Oct 2013, 15:15Thank you! I had done something very similar but then it was telling me that i could use only one getinput per process. Maybe I nested them incorrectly. I just have two other little things going off of the suggested code:
1 - When I try to enter a first name and hit enter nothing happens. But doing it again will print the hello player.firstname message and goes on fine from there. I am just not sure why it does nothing the first time. I tried it a few times and each time the script did nothing upon first entering.
2. When printing welcome + player.firstname + player.lastname is there a way to put a space between the two names? I've seen on these forums that authors tend to use periods but set their font to the background color to make them appear as invisible and therefore look like spaces. I was just wondering if there were another way.
But thank you very much for at least making this process do as I intend
edit** I just tried again and for some reason it is now accepting the player.firstname and printing the hello message on the first attempt. Odd behavior haha So it looks like that kink is worked out!
I just tried the following as far as trying to separate the two names:
If that had worked I would have changed the font color of the period to match the background to make it appear as a space but this throws a runtime error. I am used to doing similar things with PHP as far as mixing 'variables' and specified text throughout a string like this but Quest doesn't like it.
1 - When I try to enter a first name and hit enter nothing happens. But doing it again will print the hello player.firstname message and goes on fine from there. I am just not sure why it does nothing the first time. I tried it a few times and each time the script did nothing upon first entering.
2. When printing welcome + player.firstname + player.lastname is there a way to put a space between the two names? I've seen on these forums that authors tend to use periods but set their font to the background color to make them appear as invisible and therefore look like spaces. I was just wondering if there were another way.
But thank you very much for at least making this process do as I intend

edit** I just tried again and for some reason it is now accepting the player.firstname and printing the hello message on the first attempt. Odd behavior haha So it looks like that kink is worked out!
I just tried the following as far as trying to separate the two names:
msg ("Welcome, " + player.firstname "." + player.lastname)
If that had worked I would have changed the font color of the period to match the background to make it appear as a space but this throws a runtime error. I am used to doing similar things with PHP as far as mixing 'variables' and specified text throughout a string like this but Quest doesn't like it.

jaynabonne
15 Oct 2013, 15:30You missed a '+':
msg ("Welcome, " + player.firstname + "." + player.lastname)
weekendrockstar
15 Oct 2013, 15:42Ahh I wasn't sure whether the '+' was explicitly for variable names...now I see how it is properly used. However I am running into the following:
I shall keep trying to mess with it. I do greatly appreciate the help. The way that I generally best learn a new 'language' is to create first and then look at the code to see what I am actually doing by code. So I am hoping that by the time I create my second game I will be using mostly code except, perhaps, for new elements that I want in that game that aren't in this first one.
Error running script: Error compiling expression 'resultmsg ("Welcome, " + player.firstname + "." + player.lastname)': FunctionCallElement: Could find not function 'resultmsg(String)'
I shall keep trying to mess with it. I do greatly appreciate the help. The way that I generally best learn a new 'language' is to create first and then look at the code to see what I am actually doing by code. So I am hoping that by the time I create my second game I will be using mostly code except, perhaps, for new elements that I want in that game that aren't in this first one.

jaynabonne
15 Oct 2013, 15:53I don't know what "resultmsg" is. It should just be "msg". Seems you have an unexpected "result" there. 

weekendrockstar
15 Oct 2013, 16:13My unexpected result was the code not working haha Figured it out though. I accidentally appended your msg code line directly to the end of the player.lastname = result line. I'm hanging my head in shame! But thank you good sir, you get a gold star from me today!
I actually went one better than my initial thought for creating the space. Since I'd recently learned roughly how much of the Quest system deals with HTML I changed my code to:
Works like a charm! Thank you!
I actually went one better than my initial thought for creating the space. Since I'd recently learned roughly how much of the Quest system deals with HTML I changed my code to:
msg ("Welcome, " + player.firstname + " " + player.lastname)
Works like a charm! Thank you!
HegemonKhan
16 Oct 2013, 01:02getting the syntax correct for message scripts with text and attributes in it, is annoyingly hard to learn in getting the + and " symbols' placement correct.
I have a post somewhere that tries to explain how to do it right (and understand it)... not really interested in trying to look for it though myself, lol.
I have a post somewhere that tries to explain how to do it right (and understand it)... not really interested in trying to look for it though myself, lol.