Skip to content

Instantly share code, notes, and snippets.

@muink
Created July 8, 2018 13:23
Show Gist options
  • Select an option

  • Save muink/a6d92a01ae7d40d05be7a662e197bd5f to your computer and use it in GitHub Desktop.

Select an option

Save muink/a6d92a01ae7d40d05be7a662e197bd5f to your computer and use it in GitHub Desktop.
@echo off
:init
set /a "num=0, offset_x=-30, offset_y=-30">nul
set /a "x_l=1+%offset_x%, x_h=60+%offset_x%, y_l=1+%offset_y%, y_h=60+%offset_y%">nul
(echo.{
echo. "blueprint": {
echo. "icons": [
echo. {
echo. "signal": {
echo. "type": "item",
echo. "name": "pumpjack"
echo. },
echo. "index": 1
echo. }
echo. ],
echo. "entities": [
)>1.txt
setlocal enabledelayedexpansion
(for /l %%y in (%y_l%, 1, %y_h%) do (
for /l %%x in (%x_l%, 1, %x_h%) do (
set /a num+=1
(
echo. {
echo. "entity_number": !num!,
echo. "name": "pumpjack",
echo. "position": {
echo. "x": %%x,
echo. "y": %%y
echo. }
)
if "%%x" == "%x_h%" (
if "%%y" == "%y_h%" (
echo. }
) else (
echo. },
)
) else (
echo. },
)
)
))>>1.txt
endlocal
(echo. ],
echo. "item": "blueprint",
echo. "label": "pumpjack",
echo. "version": 0
echo. }
echo.}
)>>1.txt
goto :eof
面积60x60
数量60x60
30 30
30 *30
顺序从坐往右再往下
-1-1 | +1-1
|
------+----->
|*
-1+1 \|/+1+1
中点 1x1
中心偏移 -30x-30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment