Lua Requires Generator (Batch Script)

Tools which are useful for mod development.
Post Reply
User avatar
xaetral
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Sun Apr 28, 2019 2:25 pm
Contact:

Lua Requires Generator (Batch Script)

Post by xaetral »

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)

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
All of this is under public domain, feel free to do whatever you want with it.

Post Reply

Return to “Development tools”