我有这个代码,当玩家尝试吃东西时执行:
def eat(target='object'):
global current_room
global locations
global inventory
if target in inventory:
items[target]['on_eat'] #This is showing no results.
else:
print 'You have no ' + target + ' to eat.'
Run Code Online (Sandbox Code Playgroud)
和这个项目的代码(修剪)
items = {
'strawberry': {
'weight': 1,
'text': 'The strawberry is red',
'on_eat': "normal_eat('strawberry', 'pretty good, but not as sweet as you expected')"
},
'trees': {
'weight': 50,
'text': 'The trees are tall with large, leaf filled branches blocking out a majority of sunlight.',
'on_eat': "forcesay('Eating trees? What …
Run Code Online (Sandbox Code Playgroud)