Python Forum
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Game inputs skipping
#2
You really need a loop that keeps track of the state of the game. The format you are using is far too restrictive. For example, you can't open the glovebox until you try to open the car and fail. I would strongly suggest reading the text adventure tutorial linked to in my signature.

Also, the standard way in Python for case insensitive text matching is to use the lower method of the input string, which makes it all lowercase:

if userInput.lower() == 'leave car':
    # do stuff
The above code covers all three cases you have in your code. This allows to not repeat code. Repeating code is a bad idea, it is an invitation for bugs and inconsistencies.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Game inputs skipping - by Azazel - May-22-2017, 02:14 PM
RE: Game inputs skipping - by ichabod801 - May-22-2017, 02:40 PM
RE: Game inputs skipping - by Azazel - May-25-2017, 02:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  File loop curiously skipping files - FIXED mbk34 10 893 Feb-10-2024, 07:08 AM
Last Post: buran
  Skipping line in text without Restarting Loop IdMineThat 4 1,530 Apr-05-2022, 04:23 AM
Last Post: deanhystad
  python seems to be skipping lines of code alansandbucket 1 4,201 Jun-22-2021, 01:18 AM
Last Post: Larz60+
  Skipping Strings Kristenl2784 0 1,523 Jul-27-2020, 06:01 PM
Last Post: Kristenl2784
  looping for time while skipping a day Staph 2 2,217 Jun-23-2019, 03:33 AM
Last Post: Staph
  Skipping Loop blueriver649 4 2,851 Apr-18-2019, 04:11 AM
Last Post: blueriver649
  When I read csv file i am getting b'Skipping line messages GuJu 4 10,445 Mar-07-2019, 11:47 AM
Last Post: GuJu
  For loop question(skipping) jure98 1 2,488 Mar-31-2018, 01:54 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020