So I'm making a adventure game in .bat, and I want it so that when the player presses - it takes him to the Map frame and when he presses = the player goes to the Journal. I already worked out a way to return to the frame that the player was originally in, but I need to know how to set up key bindings.
Key bindings are a key that you press at anytime, and when you press it something happens, like you go to a map or teleport.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
As stated in the comments your best bet is to use choice. The main setup for choice is:
@choice [/c:] [/n] [/t /d ] [/m <"Text">]
The /c attribute lists all the available choices (i.e /c:123) would allow 1, 2 or 3 to be pressed.
The /n specifies not to display the inputted choices. (i.e the choices "123" would show up in console as [123]?) For [123]? to be shown leave out the /n
/t sets the time before a default choice is made
/d sets the default choice to be made after /t seconds
/m sets text to be displayed in the console window
For Example:
@ECHO off
@CHOICE /c:123 /n /t 100 /d 1 /m "TextGoesHere"
if ERRORLEVEL 3 GOTO three
if ERRORLEVEL 2 GOTO two
if ERRORLEVEL 1 GOTO one
goto end
:one
echo You pressed 1!
echo This is also the default choice after 100 seconds
goto end
:two
echo You pressed 2!
goto end
:three
echo You pressed 3!
:end
pause
Would display:
TextGoesHere [1,2,3]?
And if 2 was pressed:
TextGoesHere [1,2,3]?
You have pressed "2"!
press any key to continue...
And of course you could add code to these sections instead of just displaying text.
For more info about "choice" click here