我正在尝试保存一个游戏而且它会被卡住。当我按 ENTER 时,它会留下一个空白点。有没有人在我的剧本中看到错误?
@echo off
:saveload
title player movement
color 0f
cls
set /a health=10
if exist saves.txt (
< saves.txt (
set /p weapon=
set /p armorh=
set /p armorc=
set /p armorl=
set /p armorf=
set /p bow=
set /p gold=
set /p dmgweapon=
set /p dmgbow=
set /p prtah=
set /p prtac=
set /p prtal=
set /p prtaf=
set /p name=
)
goto :varsetup
) else (
echo to first begin we need to get your name!
set /p name=What is your name?:
(
set /p armorh=n/a
set /p armorc=n/a
set /p armorl=n/a
set /p armorf=n/a
set /p bow=n/a
set /p gold=10
set /p dmgweapon=1
set /p dmgbow=0
set /p prtah=0
set /p prtac=0
set /p prtal=0
set /p prtaf=0
set /p name=%name%
) > saves.txt
goto :saved
)
:saved
答案 0 :(得分:0)
在else
之后的set /p name=
分支中,代替set /p foo=bar
,您需要说明echo bar
,只要我有您的意图。 if exist
不应该是问题。这是固定代码:
@echo off
:saveload
title player movement
color 0f
cls
set /a health=10
if exist "saves.txt" (
< "saves.txt" (
set /p weapon=
set /p armorh=
set /p armorc=
set /p armorl=
set /p armorf=
set /p bow=
set /p gold=
set /p dmgweapon=
set /p dmgbow=
set /p prtah=
set /p prtac=
set /p prtal=
set /p prtaf=
set /p name=
)
goto :varsetup
) else (
echo to first begin we need to get your name!
set /p name=What is your name?:
(
echo n/a
echo n/a
echo n/a
echo n/a
echo n/a
echo 10
echo 1
echo 0
echo 0
echo 0
echo 0
echo 0
echo %name%
) > "saves.txt"
goto :saved
)
:saved