Write the Story
Write the Story
After the player answers all of the questions, they’ll get to see their answers combined with the story. The story will also be stored in a variable using strings and then be combined with the strings holding the player’s answers.
Code the First String
- Make sure the playtest is stopped.
- Go back to the script by clicking on the StoryManager script tab above the game editor.
Reopening the Script
If you don’t see the script editor tab, you can re-open it by double-clicking on StoryManager in the Explorer window.
- Beneath where you typed the question, create a new variable named
story. Make sure the variable name is lowercase.
-- Code story between the dashes -- ============================================= local name1 = storyMaker:GetInput("What is your favorite name?") local story
- To find the first string, go back to the original story. Circle or highlight everything before the first placeholder. If your variable happens to be in the middle of a sentence, no problem - the rest can be added later.
|In a tree on a hill, lives the great wizard name1.|
- Have the
storyvariable store the string like below:
-- 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 "
Tipps zur Problemlösung
- Remember that
local storyneeds to be lowercase because other parts of the game are looking for a variable with that exact name.
- The code will only show what you tell it to, so include a space at the end so the strings don’t run together like below:
"In a tree on a hill lives the great wizard "