I've recently undertaken making a text-based game to try and assist myself with learning and applying skills in python coding. I've recently reached a roadblock in trying to work with a "look" command. I currently have it working without arguments where it will display the detailed description of the room the player is in, but I'm trying to expand the function to accept arguments for when the player is trying to look at an NPC (currently they exist in the same class as the player), or if there were to be an object on the floor once I implement inventories, looking at the item for more details about it. Any assistance would be helpful!
I tried to turn the user's input into a variable that gets checked against a few options. When I realized I needed to have some of the commands with arguments, I used a startswith() string function on the look section, but the argument seems to get bypassed even if one gets put in that matches one of the "players." Here is the code for the look function and the action function that passes the input onto the look function:
def look(target = "None"):
if target == player:
if player.location != myPlayer.location:
print ("There's no one like that here to look at.")
else:
text = textwrap.wrap(target.desc, width=70)
for line in text:
print (line)
elif target == "None":
text = textwrap.wrap(zonemap[myPlayer.location][EXAMINATION], width = 70)
for line in text:
print (line)
else:
print ("What are you trying to look at?")
start_action = input ("< " + str(myPlayer.name) + ", " + str(myPlayer.hp) + "/" + str(myPlayer.maxhp) + "hp >")
prompt = start_action.lower()
look_action = prompt.startswith('look')
elif look_action == True:
os.system('cls')
look()
action()`