为什么不设定时间,然后重新设定时间对我有利呢?

时间:2019-04-08 19:25:23

标签: batch-file

我正在尝试编写一个名为“ FIGHT!.bat”的游戏。我提供了随时保存的选项(因为这是一个游戏),但是当我保存时,时间和日期不会更新,并且时间显示为例如:“ 2 :: 3 PM”。我需要帮助!这是我在下面使用的代码。

@echo off
echo "AM, PM", or "24 Hour"?
echo[
choice /c 12 /m "1, or 2?"
if %errorlevel% equ 1 (
set timeformat=1
) else (
set timeformat=2
)
:setmrtime
if %timeformat% equ 1 (
set timerem=%time:~0,2%:%time:~3,2%
set hour=1
goto save
) else (
set hour=%time:~0,2%
set minute=%time:~3,2%
set pmam=AM
goto holdup
)
:holdup
if %hour% geq 12 (
set pmam=PM
) else (
set pmam=AM
)
if %hour% equ 12 (
set pmam=PM
)
if %hour% geq 13 (
set hour=%hour%-12
)
set timerem=%hour%:%minute% %pmam%
goto save
:save
cls
color 09
echo Save?
choice /c YN /m "Yes, or no? "
if %errorlevel%==1 (goto saving)
if %errorlevel%==2 (goto main)
:saving
set level=1
set health=10
set maxhealth=10
set money=0
set potions=0
set weapon=Hoe
set armor=Shirt
set bank=0
set fullrestores=0
set defence=0
set attack=1
set wlevel=1
set weaponlev=%wlevel%
set kills=0
set lastsave=%date% at %timerem%
set mystery=0
set timeformat=%timeformat%
set win=0
set /a save1=%save1%+1
attrib +h save.file
attrib -H save.file
(
echo %name%
echo %level%
echo %health%
echo %maxhealth%
echo %money%
echo %potions%
echo %weapon%
echo %armor%
echo %gender%
echo %bank%
echo %fullrestores%
echo %defence%
echo %attack%
echo %wlevel%
echo %weaponlev%
echo %kills%
echo %lastsave%
echo %mystery%
echo %timeformat%
echo %win%
)>save.file
attrib +H save.file
echo Saved.
pause
goto story
:story
cls
echo Story.
pause
:town
cls
echo Save?
choice /c YN /m "What? "
if %errorlevel%==2 (
exit
) else (
cls
echo %timerem%
goto save2
)
:save2
cls
color 0c
echo Save?
choice /c YN /m "Yes, or no? "
if %errorlevel%==1 (goto setdate)
if %errorlevel%==2 (goto town)
:saving2
attrib -H save.file
set timerem=%timerem%
set lastsave=%date% at %timerem%
(
echo %name%
echo %level%
echo %health%
echo %maxhealth%
echo %money%
echo %potions%
echo %weapon%
echo %armor%
echo %gender%
echo %bank%
echo %fullrestores%
echo %defence%
echo %attack%
echo %wlevel%
echo %weaponlev%
echo %kills%
echo %lastsave%
echo %mystery%
echo %timeformat%
echo %win%
)>save.file
attrib +H save.file
echo Saved.
pause
exit

现在不用担心,我抽出了部分实际游戏并更改了几行内容使其成为一个小程序。

出于某种奇怪的原因,当我保存游戏两次时,此代码将显示“ 2 :: 3 PM”或类似的内容,应为“ 3:24 PM”,而不是“ 2 :: 3 PM”。该代码无法正常工作。我有什么办法可以使此代码正常工作?

0 个答案:

没有答案