我有一个函数作为教程游戏的一部分。如果条件满足(如果对象==“代码”),则有问题的功能应触发另一功能函数不调用另一个函数
# right room
def right_room():
print "You see a table with two objects: a map and a code translator"
print "You can take one object"
print "Which object do you take?"
next = raw_input("> ")
if "map" in next and "code" in next:
dead("You're greed surpassed your wisdom.")
elif "map" in next:
print "OK, you have the map."
theobject = "map"
print "Now you must exit and go ahead"
return theobject
opening()
elif "code" in next:
print "OK, you have the code."
theobject = "code"
print "Now you must exit and go ahead."
return theobject
opening()
但是打开不被称为?这里是输出:
你在Labrynthe。你左边有一扇门。你的权利 有一个门。或者你可以继续。
right你看到一个包含两个对象的表:一个地图和一个代码翻译器你可以带一个对象你拿哪个对象? 代码确定,你有代码。现在你必须退出并继续。然后
上面的函数是指人在送他们回到起点和提示输入“超前”,在终端:
# opening scene
def opening():
print "You're in a Labrynthe."
print "There's a door on your left."
print "There's a door on your right."
print "Or you can go ahead."
next = raw_input("> ")
if "right" in next:
right_room()
elif "left" in next:
left_room()
elif "ahead" in next:
ahead()
else:
print "Which way will you go?"
但开口()没有被调用。相反,Python似乎完成脚本并退出。
您在调用该函数之前使用'return' ...返回后的任何内容都未执行 – Jeribo
'next'是python中的内置函数。你可能会考虑将你的变量重命名为别的东西('next_'是一个可行的选择) – SethMMorton