This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-11-13 20:55:16

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

I need DOS help!

Can someone fix this? After I start, if I type in no command, it shuts off. Same with the examine commands...

Code:

@echo off
goto :Start
set area = 00
set inventory =

:Start
echo.
echo.
title Sep's First DOS-Game!
echo Welcome to the epic DOS game!
echo 1) Play
echo 2) Quit
echo 3) Help
set /p mainchoice=

if %mainchoice%==1 goto :00
if %mainchoice%==2 exit
if %mainchoice%==3 goto :Help

:Help
echo.
echo.
echo Type in the commands you would like to 

use when you are prompted.
echo.
echo Commands:
echo use
echo use ____ with ____
echo look
echo examine ____
echo inventory
echo.
pause
goto :Start


:00
set area = 00
echo.
echo.
echo You awake in a blank room...
set /p do=What would you like to do?: 
if %do% == look goto (:Look00)
else if %do% == use lightbulb ()
else if %do% == inventory (echo.
echo.
echo You have %inventory% in your 

inventory.
goto :00)
else if %do% == examine walls (echo.
echo.
echo Blank, white walls. This one has a small 

hole in it.
goto :00)
else (goto :00)


:Look00
echo.
echo.
echo You are in a blank, white room, with 

blank walls, a blank floor, and a small 

lightbulb on the ceiling.
goto :00

http://i46.tinypic.com/dw7zft.png

Offline

 

#2 2010-11-13 20:57:30

Scratchthatguys
Scratcher
Registered: 2010-07-16
Posts: 1000+

Re: I need DOS help!

You cannot use replies with 2 words. It confuses the DOS prompt, and shuts it down.

Offline

 

#3 2010-11-13 21:34:40

meowmeow55
Scratcher
Registered: 2008-12-24
Posts: 1000+

Re: I need DOS help!

OK, here are a few tips to fix up your code:
1. Drop the spaces on both sides of the equals sign when using the set command. Change "set area = 00" to "set area=00", etc.
2. Put double quotes around variables and what they are compared to when using "==". For example, change '%do%==examine walls' to '"%do%"=="examine walls"'. This will allow you to use spaces when using "set /p".
3. When you have multiple-choice inputs with only one character for each, use the "choice" command instead of "set /p" and use "if ERRORLEVEL x" commands to filter the results. Changing your "Play, Quit, Help" choice to this would look like this:

Code:

choice /c 123 /n

if ERRORLEVEL 1 goto :00
if ERRORLEVEL 2 exit /b
::oh BTW, use "exit /b" when exiting so it will exit the batch file 
::but not the command prompt if the batch file is run from the prompt.
if ERRORLEVEL 3 goto :Help

More info on the choice command here.
4. Your "if else" syntax looks messy. Here's an example to look off of:

Code:

if %var%==something (
echo.
echo The variable "var" is "something"!
echo.
) else (
echo.
echo The variable "var" is not "something"!
echo.
)

Also, put spaces between parentheses and the command directly before/after them.


Yawn.

Offline

 

#4 2010-11-14 07:17:09

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: I need DOS help!

While testing:

Code:

Welcome to the epic DOS game!
1) Play
2) Quit
3) Help
f


Type in the commands you would like to use when you are prompted.

Commands:
use
use ____ with ____
look
examine ____
inventory

Press any key to continue . . .


Welcome to the epic DOS game!
1) Play
2) Quit
3) Help
1


You awake in a blank room...
What would you like to do?: look


You are in a blank, white room, with blank walls, a blank floor, and a small lig
htbulb on the ceiling.


You awake in a blank room...
What would you like to do?: examine wall
'else' is not recognized as an internal or external command,
operable program or batch file.
'else' is not recognized as an internal or external command,
operable program or batch file.


You have  in your inventory.


You awake in a blank room...
What would you like to do?:

It doesn't understand else...


http://i46.tinypic.com/dw7zft.png

Offline

 

#5 2010-11-14 08:00:18

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: I need DOS help!

Please?


http://i46.tinypic.com/dw7zft.png

Offline

 

#6 2010-11-14 08:47:52

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: I need DOS help!

OK, so I have this:

Code:

@echo off
set area=00
set inventory=
goto :Title


:Title
echo \  \  /  /    __   ___    _    ___    _
echo  \  \/  /   /__      |      |_)  |__     /_\    /\  /\
echo  /  /\  \    __/     |      |  \  |___  /    \  /  \/   \
echo /  /  \  \                              Games
echo It's not extreme, it's XStream.
echo.
echo Press any key to start...
pause
goto:Start

