Ich habe Ihren Code und lieferte eine abgeschlossene Arbeits Skript aufgeräumt, und stellte fest, wo Sie Ihr Spiel-Code setzen.
Obwohl die verzögerte Erweiterung für diesen Code nicht benötigt wird, habe ich sie in das Skript eingefügt, wie Sie es in Ihrem ursprünglichen Skript hatten.
Bitte beachten Sie die Variablennamen, die ich gewählt habe, da sie an verschiedenen Orten verwendet werden.
Ich habe versucht, den Code mit Informationen zu kommentieren, was es tut, und ich würde zufällig weiter erklären, wenn nötig.
Ich würde gerne Ihr Spiel spielen, wenn Sie damit abgeschlossen sind, wenn ich darf. :)
Hoffe, dass hilft.
Ben
BPG.cmd
REM Script: BPG.cmd
REM Version: 1.0
REM Description: Game to play about Monsters.
Rem Notes: Currently Implementing Menu System.
Rem Sets up Variables and checks if the script needs to be re-called.
@(
SETLOCAL ENABLEDelayedExpansion
echo off
SET "eLvl=0"
SET "ScriptFolder=%~dp0"
SET "Log=%~dpn0.log"
SET "ConfigFile=%~dpn0_cfg.txt"
IF /I "%~1" NEQ "MAX" (
ENDLOCAL
ECHO.Game not started Maximized, Opening in a New Window by Running: Start "BPG 1 A Batch of Monsters" /MAX "%~dpnx0" MAX
Start "BPG 1 A Batch of Monsters" /MAX "%~dpnx0" MAX
EXIT /b %eLvl%
)
COLOR 2
)
REM Calls Main Function.
CALL :Main
REM Ends the script.
(
ENDLOCAL
EXIT /b %eLvl%
)
REM Main Function, most of your coding goes here, and this function calls sub functions.
:Main
Rem Check if Config file exists, if it does not, then call the New User Function.
IF NOT EXIST "%ConfigFile%" (
CALL :NewUser
)
Rem Load Username from Config file.
FOR /F "Tokens=*" %%A IN ('Type "%ConfigFile%"') DO (
SET "_UserName=%%~A"
)
Rem Call Menu System
CALL :Menu
REM Based off the option chosen Either Start a new Game or Skip to the End.
REM ECHO.CALL %_Menu_Choice%
CALL %_Menu_Choice%
GOTO :EOF
:NewUser
SETLOCAL
REM Get the Username Input
SET /P "_User=Please Enter a Username: "
REM Output the Username to the config file, overwriting all the file contents:
echo.%_User%>"%ConfigFile%"
ENDLOCAL
GOTO :EOF
:Menu
SETLOCAL
REM Output the Config file contents:
Type "%ConfigFile%"
REM Clear the screen
cls
echo ______ _______ _______
echo I ___ \ I ____ I I ____ \
echo I I I II I II I I \/
echo I I__//I I____II I I
echo I __ I I _____I I I ____
echo I I \ \ I I I I \_ I
echo I I___I II I I I___I I
echo I______/ I_/ I_______I A BATCH OF MONSTERS
echo.
echo.
echo 1) Begin
echo.
echo 2) Exit
echo.
set /p "_Choice=%_UserName%, Enter a Number: "
(
REM End the local variable Space, and Set return variables based on the choice, or re-draw the menu.
ENDLOCAL
IF /I "%_Choice%" EQU "1" (
REM ECHO.%_Choice% EQU 1
SET "_Menu_Choice=:Begin_Game"
) ELSE (
IF /I "%_Choice%" EQU "2" (
REM ECHO.%_Choice% EQU 2
SET "_Menu_Choice=GOTO :EOF"
) ELSE (
ECHO.%_Choice% Not Valid!
PAUSE
GOTO :Menu
)
)
)
goto :EOF
:Begin_Game
REM All the remaining code for your game should probably go here.
GOTO :EOF
Danke für diesen Mann, ich werde damit experimentieren und es ausprobieren, auch ich würde es lieben, wenn du es spielst, wenn es ist getan: D – Yoshirou
Hallo Yoshirou, Klingt gut. Ich freue mich darauf, wieder zu hören. Bitte beachten Sie, ich bin mir nicht sicher, warum Sie in Ihrem Skript die Ausgabe des Inhalts der Konfigurationsdatei haben, kurz bevor das Menü den Bildschirm löscht. Ich habe das an Ort und Stelle, aber Sie werden nie die Ausgabe sehen, wie der nächste Befehl den Bildschirm löscht. –
Vielen Dank Mann, und ich habe wahrscheinlich vergessen, es zu einem bestimmten Zeitpunkt zu löschen, ich versuchte das Skript vor einer Minute und es funktioniert perfekt, ich kann nicht warten, um das Spiel zu vervollständigen und das war eine große Hilfe, wirklich geschätzt – Yoshirou