Files
dzhe-in-batch/editor/editor.bat
Victor Giers f7287dbcb2 initial commit
2019-07-09 15:36:02 +02:00

246 lines
8.9 KiB
Batchfile
Raw Blame History

::Bugs
::Wenn man die erste Interaktionsmoeglichkeit gleich weg"finish"t, ist der Leser in einer Sackgasse.
::Fixmgl: IMMER eine "zurueck"-Moeglichkeit zur Verfuegung stellen.
::
::Was noch fehlt
::
::Speicherfunktion
::
::Es muss im Editor einsehbar sein, welche Seiten es schon gibt. <-
@echo off
@echo.
@echo Dies ist der Generator fuer interaktive Batch-Buecher.
@echo.
@echo ACHTUNG! Wenn du das Schreiben einer Seite abbrichst, treten Fehler im Buch auf.
@echo.
@echo An welchem Buch moechtest du weiterschreiben?
@echo Fuer ein neues Buch gib einen Namen an.
set /p titel=
:seide
set mgl1=
set mgl2=
set mgl3=
set mgl4=
set mgl5=
set mgl6=
set mgl7=
set mgl8=
set mgl9=
set mgl10=
set mgl11=
@echo Gib bitte den Titel der Seite an.
set /p seite=
echo ^@echo off >> %titel%.bat
echo ^:%seite% >> %titel%.bat
echo cls >> %titel%.bat
echo ^@echo^. >> %titel%.bat
@echo.
@echo Nun zum Inhalt.
@echo Fuer eine leere Zeile schreibe "empty".
@echo Fuer eine verzoegerung schreibe "delay"
@echo Wenn du den Spieler interagieren lassen moechtest schreibe "finish".
@echo.
:loop1
set /p zeile=
if "%zeile%"=="delay" goto pau
if "%zeile%"=="empty" goto empt
if "%zeile%"=="finish" goto int
echo ^@echo %zeile% >> %titel%.bat
goto loop1
:pau
@echo Wie lang soll die Verzoegerung sein? 1000 = 1 Sekunde
set /p delay=
echo ping ^1^.^1^.^1^.^1^ ^-n^ ^1 ^-w^ %delay%^ ^>NUL >> %titel%.bat
goto loop1
:empt
echo ^@echo^. >> %titel%.bat
goto loop1
:int
echo ^@echo. >> %titel%.bat
echo ^@echo. >> %titel%.bat
echo ^@echo^ Moeglichkeiten^: >> %titel%.bat
echo ^@echo. >> %titel%.bat
set /a a=0
set /a b=0
:loop2
@echo Gib eine Handlungsmoeglichkeit ein. Nur ein Wort. Schreibe "finish", falls du fertig bist.
set /a a=%a%+1
if %a%==11 goto prefinint
set /p mgl%a%="%a%. "
if not defined mgl%a% (
goto erraw
)
if $%mgl1%$==$finish$ goto nomgl
if $%mgl2%$==$finish$ goto prefinint
if $%mgl3%$==$finish$ goto prefinint
if $%mgl4%$==$finish$ goto prefinint
if $%mgl5%$==$finish$ goto prefinint
if $%mgl6%$==$finish$ goto prefinint
if $%mgl7%$==$finish$ goto prefinint
if $%mgl8%$==$finish$ goto prefinint
if $%mgl9%$==$finish$ goto prefinint
if $%mgl10%$==$finish$ goto prefinmgl
@echo Auf welche Seite fuehrt diese Handlung den Spieler?
@echo Schreibe "help" fuer eine uebersicht aller vorhandenen Seiten.
set /a b=%b%+1
set /p link%b%=
if not defined link%b% (
goto erraw
)
goto loop2
:erraw
@echo Fehler! Nochmal von vorne!
set /a a=0
goto loop2
:prefinint
if defined mgl11 (
echo %mgl1%^,^ %mgl2%^,^ %mgl3%^,^ %mgl4%^,^ %mgl5%^,^ %mgl6%^,^ %mgl7%^,^ %mgl8%^,^ %mgl9%^,^ %mgl10% >> %titel%.bat
echo ^@echo^. >> %titel%.bat
echo ^:%seite%P >> %titel%.bat
echo set^ ^/p^ action^= >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl1%^$^ goto^ %link1% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl2%^$^ goto^ %link2% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl3%^$^ goto^ %link3% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%%mgl4%^$^ goto^ %link4% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl5%^$^ goto^ %link5% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl6%^$^ goto^ %link6% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl7%^$^ goto^ %link7% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl8%^$^ goto^ %link8% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl9%^$^ goto^ %link9% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl10%^$^ ^(goto^ %link10%^)^ else^ goto^ %seite%P >> %titel%.bat
goto eof
)
if defined mgl10 (
echo ^@echo %mgl1%^,^ %mgl2%^,^ %mgl3%^,^ %mgl4%^,^ %mgl5%^,^ %mgl6%^,^ %mgl7%^,^ %mgl8%^,^ %mgl9% >> %titel%.bat
echo ^@echo^. >> %titel%.bat
echo ^:%seite%P >> %titel%.bat
echo set^ ^/p^ action^= >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl1%^$^ goto^ %link1% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl2%^$^ goto^ %link2% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl3%^$^ goto^ %link3% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl4%^$^ goto^ %link4% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl5%^$^ goto^ %link5% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl6%^$^ goto^ %link6% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl7%^$^ goto^ %link7% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl8%^$^ goto^ %link8% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl9%^$^ ^(goto^ %link9%^)^ else^ goto^ %seite%P >> %titel%.bat
goto eof
)
if defined mgl9 (
echo ^@echo %mgl1%^,^ %mgl2%^,^ %mgl3%^,^ %mgl4%^,^ %mgl5%^,^ %mgl6%^,^ %mgl7%^,^ %mgl8% >> %titel%.bat
echo ^@echo^. >> %titel%.bat
echo ^:%seite%P >> %titel%.bat
echo set^ ^/p^ action^= >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl1%^$^ goto^ %link1% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl2%^$^ goto^ %link2% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl3%^$^ goto^ %link3% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl4%^$^ goto^ %link4% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl5%^$^ goto^ %link5% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl6%^$^ goto^ %link6% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl7%^$^ goto^ %link7% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl8%^$^ ^(goto^ %link8%^)^ else^ goto^ %seite%P >> %titel%.bat
goto eof
)
if defined mgl8 (
echo ^@echo %mgl1%^,^ %mgl2%^,^ %mgl3%^,^ %mgl4%^,^ %mgl5%^,^ %mgl6%^,^ %mgl7% >> %titel%.bat
echo ^@echo^. >> %titel%.bat
echo ^:%seite%P >> %titel%.bat
echo set^ ^/p^ action^= >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl1%^$^ goto^ %link1% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl2%^$^ goto^ %link2% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl3%^$^ goto^ %link3% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl4%^$^ goto^ %link4% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl5%^$^ goto^ %link5% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl6%^$^ goto^ %link6% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl7%^$^ ^(goto^ %link7%^)^ else^ goto^ %seite%P >> %titel%.bat
goto eof
)
if defined mgl7 (
echo ^@echo %mgl1%^,^ %mgl2%^,^ %mgl3%^,^ %mgl4%^,^ %mgl5%^,^ %mgl6% >> %titel%.bat
echo ^@echo^. >> %titel%.bat
echo ^:%seite%P >> %titel%.bat
echo set^ ^/p^ action^= >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl1%^$^ goto^ %link1% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl2%^$^ goto^ %link2% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl3%^$^ goto^ %link3% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl4%^$^ goto^ %link4% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl5%^$^ goto^ %link5% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl6%^$^ ^(goto^ %link6%^)^ else^ goto^ %seite%P >> %titel%.bat
goto eof
)
if defined mgl6 (
echo ^@echo %mgl1%^,^ %mgl2%^,^ %mgl3%^,^ %mgl4%^,^ %mgl5% >> %titel%.bat
echo ^@echo^. >> %titel%.bat
echo ^:%seite%P >> %titel%.bat
echo set^ ^/p^ action^= >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl1%^$^ goto^ %link1% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl2%^$^ goto^ %link2% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl3%^$^ goto^ %link3% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl4%^$^ goto^ %link4% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl5%^$^ ^(goto^ %link5%^)^ else^ goto^ %seite%P >> %titel%.bat
goto eof
)
if defined mgl5 (
echo ^@echo %mgl1%^,^ %mgl2%^,^ %mgl3%^,^ %mgl4% >> %titel%.bat
echo ^@echo^. >> %titel%.bat
echo ^:%seite%P >> %titel%.bat
echo set^ ^/p^ action^= >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl1%^$^ goto^ %link1% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl2%^$^ goto^ %link2% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl3%^$^ goto^ %link3% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl4%^$^ ^(goto^ %link4%^)^ else^ goto^ %seite%P >> %titel%.bat
goto eof
)
if defined mgl4 (
echo ^@echo %mgl1%^,^ %mgl2%^,^ %mgl3% >> %titel%.bat
echo ^@echo^. >> %titel%.bat
echo ^:%seite%P >> %titel%.bat
echo set^ ^/p^ action^= >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl1%^$^ goto^ %link1% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl2%^$^ goto^ %link2% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl3%^$^ ^(goto^ %link3%^)^ else^ goto^ %seite%P >> %titel%.bat
goto eof
)
if defined mgl3 (
echo ^@echo %mgl1%^,^ %mgl2% >> %titel%.bat
echo ^@echo^. >> %titel%.bat
echo ^:%seite%P >> %titel%.bat
echo set^ ^/p^ action^= >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl1%^$^ goto^ %link1% >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl2%^$^ ^(goto^ %link2%^)^ else^ goto^ %seite%P >> %titel%.bat
goto eof
)
if defined mgl2 (
echo ^@echo %mgl1% >> %titel%.bat
echo ^@echo^. >> %titel%.bat
echo ^:%seite%P >> %titel%.bat
echo set^ ^/p^ action^= >> %titel%.bat
echo if^ ^$%%action%%^$^=^=^$%mgl1%^$^ ^(goto^ %link1%^)^ else^ goto^ %seite%P >> %titel%.bat
goto eof
)
:nomgl
::an dieser stelle kommt das, was passiert, wenn es keine moeglichkeiten gibt. also die standardmgl?
:eof
@echo Script ausgef<65>hrt.
@echo Moechtest du mit der n<>chsten Seite weitermachen? (y)
set /p sadfjk=
if %sadfjk%==y (
cls
goto seide
) else (
@echo Druecke eine Taste zum Beenden.
pause >nul
exit
)