Python Forum
how to make a hotkey for text adventure game
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to make a hotkey for text adventure game
#1
So I'm trying to make this sort of "map" key for the player to press to change their location. But I don't want to manually put in the code for every outcome I put in. I was wondering for any advice In how to make a hotkey.

NOTE: I'm a beginner just learning python so yeah I don't know much.
Reply
#2
Is it safe to assume you are using python's native "input()" function? If you post your code it will be easier to find a solution. The basic idea would be to write some kind of mapping function that runs if input is ever a certain character. You won't have to code for every outcome, you code how the computer decides the result of the function.
Reply
#3
name = input("Hello, Welcome to Quest Sim! Please enter your name!")
print('hello' + name)
instructions = input('Before we begin, I reccomend reading the instructions to understand how this game works press I. if you know how to play the game, press N')
if instructions == 'I':
instructions = input('Quest Sim is a word based game. that means you have to give commands when you start the game,'
'everytime their is a "" around certain words. it means its a interable command you can use.'
'just type the command to use the action. Press "Y" to return')
elif instructions == "Y" or instructions == "N":
input("The world depends on you to find the three keys to seal the darkness! to start your quest please press M")



M = str(['Beach, Mines, Town, Mansion, Home'])
x = input(m + "Select a location!")
computer = randint(0,1)
player = 3
siren = 1
if x == 'Beach':
choice1 = input("Welcome to the Beach, here lies a vast ocean fulled of critters, big and small."
'On your "Right" lies a pus fulled trail full of dead seagulls alongside the coast.'
'On your "Left" you find a injured person gasping for breath.'
'Or we can return to map to view other locations. What do you do?.')
if choice1.lower() == 'Right':
choice2 = input('You followed the trail, the stench being unable until the trail suddenly ends. You find a wild siren. you can "observe" or try to "attack" the siren. What do you do?')
if choice2 == 'Observe':
action1 = input("You notice the siren wearing a necklace around her neck, it's one of the keys of darkness!"
'it also appears that the siren is trying to sleep. there could be a small chance to "steal" the necklace from without confrontation. Worst case is that you will have to "fight"')
if action1 == 'steal':
if computer == 1:
input("You successfully took the necklace and with it the key!")


Here is my code, it's still a work in progress.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I make a game save? BliepMonster 6 1,473 Oct-09-2022, 08:59 AM
Last Post: Gribouillis
  make all text in Right to left alignment in tkinter widgets jalal0034 1 1,258 Sep-27-2022, 06:42 PM
Last Post: Larz60+
  loop adventure game ilikedofs 1 1,671 May-26-2021, 12:43 AM
Last Post: bowlofred
  A text-based game [SOLVED] Gameri1 6 3,846 Apr-20-2021, 02:26 PM
Last Post: buran
  Winning/Losing Message Error in Text based Game kdr87 2 2,927 Dec-14-2020, 12:25 AM
Last Post: bowlofred
  Choose your own adventure game noahc2004 2 2,524 Jun-26-2020, 02:06 PM
Last Post: DPaul
  Hotkey to restart code? DannyB 1 2,698 May-20-2020, 02:52 AM
Last Post: michael1789
  PySide2 Hotkey works only once in Maya LalaGhost 0 1,755 May-19-2020, 05:05 PM
Last Post: LalaGhost
  so im trying to make a question game for school and im trying to make it when some on dertder25t 1 1,489 Jan-27-2020, 10:44 PM
Last Post: woooee
  Terminate a process when hotkey is pressed 66Gramms 0 2,210 Dec-24-2019, 06:41 PM
Last Post: 66Gramms

Forum Jump:

User Panel Messages

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