0

When I'm at :Forest, for example, how I can type I, to display the Inventory, and then return to where I called it from?

Example snippet:

:Inventory
echo Inventory:
echo bla bla items
cls
pause

:StoryBegin
echo This is a story
set /p input=(1,2)?
if %input% == 1 goto Forest
if %input% == 2 goto Castle
if %input% == I goto Inventory

:Forest
set /p input=(1,2)
if %input% == 1 goto House
if %input% == 2 goto Hill
if %input% == I goto Inventory
Compo
  • 36,585
  • 5
  • 27
  • 39

1 Answers1

0

Please consider choice which is designed for this task. Use the search facility for [batch-file] choice eg Gerhard's example https://stackoverflow.com/a/58370914/2128947 or see the documentation - choice /? from the prompt.

The magic formula from there is

if errorlevel x call :inventory&goto somewhere

Where :inventory is an "internal subroutine" which should terminate with a goto :eof. The colons in the call statement and goto :eof are required.

Magoo
  • 77,302
  • 8
  • 62
  • 84