1

我正在批量制作地牢爬行引擎。我制作了一个易于使用的地图编辑器,但需要有关特定 IF 语句的帮助。

(...)
set Xpos=3
set Ypos=3
set unipos=%Xpos%.%Ypos%
goto map2.2

:map2.2
rem     N
rem   ??=??
rem   ==+==
rem W =?=?= E
rem   ==+==
rem   ??=??
rem     S
set donjon=2.2
set tile1.1=x
set tile1.2=x
set tile1.3=ns
set tile1.4=x
set tile1.5=x
set tile2.1=se
set tile2.2=ew
set tile2.3=nsew
set tile2.4=ew
set tile2.5=sw
set tile3.1=nsw
set tile3.2=x
set tile3.3=nsew
set tile3.4=x
set tile3.5=nse
set tile4.1=ne
set tile4.2=ew
set tile4.3=nsew
set tile4.4=ew
set tile4.5=nw
set tile5.1=x
set tile5.2=x
set tile5.3=ns
set tile5.4=x
set tile5.5=x
goto inroom

:inroom
set tile=tile
set roomcheck=%tile%%unipos%
set retire=inroom
cls
echo  [%name1%] HP: %hp1%/%xhp1%
if 1==%friend2% echo  [%name2%] HP: %hp2%/%xhp2%
if 1==%friend3% echo  [%name3%] HP: %hp3%/%xhp3%
echo ==================================================
echo.
echo  You are now at room %unipos%. %roomcheck%
if nsew==%roomcheck% echo  There are exits in all four directions.
echo.

加载地图时出现的是这样的:

[你的名字] 生命值:300/300

你现在在 room3.3。tile3.3

我需要知道当标题中存在另一个变量时如何搜索一个变量!我可能说得非常错误,但“%tile%%unipos%”是我能想到的最好的。它是一个...占位符,如果你愿意的话。

4

1 回答 1

1

你需要延迟扩展

@echo off
setlocal enabledelayedexpansion

set "tile3.3=nsew"
set "unipos=3.3"
set "roomcheck=!tile%unipos%!"
echo %roomcheck%
于 2015-06-29T20:45:59.250 回答