SHARE
TWEET

Install Any Terraria TModLoader Version (Batch)

Imthedude025 Nov 28th, 2019 120 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2. ::Install Any TModLoader Version Via Batch                   ::
  3. ::Created by RU$$ [http://russdev.mooo.com/]                 ::
  4. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  5. @ECHO OFF
  6. @CD %TEMP%
  7. @setlocal enabledelayedexpansion
  8. @mode con:cols=120 lines=3000
  9. call :Config
  10. set "LoadMsg=Loading Scripts..."
  11. call :Progress
  12. goto GetScripts
  13.  
  14. :Config
  15. set "Counter=-5"
  16. set "CountN=5"
  17. set "Schalter=2"
  18. set "Width=0"
  19. set "LoadMsg="
  20. goto :EOF
  21.  
  22. :GetScripts
  23.  
  24. :: Get HTML Script
  25. ::
  26. ::::::::::::::::::::::
  27. powershell -c "Invoke-RestMethod -Uri "https://forums.terraria.org/index.php?threads/1-3-tmodloader-a-modding-api.23726/" -OutFile output.txt"
  28. call :Progress
  29.  
  30. :: Get Current Version
  31. ::
  32. :::::::::::::::::::::: Remove Everything Before -- Steam/GoG:
  33. for /f "delims=:" %%N in ('findstr /n Steam/GoG: output.txt') do if not defined N set /a N=%%N-1
  34. more +%N% "output.txt" >"1.txt"
  35. call :Progress
  36. :::::::::::::::::::::: Remove Everything After First -- <br />
  37. powershell -executionpolicy bypass -command "(Get-Content 1.txt -Raw) -replace '(?s)<br.*?>.+' | Set-Content 2.txt"
  38. call :Progress
  39. :::::::::::::::::::::: Remove Everything From Each Line After -- target
  40. powershell -executionpolicy bypass -command "(Get-Content 2.txt -Raw) -replace 'target.*' | Set-Content 3.txt"
  41. call :Progress
  42. :::::::::::::::::::::: Replace " <a href=" To " "
  43. powershell -executionpolicy bypass -command "(Get-Content 3.txt -Raw) -replace ' \<a href=', ' ' | Set-Content currentbuild.txt"
  44. call :Progress
  45.  
  46. :: Remove Temp Files
  47. if exist "1.txt" (del 1.txt)
  48. if exist "2.txt" (del 2.txt)
  49. if exist "3.txt" (del 3.txt)
  50. call :Progress
  51.  
  52. :: Get Older Versions
  53. ::
  54. :::::::::::::::::::::: Remove Everything Before -- bbCodeBlock-content">v
  55. for /f "delims=:" %%M in ('findstr /n bbCodeBlock-content\^"\^>v output.txt') do if not defined M set /a M=%%M-1
  56. more +%M% "output.txt" >"1.txt"
  57. call :Progress
  58. :::::::::::::::::::::: Remove Everything After First -- </div>
  59. powershell -executionpolicy bypass -command "(Get-Content 1.txt -Raw) -replace '(?s)</div>.+' | Set-Content 2.txt"
  60. call :Progress
  61. :::::::::::::::::::::: Remove Everything After Inbetween <div>
  62. powershell -executionpolicy bypass -command "(Get-Content 2.txt -Raw) -replace '\<div.*?\>' | Set-Content 3.txt"
  63. call :Progress
  64. :::::::::::::::::::::: Remove Everything From Each Line After -- target
  65. powershell -executionpolicy bypass -command "(Get-Content 3.txt -Raw) -replace 'target.*' | Set-Content 4.txt"
  66. call :Progress
  67. :::::::::::::::::::::: Replace " <a href=" To " "
  68. powershell -executionpolicy bypass -command "(Get-Content 4.txt -Raw) -replace ' \<a href=', ' ' | Set-Content 5.txt"
  69. call :Progress
  70. :::::::::::::::::::::: Replace "<br />" To ""
  71. powershell -executionpolicy bypass -command "(Get-Content 5.txt -Raw) -replace '\<br.*?\>', '' | Set-Content 6.txt"
  72. call :Progress
  73. :::::::::::::::::::::: Remove Everything After -- <a
  74. powershell -executionpolicy bypass -command "(Get-Content 6.txt -Raw) -replace '\<a.*?5""' | Set-Content 7.txt"
  75. call :Progress
  76. :::::::::::::::::::::: Remove Empty Lines
  77. powershell -executionpolicy bypass -command "(Get-Content 7.txt -Raw) -replace ('(?m)^\s*','').trim() | Set-Content oldversions.txt"
  78. call :Progress
  79.  
  80. :::::::::::::::::::::: Combine Text Files
  81. copy /b "currentbuild.txt"+"oldversions.txt" TLoadVersionsTEMP1.txt >nul
  82. call :Progress
  83. :::::::::::::::::::::: Remove Empty Lines In Text File
  84. powershell -executionpolicy bypass -command "(Get-Content TLoadVersionsTEMP1.txt -Raw) -replace ('(?m)^\s*','').trim() | Set-Content TLoadVersionsTEMP2.txt"
  85. call :Progress
  86. :::::::::::::::::::::: Replace "<br />" To ""
  87. powershell -executionpolicy bypass -command "(Get-Content TLoadVersionsTEMP2.txt -Raw) -replace 'Steam.*?GoG', 'Latest-Version' | Set-Content TLoadVersions.txt"
  88. call :Progress
  89.  
  90. :: Remove Temp Files
  91. ::
  92. ::::::::::::::::::::::
  93. if exist "1.txt" (del 1.txt)
  94. if exist "2.txt" (del 2.txt)
  95. if exist "3.txt" (del 3.txt)
  96. if exist "4.txt" (del 4.txt)
  97. if exist "5.txt" (del 5.txt)
  98. if exist "6.txt" (del 6.txt)
  99. if exist "7.txt" (del 7.txt)
  100. call :Progress
  101. if exist "output.txt" (del output.txt)
  102. if exist "TLoadVersionsTEMP1.txt" (del TLoadVersionsTEMP1.txt)
  103. if exist "TLoadVersionsTEMP2.txt" (del TLoadVersionsTEMP2.txt)
  104. if exist "oldversions.txt" (del oldversions.txt)
  105. if exist "currentbuild.txt" (del currentbuild.txt)
  106. call :Progress
  107. call :Config
  108. goto MenuList
  109.  
  110. :MenuList
  111. cls
  112.  
  113. Set "INPUT="
  114. Set "i=0"
  115.  
  116. Echo Select A Tmodloader Version:
  117. Echo(
  118.  
  119. Rem | Generate the list of items from textfile
  120. FOR /F "tokens=1,* delims=: " %%A IN (TLoadVersions.txt) DO (
  121.  
  122.     Rem | Set Strings
  123.     Set /A "i+=1"
  124.  
  125.     Rem | Save Variable As String
  126.     Set "Num!i!=%%B"
  127.  
  128.     Rem | Print String To Console
  129.     Echo [!i!] - %%A
  130.    
  131. )
  132. Echo [0] - Exit
  133.  
  134. Echo(
  135. Set /P INPUT=Set Your Choice And Press Enter:
  136. IF /I "!INPUT!"=="0" GOTO :EOF
  137.  
  138. Rem | Check For Valid Listing
  139. IF /I "!Num%INPUT%!"=="" (
  140.  
  141.     Rem | Number Not Listed!
  142.     cls
  143.     Echo ERROR: Number Was Not On The List.
  144.     Echo(
  145.    
  146.     Pause
  147.     goto MenuList
  148.  
  149. )
  150. cls
  151.  
  152. Rem | Remove Temp Files
  153. if exist "TLoadVersions.txt" (del TLoadVersions.txt)
  154.  
  155. Rem | Set String Based On Number
  156. Set "INPUT=!Num%INPUT%!"
  157.  
  158. Rem | Remove Spaces From End Of String
  159. for /l %%A in (1,1,100) do (if "!INPUT:~-1!"==" " set INPUT=!INPUT:~0,-1!)
  160. Set "net_int=!INPUT!"
  161. goto InstallMe
  162.  
  163. :InstallMe
  164. set "LoadMsg=Installing..."
  165. set "Counter=-25"
  166. set "CountN=25"
  167. call :Progress
  168.  
  169. :::::::::::::::::::::: Download File
  170. powershell -c "Invoke-RestMethod -Uri !INPUT! -OutFile x.zip"
  171. call :Progress
  172. :::::::::::::::::::::: Extract File
  173. powershell.exe -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('x.zip', 'DownloadedFiles'); }"
  174. call :Progress
  175. :::::::::::::::::::::: Rename Needed Files
  176. ren "%temp%\DownloadedFiles\Terraria.exe" "TerrariaModded.exe" >nul
  177. call :Progress
  178. :::::::::::::::::::::: Move Files
  179. move /Y "%temp%\DownloadedFiles\*.*" "C:\Program Files (x86)\Steam\steamapps\common\Terraria" >nul
  180. call :Progress
  181.  
  182. :: Remove Temp Files
  183. ::
  184. ::::::::::::::::::::::
  185. if exist "x.zip" (del x.zip)
  186. if exist "%temp%\DownloadedFiles" (rmdir /s /q "%temp%\DownloadedFiles")
  187. goto Completed
  188.  
  189. :Completed
  190. cls
  191. Echo SUCCESS: The ModLoader Has Finished Installing.
  192. Echo(
  193.  
  194. Pause
  195. goto :EOF
  196.  
  197. :: Progress Bar Function
  198. ::
  199. ::::::::::::::::::::::
  200. :Progress
  201. set /a Counter=%Counter% + !CountN!
  202. set /a Display=%Counter% / 2
  203. FOR /L %%A IN (1,1,%Display%) DO (
  204.     set Display=!Display!²
  205. )
  206. cls
  207. if %Counter% gtr 100 (Set /a "Counter=100")
  208. echo            !LoadMsg!                  %Counter%%%
  209. echo     ²!Display:~2,47!
  210. echo(
  211. goto :EOF
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top