Ich mache ein Batch-Spiel, und ich versuche, das Sparsystem aus einem Batch-Spiel namens finalrealm in meine zu implementieren. Sein Spiel ist offener als meines, also musste ich das Zeug wechseln. Wie funktioniert mein Speicherungssystem? Wenn Sie zu einem bestimmten Teil des Spiels kommen, wird es Ihren "Ort" im Spiel als Variable setzen, alle Variablen im Gam in einer .bat-Datei speichern und dann den Ort verwenden Variabel, gehe zurück zu dem Punkt in dem Spiel, in dem du warst. Es kann jedoch passieren, dass etwas schief geht und Sie dann in den Code für die Anmeldung gelangen. Wenn ich mich dann anmelde, schlägt das fehl. HierWie spart man Stapelverarbeitung?
ist der Code:
@echo off
cls
Title RPG BUILD 0.4 (MAJOR UPDATE:Saving Progress +)
color 07
cls
:FirstMENU
cls
echo What would you like to do?
echo.
echo 1) Open Save File
echo 2) New Game
echo.
echo.
echo Current Version: RPG BUILD 0.4
echo (Saving Function Based on "FinalRealm" by Brian)
set /p login=
if %login% GEQ 3 goto FirstMENU
if %login% EQU 1 goto login
if %login% EQU 2 goto createuser
goto Login
:createuser
echo.
echo What would you like your Username to be?
set /p username1=
set v1f=0
goto checkforspaces
:checkforspaces
set x=!v1f!
set Letter%v1f%=!username1:~%x%,1!
if "!Letter%v1f%!" EQU " " (
echo.
echo.
echo Sorry you cant use spaces in your Username.
pause>nul
goto FirstMenu
)
echo.
echo What would you like your Password to be?
set /p password1=
goto Begin
:SAVE_GAME_FILES
(
echo set username1=%username1%
echo set password1=%password1%
:DATA_VALUES
set Hair=%Hair%
set Face=%Face%
set E=%E%
set /a Power=%Power%
set /a Hp=%Hp%
set rival=%rival%
set /a rivalhp=%rivalhp%
set L=%L%
)>%username1%.bat
if L EQU 1 goto Menu
if L EQU 2 goto folo
if L EQU 3 goto rolo
if L EQU 4 goto levelup1
if L EQU 5 goto 23
:login
cls
set /p name1=Username:
if not exist "%name1%.bat" (
echo That is not a valid Username.
pause>nul
goto FirstMenu
)
set /p pass1=Password:
call %name1%.bat
if not %password1% EQU %pass1% (
echo That is not a valid Password.
pause>nul
goto FirstMenu
)
goto SAVE_GAME_FILES
:Begin
echo Hello %username1%!
pause >nul
cls
echo Begin your journey by making a character!
pause >nul
:CM
cls
echo Loading Character Maker
pause >nul
cls
:Hair
echo 1. Bald
echo 2. Wavy Hair ~~~
echo 3. Curled Up Hair ,,,
set /p answer=Type the number of your option and press enter.
if %answer%==1 goto lel
if %answer%==2 goto 2
if %answer%==3 goto 3
:lel
cls
set Hair=___
goto A
:2
cls
set Hair=~~~
goto A
:3
cls
set Hair=,,,
goto A
:A
echo 1. ('-') Face
echo 2. (.3.) Face
echo 3. (._.) Face
set /p answer=Type the number of your option and press enter.
if %answer%==1 goto 5
if %answer%==2 goto 6
if %answer%==3 goto 7
:5
cls
set Face=('-')
goto B
:6
cls
set Face=(.3.)
goto B
:7
cls
set Face=(._.)
goto B
:B
echo 1. (-) Energy
echo 2. (*) Energy
echo 3. (+) Energy
set /p answer=Type the number of your option and press enter.
if %answer%==1 goto 8
if %answer%==2 goto 9
if %answer%==3 goto 0
:0
cls
set E=+
goto C
:9
cls
set E=*
goto C
:8
cls
set E=-
goto C
:C
echo %Hair%
echo %Face%
echo /!\ %E%
echo /"\
echo This is your character
set /p answer=Would you like to redo you character? (Yes/No)
if %answer%==Yes goto CM
if %answer%==No goto MenuPre
:MenuPre
set L=1
goto SAVE_GAME_FILES
:Menu
cls
echo MENU
echo 1. Start
echo 2. Exit
set /p answer=Type the number of your option and press enter.
if %answer%==1 goto Start
if %answer%==2 goto Exit
:Exit
exit
:Start
cls
echo Let us begin by getting you an item!
pause >nul
cls
set L=2
goto SAVE_GAME_FILES
:folo
cls
color 0A
echo \---------------------------------------------------\
echo \ Item Shop (Route 1) \
echo \---------------------------------------------------\
pause >nul
cls
echo Oh hey! A promotion! "All new customers get a free sword!"
pause >nul
cls
echo *Randomizing Sword's Power*
pause >nul
:Random
cls
set /a Power=%random%
if %random% GTR 1000 goto Random
set /a Power=%Power%/2400 + 1
echo Wow! This sword's power stat is %Power% (10 and below is common,
echo 11 and above is uncommon)
pause >nul
cls
echo %username1% recieved "Sword"
pause >nul
set L=3
goto SAVE_GAME_FILES
:rolo
cls
color 03
echo ???????: Hey, %username1%! I am going to wreck you!!!!
pause >nul
cls
echo ??????: I am your rival!!!
pause >nul
cls
set /p rival=What is your rival's name?
cls
set /a rivalhp=50
set /a hp=50
cls
color 0F
echo %rival%'s HP:%rivalhp% %username1%'s Hp:%hp%
pause >nul
:BattleMain
cls
echo %rival%'s HP:%rivalhp% %username1%'s Hp:%hp%
echo What move will you use?
echo 1.Slash
set /p answer=
if %answer%==1 goto SwegslashRandom
:SwegslashRandom
cls
set /a num=%random%
if %num% gtr 100 goto SwegslashRandom
if %num% lss 1 goto SwegslahsRandom
if %num% gtr 75 (goto Critical)
if %num%==75 (goto OK)
if %num% lss 75 (goto OK)
:Critical
set /a rivalhp= %rivalhp%-(%Power% + 5)
cls
echo %rival% used Punch!
pause >nul
cls
echo Your HP went down by 8!
pause >nul
cls
echo You used Slash
pause >nul
cls
echo Critical hit! %rival%'s HP went down by %power% + 5 for critical hit bonus!
pause
set /a hp=%hp%-8
if %rivalhp%==0 goto Win
if %rivalhp% lss 0 goto Win
if %rivalhp% gtr 0 goto BattleMain
:OK
set /a rivalhp= %rivalhp%-%power%
cls
echo %rival% used Punch!
pause >nul
cls
echo Your HP went down by 10!
pause >nul
if %hp%==0 goto LOZER
if %hp% lss 0 goto LOZER
cls
echo You used Slash
pause >nul
cls
echo %rival%'s HP went down by %power%!
pause >nul
set /a hp =%hp%-10
if %rivalhp%==0 goto Win
if %rivalhp% lss 0 goto Win
if %rivalhp% gtr 0 goto BattleMain
:Win
cls
color 0E
echo %rival%: Ugh, you're too powerful...
pause >nul
cls
echo %rival% ran away
pause >nul
goto levelup1
:LOZER
cls
color 47
echo %rival%:HA, what a weak foe!
pause >nul
echo *Redoing Battle*
pause >nul
goto rolo
set L=4
goto SAVE_GAME_FILES
:levelup1
cls
echo %username1% Leveled up to, Level 2!
set /a level=2
pause >nul
cls
set /a hp=(%hp%*8)+50
set /a power=%power%+((%random%/1000)+1)
echo Wow! Your sword's power is now %power%, and your HP is now %hp%
pause >nul
:PRE23
set L=5
goto SAVE_GAME_FILES
:23
cls
echo Oh hey, %rival% dropped a map!
pause >nul
cls
echo [] Destiny Cave
echo Route 3 !
echo ________ !
echo / \ !
echo [] City A \ Route 4 ! Route X
echo / \ !
echo /Route 2 ! Route 5 !
echo Route 1 / []_____!____________[]
echo _________/ Gang Hideout City B
pause >nul
cls
echo %username1% obtained "Map"
pause >nul
cls
echo Let's continue onto Route 2!
pause >nul
cls
echo \---------------------------------------------------\
echo \ Route 2 \
echo \---------------------------------------------------\
pause >nul
cls
echo While we go down Route 2, let me explain "energy"
pause >nul
cls
echo It seems you have, %E% type energy.
pause >nul
cls
echo During a battle, you can use energy attacks.
pause >nul
cls
echo Energy Attacks are sort of a gamble, they can be really good or really bad
echo but they get stronger the lower the hp you have, so use them to finish the battle
pause >nul
cls
echo [] Destiny Cave
echo Route 3 !
echo ________ !
echo / \ !
echo You ---> [] City A \ Route 4 ! Route X
echo / \ !
echo /Route 2 ! Route 5 !
echo Route 1 / []_____!____________[]
echo _________/ Gang Hideout City B
pause >nul
echo Hey! We are now in City A!
pause >nul
cls
echo that is the end of Build
pause >nul
exit
Hilfe wäre sehr willkommen! Vielen Dank!
auf den ersten Blick verwenden Sie Klammern in Ihrer Zeichenvariablen. Da Klammern die öffnenden und schließenden Zeichen des Blocks sind, kann das Schließen einer beliebigen Variablen die Blocklogik stören. Also muss die schließende Klammer ** mit Escapezeichen versehen oder in Anführungszeichen eingeschlossen werden **, wenn Sie sie verwenden wollen. Flucht ** ^) ** – elzooilogico