-4

I decided to make a text based adventure and I realized I didn't know much about making one. I do, however, know that I want to make it with a batch file, just because I think it is easier to work with and share. I don't have many questions right now but I'm sure I'll come up with more as time goes on (if I decide this is fun) but right now I have two questions:

  1. How do you make lines appear as if someone was typing it?

  2. How do you make the line wait x seconds before going to the next process (you know for "dramatic effect")

edit I forgot to put the script that I need help with sorry (it's supposed to look like the "wake up neo" screen from The Matrix but I cant get the intervals smaller than 2 or hide the ping text underneath).

    echo h
    PING 127.0.0.1 -n 2
    cls
    echo he
    PING 127.0.0.1 -n 2
    cls
    echo hel
    PING 127.0.0.1 -n 2
    cls
    echo hell
    PING 127.0.0.1 -n 2
    cls
    echo hello
    PING 127.0.0.1 -n 3
    cls
    echo hello.
    PING 127.0.0.1 -n 3
    cls
    echo hello..
    PING 127.0.0.1 -n 3
    cls
    echo hello...
    PING 127.0.0.1 -n 5
Bucket
  • 7,415
  • 9
  • 35
  • 45
  • 2
    Welcome to SO. This is a Q&A site. First read some tutorial on batch programming, try some code, and come back with your code and a detailed question, we will be happy to help you then. – PA. Jul 24 '13 at 17:07
  • 1
    Try a look at the code of others batch adventures like [Dostips: Swords of Morovaith](http://www.dostips.com/forum/viewtopic.php?f=3&t=4736) – jeb Jul 24 '13 at 17:25

1 Answers1

2

Wait/Delay [Source]

PING 127.0.0.1 -n 6 >nul

5 Second Delay

  • How it Works: 6 ping echos with default 1 second pause between them with loopback ip.
  • -n cannot be less than 2 or there will be no delay.

Delay < 1 Second

PING 10.1.1.1 -n 1 -w 200 >nul

200 Millisecond Delay by using a Private IP Address and the timeout flag -w. ( only adjust the -w value and leave -n as 1 when using this method )


Great Getting Started Resources

Rob van der Woude

SS64

DosTips

ComputerHope

TechNet


Example

Here is an example Typing routine that will print out each character of the message with a 200ms delay between each character.

@echo off
call :Typing "hello..."
exit /b 0

:Typing <Message>
setlocal
set "Message=%~1"
:TypingLoop
ping 10.1.1.1 -n 1 -w 200 >nul
<nul set /p "=%Message:~0,1%"
set "Message=%Message:~1%"
if defined Message goto TypingLoop
endlocal
exit /b 0
Community
  • 1
  • 1
David Ruhmann
  • 11,064
  • 4
  • 37
  • 47