Adding to the Story
Adding to the Story
Next, the first string of the story needs to be combined with the player’s answer. Combining things together is called concatenation. To combine the two strings together, use ..
- On the same line as the
story
variable, type..
while playing do storyMaker:Reset()   -- Code story between the dashes -- =============================================   local name1 = storyMaker:GetInput("What is your favorite name?")   local story = "In a tree on a hill lives the great wizard " ..
- Still on the same line, type the name of the variable holding the player’s answer.
while playing do storyMaker:Reset()   -- Code story between the dashes -- =============================================   local name1 = storyMaker:GetInput("What is your favorite name?")   local story = "In a tree on a hill lives the great wizard " .. name1
Write the Story and Playtest
Now that the story is typed, it needs to be shown to players.
- Under the second dashed line, find
storyMaker:Write()
. Between the()
, type the variablestory
. This tells the program to write the story in the game.
while playing do storyMaker:Reset()   -- Code story between the dashes -- =============================================   local name1 = storyMaker:GetInput("What is your favorite name?")   local story = "In a tree on a hill lives the great wizard " .. name1   -- =============================================   -- Add the story variable between the parenthesis below storyMaker:Write(story)
Check Your Work
Make sure that you’ve typed story
in the line storyMaker:Write(story)
and the capitalization is exactly like the code box. Without this step, the story won’t appear when you playtest.
- Playtest the game. You should see the two strings combined together.

Troubleshooting Tips »
If the question is not being asked, check that:
- The question is inside of quotation marks.
If the story is not combining together, check that:
- The first part of the story is inside of quotation marks.
- The name of the variable holding the player answers matches exactly. Capitalization counts!
- The name of the variable holding the player’s answer is not inside of quotation marks.
- The two strings are separated by
..
If you can’t see your story appear:
- Make sure that that you’ve typed the
story
variable between the()
instoryMaker:Write()
Finish Your Sentence
To add more words or punctuation to the sentence, add another string.
- On the same line as the story variable, add another
..
- Add another string containing the rest of the sentence, or just punctuation. Don’t forget to add an extra space at the end of the sentence.
-- =============================================   local name1 = storyMaker:GetInput("What is your favorite name?")   local story = "In a tree on a hill lives the great wizard " .. name1 .. ". "
Previous Write the Story Next Add a Second Question