Skip to content

Instantly share code, notes, and snippets.

@fireundubh
Last active May 22, 2016 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fireundubh/667b685ad9f5e3358a9b596b42036949 to your computer and use it in GitHub Desktop.
Save fireundubh/667b685ad9f5e3358a9b596b42036949 to your computer and use it in GitHub Desktop.
@ECHO OFF
SETLOCAL
SET compiler="D:\Steam\steamapps\common\Fallout 4\Papyrus Compiler\PapyrusCompiler.exe"
SET flags="D:\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\Base\Institute_Papyrus_Flags.flg"
SET imports="D:\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User;D:\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\Base"
SET projects="D:\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\Projects"
SET output="D:\Steam\steamapps\common\Fallout 4\Data\Scripts"
CALL :ExpandPath %1
IF [%1] == [] (
ECHO. & ECHO Compiling... %CD%
%compiler% %CD% -all -op -o=%output% -i=%imports% -f=%flags% -release -final -q
) ELSE IF [%sourceExtension%] == [.psc] (
ECHO. & ECHO Compiling... %sourceFile:"=%
%compiler% "%sourceFile%" -op -o=%output% -i=%imports% -f=%flags% -release -final -q
IF EXIST %binaryPath% (
ECHO Operation succeeded.
) ELSE (
ECHO Operation failed. File does not exist: %binaryPath:"=%
GOTO Done
)
IF [%2] == [--test] (
IF EXIST %binaryPath% (
ECHO. & ECHO Removing compiled script...
DEL %binaryPath%
)
IF NOT EXIST %binaryPath% (
ECHO Operation succeeded.
GOTO Done
) ELSE (
ECHO Operation failed. File exists: %binaryPath:"=%
GOTO Done
)
)
) ELSE IF [%sourceExtension%] == [.ppj] (
ECHO. & ECHO Compiling... %projects:"=%\%sourceFile:"=%
%compiler% "%projects:"=%\%sourceFile:"=%" -q
) ELSE (
ECHO. & ECHO Compiling... %1
%compiler% "%1" -all -op -o=%output% -i=%imports% -f=%flags% -release -final -q
)
:Done
FOR /f "tokens=2-4 delims=/ " %%a IN ('date /t') do (SET finishDate=%%c-%%a-%%b)
FOR /f "tokens=1-2 delims=/:" %%a IN ('time /t') do (SET finishTime=%%a:%%b)
ECHO. & ECHO Done. [ %finishDate% %finishTime% ]
ENDLOCAL
:ExpandPath
SET sourceFolder=%~dp1
SET sourceFile=%~nx1
SET sourceExtension=%~x1
IF [%sourceExtension%] == [.psc] (
SET binaryPath="%output:"=%\%sourceFile:.psc=.pex%"
) ELSE (
SET binaryPath="%sourceFolder%%sourceFile%"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment