
你几乎已经 完成了项目! 剩下的就是完成第一句话,然后添加另一个问题,让玩家有更多选择。
完成句子
要向句子添加更多单词或句点,使用连接添加另一条字符串。
在故事变量的同一行上,输入 ..
添加包含句子剩余部分或仅仅是句号的另一条字符串。不要忘记在句子结尾添加额外空格。
-- 贯穿逗号之间的代码故事-- =============================================local name1 = storyMaker:GetInput("What is your favorite name?")local story = "In a tree on a hill lives the great wizard " .. name1 .. ". "-- =============================================
添加第二个问题
要提出第二个问题,创建一个新问题,并继续添加到同一个变量中保留故事。
决定要从故事的第二句话中删除哪个单词。
原始占位符: 每天早上,巫师喜欢吃一大碗蜂蜜烤熟的食物 food1 。
在第一个变量之下,创建一个新变量来作为占位符。
local name1 = storyMaker:GetInput("What is your favorite name?")local food1local story = "In a tree on a hill lives the great wizard " .. name1 .. ". "使用 storyMaker:GetInput("") 向玩家提问并存储答案。
local name1 = storyMaker:GetInput("What is your favorite name?")local food1local story = "In a tree on a hill lives the great wizard " .. name1 .. ". "在故事变量中,使用 .. 将下一个故事字符串连接在一起,确保包含句子结束后的空格。
local name1 = storyMaker:GetInput("What is your favorite name?")local food1 = storyMaker:GetInput("What is your favorite food?")local story = "In a tree on a hill lives the great wizard " .. name1 .. ". " .. "Every morning, the wizard loves eating a giant bowl of honey roasted "在新故事字符串之后,连接第二个问题的答案并加上句号完成。
local name1 = storyMaker:GetInput("What is your favorite name?")local food1 = storyMaker:GetInput("What is your favorite food?")local story = "In a tree on a hill lives the great wizard " .. name1 .. ". " .. "Every morning, the wizard loves eating a giant bowl of honey roasted " .. food1 .. ". "
可选添加内容
如果您对发展故事更感兴趣,我们包含了一些想法。例如,改进故事的一些方法包括:
- 为你的故事添加更多线条
- 每次添加新的变量和字符串时,都要进行游戏测试
- 向同行或朋友询问他们想要自定义的其他词。
此外,以下是一些 提示和技巧 ,用于为玩家制作有趣的故事。
使用变量超过一次
变量可以多次使用 — 只需在包含单词(s)的地方使用字符串之间的连接即可。 示例代码 : "I am " .. name1 .. " and you are in the palace of " .. name1 .. "!" 结果 : 我是 Sameth ,你在 Sameth 的宫殿里!
添加行间距
通过在字符串中输入 \n 来添加行间分隔符。还可以像 \n\n 一样将多个行间分隔符组合在一起。 示例代码 : "One \n Two \n\n Three" 结果 :
一
两个
三