我一直在看renpy关于如何做出选择的教程,大部分情况下,除了一件小事之外,我都弄明白了。在
如何正确使用elif语句? 我查过基本的python elif语句,甚至还有一个关于如何在renpy中使用一个的实际站点,但是我无法让它工作。在
(我附上了我的代码截图和我的错误,任何帮助都非常感谢)
下面是我的代码片段:
define e = Character("???")
$ mage = False
$ warrior = False
$ archer = False
# The game starts here.
label start:
# Show a background.
scene bg black
# This shows a character sprite.
show weird orb
# These display lines of dialogue.
e "Welcome human, what is your name?"
python:
name = renpy.input(_("What's your name?"))
name = name.strip() or __("John")
define m = Character("[name]")
e "Hmm, [name] is it?"
e "That's a wonderful name!"
m "Where am I?"
e "You'll know in good time, my child."
e "For now, tell me a bit about yourself"
menu:
e "Which of these do you prefer?"
"Magic":
jump magic
"Brute Force":
jump force
"Archery":
jump archery
label magic:
e "You chose magic."
$ mage = True
jump enter
label force:
e "You chose brute force."
$ warrior = True
jump enter
label archery:
e "You chose archery."
$ archer = True
jump enter
label enter:
if mage:
m "I'm a mage."
elif warrior:
m "I'm a warrior."
else:
m "I'm an archer"
return
以下是错误的副本:
^{pr2}${1美元^
您的代码给了您一个异常,因为这三行永远不会运行:
它们不会运行,因为它们出现在
start:
标签的上方,这是代码开始运行的地方。在有几种方法可以解决这个问题。一种方法是简单地重新排列代码,使
^{pr2}$start
标签出现在这些行的上方。另一个选择是对每个赋值使用default
语句:当游戏开始和游戏加载时,
default
语句将运行一次,但前提是变量尚未定义。在相关问题 更多 >
编程相关推荐