Lua Requires Generator (Batch Script)
Posted: Sun Oct 01, 2023 7:13 pm
To help making my big overhaul mod I made a little batch script that scans all the ".lua" files in the directory "./prototypes" (yes, even subfolders) and append each corresponding require to a fresh data.lua script.
In case that script is of any use to somebody else, here is it: (just put it in a text file and rename it with a .bat extension)
All of this is under public domain, feel free to do whatever you want with it.
In case that script is of any use to somebody else, here is it: (just put it in a text file and rename it with a .bat extension)
Code: Select all
@echo off
del data.lua
echo --This file has been automatically generated using Xaetral's batch script>>data.lua
for /r %~dp0prototypes %%f in (*.lua) do call :func %%f
goto end
:func
set z=%1
call set z=%%z:%~dp0=%%
set z=%z:\=.%
echo require("%z:.lua=%")>>data.lua
goto :eof
:end
echo --This file has been automatically generated using Xaetral's batch script>>data.lua