Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use commands again without copy and pasting them?
    text
    copied!<p>I don't really know how to explain this exactly.. But I'm making a text adventure for learning the basics. Now I want to make a gold and money system, I am using def... things for different levels and such. but in every prompt I have to put in if the user types gold, or inv it shows the inventory and then go back to the def where it was.. which I find irritating to do every time. And I forget it too at some periods. I want to do it as default in the prompt. I have a def prompt(): that is this easy code:</p> <pre><code>def prompt(): x = input('Type a command: ') return x </code></pre> <p>and if I put it there it just ends the code. I have to do this in every prompt:</p> <pre><code>def AlleenThuis(): command = prompt() if command == '1': print() elif command == '2': print() elif command == '3': print() elif command == '4': print() elif command == 'geld': #Actions start here print('\n\tYou have ' + str(gold) + ' euro. RICH BOY BRO!.\n') print() return AlleenThuis() elif command == 'inv': if not inv: print("\n\tYou don't have any items..\n") return AlleenThuis() else: #The else has to stay in this place because it's part of the 'if not inv:' guys. print('\n\t' + str(inv) + '\n') return AlleenThuis() #Actions end here </code></pre> <p>So if there's any way to just implement it so that I don't have to put it in again every time that would be awesome! Thanks.</p> <p>EDIT: It looks like you guys aren't understanding what I'm saying, so I have 2 images. So.. <strong><a href="http://i.imgur.com/GLArsyu.png" rel="nofollow">http://i.imgur.com/GLArsyu.png</a></strong> (I can't post pictures yet =[ )</p> <p>As you can see in this picture, I have included gold and inv. But in <strong><a href="http://i.imgur.com/V3ZhJ36.png" rel="nofollow">http://i.imgur.com/V3ZhJ36.png</a></strong> I have also done that, so I have coded that in the code again, that is what I Don't want! </p> <p>I just want to have that in the code 1 time, and let the gold and inventory show all the time when the player enters the commands for them!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload