So for my first big python project I'm building a text based game. It's supposed to be modular so the story and items etc. can be edited and replaced with little editing of the actual source code. Basically, the user command is stored as a string which is immediately broken into a list. The first element is an action like 'inspect' and the second element is a pseudo-argument for that action like 'location' or 'item'. After the command is interpreted, it goes to the execution module called 'item_or_loc' It's here that I get the error. Can anyone help? I'll provide more info or the entire source code if it'll help.
Command module:
def item_or_loc(iolo):
if iolo in items.items_f():
print (items.iolo(1))
elif iolo in locations.locations_f():
print (locations.iolo(1))
else:
print ('Command not recognized, try again.')
def location(loco):
plo_l = PlayerClass #(player location object_location)
if loco == 'location':
plo_l.player_loc(0)
def abort(abo):
sys.exit()
def inventory(invo):
pio_i = PlayerClass #(player inventory object_inventory)
if invo == 'inventory':
pio_i.player_inv(0)
Items module:
patient_gown=('Patient gown', 'A light blue patient\'s gown.')
wrench=('Wrench','')
stick=('Stick','')
prybar=('Prybar','')
screwdriver=('Screwdriver','')
scalpel=('Scalpel','')
broken_tile=('Broken tile','')
hatchet=('Hatchet','')
janitor_suit=('Janitor suit','')
Locations module: Basically the same as the Items module
Player module:
import items
import locations
class PlayerClass:
def player_inv(inv_index):
pinventory = [items.patient_gown[inv_index]]
print (pinventory)
def player_loc(loc_index):
ploc = [locations.cell[loc_index]]
print (ploc)