:Start
echo.
echo.
title Sep's First DOS-Game!
echo Welcome to the epic DOS game!
echo 1) Play
echo 2) Quit
echo 3) Help
set /p mainchoice=

if %mainchoice%==1 goto :00
if %mainchoice%==2 exit
if %mainchoice%==3 goto :Help

:Help
echo.
echo.
echo Type in the commands you would like to use when you are prompted.
echo.
echo Commands:
echo use ____ -- Use the item. It doesn't need to be in your inventory.
echo use ____ with ____ -- Combine two items, or use an item on another.
echo look -- Look around the current room.
echo examine ____ -- Look carefully at an item.
echo inventory -- Check your inventory.
echo.
pause
goto :Start


:00
set area = 00
echo.
echo.
echo You awake in a blank room...
set /p do=What would you like to do?: 
if "%do%"=="look" (
    goto :Look00
) ELSE (
    if "%do%"=="use lightbulb" (
        echo.
        echo.
        echo You can't reach it.
        goto :00
    ) ELSE (
        if "%do%"=="inventory" (
            echo.
            echo.
            echo You     have %inventory% in    your inventory.
            goto :00
        ) ELSE (
            if "%do%"=="examine walls" (
                echo.
                echo.
                echo Blank, white walls. This one has a small hole in it.
                goto :00
            ) ELSE (
                if "%do%"=="examine wall" (
                    echo.
                    echo.
                    echo Blank, white walls. This one has a small hole in it.
                    goto :00
                ) ELSE (
                    goto :00
                )
            )
        )
    )
)

:Look00
echo.
echo.
echo You are in a blank, white room, with blank walls, a blank floor, and a small lightbulb on the ceiling.
goto :00

But when I start it, it shuts right away... It started after I added the title part, with the XStream games...


http://i46.tinypic.com/dw7zft.png

Offline

 

#7 2010-11-14 08:55:40

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: I need DOS help!

This char: || seems to be the problem...


http://i46.tinypic.com/dw7zft.png

Offline

 

#8 2010-11-14 09:01:30

Scratchthatguys
Scratcher
Registered: 2010-07-16
Posts: 1000+

Re: I need DOS help!

You can't use * or unicode characters in it, including |.

Offline

 

#9 2010-11-14 09:08:45

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: I need DOS help!

Never mind ,but thanks. I used I instead.


http://i46.tinypic.com/dw7zft.png

Offline

 

#10 2010-11-14 09:13:21

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: I need DOS help!

Hey, how would I check if a string contains another string?


http://i46.tinypic.com/dw7zft.png

Offline

 

#11 2010-11-14 09:39:11

fire219
Scratcher
Registered: 2008-02-07
Posts: 1000+

Re: I need DOS help!

SeptimusHeap wrote:

Hey, how would I check if a string contains another string?

If the string that holds the other is a var, you can do:

Code:

 
if %anyvar%==(string) (more code here)

without the parenthesis, of course.


http://bluetetrarpg.x10.mx/usercard/img.php?name=fire219

Offline

 

#12 2010-11-14 09:55:55

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: I need DOS help!

I want to know if it CONTAINS, not if it IS...


http://i46.tinypic.com/dw7zft.png

Offline

 

#13 2010-11-14 10:51:36

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: I need DOS help!

sad


http://i46.tinypic.com/dw7zft.png

Offline

 

#14 2010-11-14 11:07:01

meowmeow55
Scratcher
Registered: 2008-12-24
Posts: 1000+

Re: I need DOS help!

OK, here's a way that will work, but it involves writing to files.
I'm assuming that you want to filter user input.

Code:

::This writes the user input to a file
echo %choice% > $][gametmp.tmp
find %textyouwanttofindhere%<$][gametmp.tmp>nul

We have to write the user input to a file because the FIND command refuses to search in a string. After the FIND command, use "if ERRORLEVEL n" to detect if the user input contains something; if the input does contain something, the command returns 0, and if it doesn't, it returns 1. You can delete the temporary file after you run the command.


Yawn.

Offline

 

#15 2010-11-14 11:09:03

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: I need DOS help!

Wait, so, how would I delete it?


http://i46.tinypic.com/dw7zft.png

Offline

 

#16 2010-11-14 11:12:31

meowmeow55
Scratcher
Registered: 2008-12-24
Posts: 1000+

Re: I need DOS help!

In this case, you would do "del $][gametmp.tmp".


Yawn.

Offline

 

Board footer