Small text game
Posted: 05 Jun 2017 14:34
I know it may sound pretty lame, however, I have tried everything and I assume (hope) you guys can help me.
I am trying to create a small, text adventure game (like on the recent game 'Stories Untold - The House Abandon.') But I cant seem to get it to work like I want it to. I can do a numbered choice type like this:
Do you?
echo 1. Walk up to the man
echo 2. Avoid him
Enter Choice:
But I really want to create a system where you just type in what you want to do. So far I have this test piece and it works up until I press enter:
@echo off
:start
ECHO a man stands beside a wall
ping localhost -n 1 >nul
set /p opt= :
if %opt%==look man goto :1
if %opt%==look at man goto :2
if %opt%==view man goto :3
:1
Echo The man is dressed in a green jacket, blue jeans
ping localhost -n 4 >nul
cls
:2
Echo The man is dressed in a green jacket, blue jeans
ping localhost -n 4 >nul
cls
:3
Echo The man is dressed in a green jacket, blue jeans
ping localhost -n 4 >nul
cls
I have found that you cannot use more than one word (anything with a space) e.g. I can use "if %opt%==lookman goto :1" but I cannot use "if %opt%==look man goto :1"
I don't know why, If you could help me (completely new btw) I would be most grateful,
- Thomas
I am trying to create a small, text adventure game (like on the recent game 'Stories Untold - The House Abandon.') But I cant seem to get it to work like I want it to. I can do a numbered choice type like this:
Do you?
echo 1. Walk up to the man
echo 2. Avoid him
Enter Choice:
But I really want to create a system where you just type in what you want to do. So far I have this test piece and it works up until I press enter:
@echo off
:start
ECHO a man stands beside a wall
ping localhost -n 1 >nul
set /p opt= :
if %opt%==look man goto :1
if %opt%==look at man goto :2
if %opt%==view man goto :3
:1
Echo The man is dressed in a green jacket, blue jeans
ping localhost -n 4 >nul
cls
:2
Echo The man is dressed in a green jacket, blue jeans
ping localhost -n 4 >nul
cls
:3
Echo The man is dressed in a green jacket, blue jeans
ping localhost -n 4 >nul
cls
I have found that you cannot use more than one word (anything with a space) e.g. I can use "if %opt%==lookman goto :1" but I cannot use "if %opt%==look man goto :1"
I don't know why, If you could help me (completely new btw) I would be most grateful,
- Thomas