哇噢星球

 找回密码
 立即注册
搜索
热搜: 地形 技能 Lua

BAT/CMD 批处理示例:IF/ELSE IF/ELSE 多重分支+条件判断处理+引用另一个批处理文件里的变量

[复制链接]
皇家骑士 发表于 2019-1-28 17:56:02 | 显示全部楼层 |阅读模式
写了个现成bat文件不想丢了备以后参考,就发到这好了。

_config.bat

[Shell] 纯文本查看 复制代码
rem Eg. D:\Program Files (x86)\WarCraft III Frozen Throne\
set dir_war3=D:\Program Files (x86)\WarCraft III Frozen Throne\

rem Eg. D:\War3_ORPG_Framework\
set dir_proj=%~dp0

rem Eg. D:\War3_ORPG_Framework\Editor\
set dir_editor=%~dp0Editor\

rem Eg. D:\War3_ORPG_Framework\Utility\
set dir_utility=%dir_proj%Utility\

rem Eg. D:\War3_ORPG_Framework\Editor\YDWE.exe
set file_ydwe=%dir_editor%YDWE.exe

rem Eg. D:\War3_ORPG_Framework\Map.w3x
set file_map=%dir_proj%Map.w3x

rem Eg. (Unit,Item,DropItem,Hero,Monster)
rem WARNING: Do not change the sequence unless you know what you're doing.
set list_table=(Unit,Item,DropItem,Hero,Monster)


_call.bat

[Shell] 纯文本查看 复制代码
@echo off

:start

  call _config.bat
  set option=%1
  if %option% == edit (
    goto step_edit
  ) else if %option% == compile_excel (
    goto step_compile_excel
  ) else if %option% == pack (
    goto step_pack
  ) else if %option% == unpack (
    goto step_unpack
  ) else if %option% == update_icon (
    goto step_update_icon
  ) else (
    echo "Unsupported Option: %option%"
    goto end
  )

:step_edit

  echo "Edit: %file_map%"
  start "" "%file_ydwe%" -loadfile "%file_map%"
  goto end

:step_compile_excel

  echo "Compile: Excel"

  echo "- 1 / 2 - Convert XLSX to CSV"
  for %%i in %list_table% do (
    python "%dir_utility%xlsx2csv\xlsx2csv.py" Data\%%i.xlsx _cache\Table\%%i.csv
  )

  echo "- 2 / 2 - Compile CSV to WarCraft3 Object Data"
  "%dir_utility%Processor\lua.exe" "%dir_utility%Processor\pack.lua"
  "%dir_utility%w3x2txt\build\lua.exe" "%dir_utility%w3x2txt\src\make.lua" %dir_proj%

  goto end

:step_pack

  echo "Pack: Map"
  w2l obj _cache\Map Map.w3x
  goto end

:step_unpack

  echo "Unpack: Map"
  w2l lni Map.w3x _cache\Map
  goto end

:step_update_icon

  cd "%dir_utility%WarCraft_Icon_Manager"
  call "install.bat"
  cd "%dir_proj%"

:end
回复

使用道具 举报

Archiver|手机版|小黑屋|哇噢星球  

GMT+8, 2019-2-18 13:41 , Processed in 0.072290 second(s), 12 queries , File On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表