UevKF8zjRV_WEtpJsXhr
We use cookies on this site to enhance your user experience

Adding to the Story

5 min

Adding to the Story

Combine the Story and Answer

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 ..

  1. 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 " ..
  1. 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.

  1. Under the second dashed line, find storyMaker:Write(). Between the (), type the variable story. 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.


  1. Playtest the game. You should see the two strings combined together.

Finish Your Sentence

To add more words or punctuation to the sentence, add another string.

  1. On the same line as the story variable, add another ..
  2. 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 .. ". "