Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 批处理游戏中缺少运算符错误_Batch File - Fatal编程技术网

Batch file 批处理游戏中缺少运算符错误

Batch file 批处理游戏中缺少运算符错误,batch-file,Batch File,我一直找不到接线员 我搜索了如何修复它,但没有找到任何需要添加的内容: :teattack1 set /a health-=!monsterdmg! # It said missing operator here pause set /a monsterhealth-=!playerdmg! # And Here pause if "!monsterhealth!" == lss 0 goto tewin pause goto testencounter pause goto encounter

我一直找不到接线员

我搜索了如何修复它,但没有找到任何需要添加的内容:

:teattack1
set /a health-=!monsterdmg! # It said missing operator here
pause
set /a monsterhealth-=!playerdmg! # And Here
pause
if "!monsterhealth!" == lss 0 goto tewin
pause
goto testencounter
pause
goto encountermenu
添加到脚本以允许使用


有关此功能的概述以及需要此功能的原因

打开命令提示窗口,输入
set/?
并仔细阅读所有输出帮助页

需要说明的是,当对算术表达式(即
set/A
)使用set时,可以直接指定变量名而无需展开。Windows命令处理器会自动将每个不是数字或运算符的字符串解释为变量名称,并在计算算术表达式时访问当前变量值

下一步在命令提示窗口
中运行/?
,然后仔细阅读所有输出帮助页

线路

Setlocal EnableDelayedExpansion
是绝对无效的,因为它包含操作符
==
和操作符
lss
,这当然不能工作

这个改进的代码修复了所有的编码错误

if "!monsterhealth!" == lss 0 goto tewin

但是,环境变量
健康状况
怪物DMG
monsterhealth
playerdmg
都应该存在并分配一个整数值,否则Windows命令解释器对每个变量使用值
0
,使得代码没有真正的用处。

您以前是否尝试过输出变量<代码>回声健康=!健康!怪物=!怪物lss应该做什么?你只需要一个或另一个。另外,如果要使用
lss
,则不需要在左侧加引号。在问题发生之前启用
ECHO on
,并在问题中显示输出也是一个好主意。我希望他至少已经启用了延迟扩展。但你可能是对的@MineCakePvP-那么好吧
!怪物未正确设置。这将导致缺少操作数错误,而不是缺少运算符@MineCakePvP您的代码中有#注释吗?确保没有注释与这些集合操作位于同一行。
:teattack1
set /a health-=monsterdmg
pause
set /a monsterhealth-=playerdmg
pause
if %monsterhealth% LEQ 0 goto tewin
pause
goto testencounter
pause
goto encountermenu