我正在創建一個基於文本的冒險遊戲。該角色正在導航由城市街區組成的地圖。我有一個direction_function
需要raw_input
,然後將字符移動到正確的相鄰塊。不過,我擁有特殊功能,例如要在大部分區塊中選取或與人互動。這裏我也使用raw_input
。如果他們輸入了正確的關鍵字,但是如果他們通過輸入方向忽略它們,則會將它們傳遞到direction_function
,這會再次提示他們輸入raw_input
。有沒有辦法將他們的初始答案傳遞到direction_function
,以便他們不必重複他們的答案?蟒蛇繞過raw_input傳入其他raw_input
這裏是我的direction_function:
def direction_function(left, right, up, down, re):
direc = raw_input(">")
if direc in west:
left()
elif direc in east:
right()
elif direc in north:
up()
elif direc in south:
down()
elif direc in inventory_list:
inventory_check()
re()
else:
print "try again"
re()
我指定的函數像這樣
def block3_0():
print "You see a bike lying in your neighbor's yard. Not much else of interest."
direc = raw_input(">")
if direc in ("take bike", "steal bike", "ride bike", "borrow bike", "use bike"):
print "\n"
bike.remove("bike")
school_route()
else:
direction_function(block2_0, block4_0, block3_1, block3_0, block3_0)
你能發表一些代碼嗎?只有相關部分,不一定全部對話。 –