Created setup.bat

This commit is contained in:
holy-jesus 2023-08-11 02:36:49 +05:00
parent 8ea25929ae
commit 9e8c47d9d8
2 changed files with 82 additions and 11 deletions

View File

@ -37,19 +37,21 @@ Compiling for the episodes is an excercise for the reader. (Should be similar bu
## Effect Voting on Twitch
If you stream on Twitch, you can make it so that viewers can vote for effects by sending chat messages. These instructions are specifically for Windows. If you're on Linux, you can figure it out.
1. Download and install [Python](https://en.wikipedia.org/wiki/Python_(programming_language)) 3.11 from [here](https://www.python.org/downloads/release/python-3113/).
2. Download the code. This is the green button that says "code" at the top. Click "Download ZIP" unless you want to use GitHub Desktop for some reason.
3. Extract the contents to any place on your computer. The only part you need are the files in the `twitch-integration` folder.
4. Press the Windows logo on your keyboard and R at the same time. It should bring up a small window named 'Run'. Type `cmd` in the text box and then click 'OK'. It should bring up a black text box.
5. Select the extracted requirements.txt in File Explorer and view the file's properties. Copy the file path next to "Location".
6. In cmd.exe, type `cd` followed by a space, then paste the file path and press Enter.
7. Now type `py -m pip install -U -r requirements.txt`. It should do a bunch of stuff.
8. In OBS, create a new text source.
1. Download the code. This is the green button that says "code" at the top. Click "Download ZIP" unless you want to use GitHub Desktop for some reason.
2. Extract the contents to any place on your computer. The only part you need are the files in the `twitch-integration` folder.
3. _(Optional)_ Double click on `setup.bat` in `twitch-integration` folder, it will complete steps 4-10. You can skip this step if you prefer to do these steps manually.
4. Download and install [Python](https://en.wikipedia.org/wiki/Python_(programming_language)) 3.11 from [here](https://www.python.org/downloads/release/python-3113/).
5. Press the Windows logo on your keyboard and R at the same time. It should bring up a small window named 'Run'. Type `cmd` in the text box and then click 'OK'. It should bring up a black text box.
6. Select the extracted requirements.txt in File Explorer and view the file's properties. Copy the file path next to "Location".
7. In cmd.exe, type `cd` followed by a space, then paste the file path and press Enter.
8. Now type `py -m pip install -U -r requirements.txt`. It should do a bunch of stuff.
9. Open Tools -> Scripts -> Python Settings. Change the Install Path to the folder where Python 3.11 is installed. If you allowed it to install to it's default place, this should be `C:/Users/___/AppData/Local/Programs/Python/Python311`. Replace `___` with your Windows user name. You can find what the name is by simply looking in `C:/Users`. If set correctly, it should say "Loaded Python Version: 3.11".
10. Click on "Scripts", click the `+` button, and select `twitch_integration.py` from the `twitch-integration` folder you extracted before.
11. Set 'Target channel' to your channel (i.e `acuifex` for `twitch.tv/acuifex`). Set 'Text Source' to your newly created text source's name. Set 'RCON password' to a password of your choice.
12. Press 'Reconnect to twitch' if you didn't automatically connect.
13. In Steam, right click on the mod and then click "Properties...". In 'LAUNCH OPTIONS', put `+developer 0 -usercon +ip 127.0.0.1 +rcon_password ___ +net_start +chaos_vote_enable 1`. Replace `___` with the RCON password that you entered in OBS. The `+developer 0` part is necessary for some reason, despite not seeming like it should be. You will also have to do this in Ep1 & 2 chaos if you want to use Twitch voting in them.
11. In OBS, create a new text source.
12. Set 'Target channel' to your channel (i.e `acuifex` for `twitch.tv/acuifex`). Set 'Text Source' to your newly created text source's name. Set 'RCON password' to a password of your choice.
13. Press 'Reconnect to twitch' if you didn't automatically connect.
14. In Steam, right click on the mod and then click "Properties...". In 'LAUNCH OPTIONS', put `+developer 0 -usercon +ip 127.0.0.1 +rcon_password ___ +net_start +chaos_vote_enable 1`. Replace `___` with the RCON password that you entered in OBS. The `+developer 0` part is necessary for some reason, despite not seeming like it should be. You will also have to do this in Ep1 & 2 chaos if you want to use Twitch voting in them.
It should work now. If it doesn't, 'Script Log' button in OBS might have useful info. You can test voting commands by typing in your Twitch chat, even if you're not streaming.
To remove Twitch integration, you can simply clear out the mod's launch options and select twitch-integration.py in OBS and then click the minus button.

View File

@ -0,0 +1,69 @@
@echo off
setlocal enabledelayedexpansion
setlocal enableextensions
py --version > nul 2>&1
if %errorlevel% neq 0 (
choice /C YN /M "Python is not installed. Do you want the script to install it"
IF errorlevel 2 (
echo Install Python and run this script again. You can download Python here: https://www.python.org
pause
exit
) else (
if not exist "pythoninstaller.exe" (
powershell -Command "Invoke-WebRequest https://www.python.org/ftp/python/3.11.4/python-3.11.4-amd64.exe -OutFile pythoninstaller.exe"
echo Python installer downloaded. Installing...
)
.\pythoninstaller.exe /passive AppendPath=1
del pythoninstaller.exe
echo Step 4 done.
)
) else (
Echo Step 4 already done.
)
py -c "import platform; print(f'Installed Python version: {platform.python_version()}'); exit(0) if tuple(map(int, platform.python_version().split('.'))) >= (3,10) else exit(1)"
if %errorlevel% neq 0 (
REM rcon==2.4.2 requires Python 3.10 or higher.
echo Python version 3.10 or higher is required. Please upgrade or uninstall Python and run this script again.
pause
exit
)
py -m pip install -r requirements.txt
if %errorlevel% neq 0 (
echo An error occurred while installing the requirements.
pause
exit
)
echo Steps 5, 6, 7 and 8 done.
set "iniFile=%appdata%\obs-studio\global.ini"
if exist "%iniFile%" (
findstr /c:"[Python]" "%iniFile%" > nul 2>&1
if !errorlevel! neq 0 (
py -c "import os; import sys; executable = '/'.join(sys.executable.split('\\')[:-1]); f = open(os.path.expandvars('${appdata}/obs-studio/global.ini'), 'a'); f.writelines(['\n', '[Python]\n', f'Path64bit={executable}\n']); f.close();"
echo Step 9 done.
) else (
echo Step 9 already done.
)
) else (
echo Can't find global.ini file. Try starting and closing OBS, then run this script again, if that doesn't help, perform step 9 manually.
)
set cnt=0
for %%A in (%appdata%\obs-studio\basic\scenes\*.json) do set /a cnt+=1
if %cnt% == 0 (
echo Couldn't find OBS scenes, you'll have to do step 10 manually.
) else if %cnt% == 1 (
py -c "import glob; import os; import json; print('You must run this script in twitch-integration folder.') or quit(0) if not os.path.exists(os.getcwd() + '\\twitch_integration.py') else None; f = open(glob.glob(os.path.expandvars('${appdata}/obs-studio/basic/scenes/*.json'))[0], 'r'); data = json.loads(f.read()); f.close(); quit(0) if any('twitch_integration.py' in script['path'] for script in data['modules']['scripts-tool']) else None; data['modules']['scripts-tool'].append({'path': os.getcwd().replace('\\', '/') + '/twitch_integration.py', 'settings': {}}); dump = json.dumps(data); f = open(glob.glob(os.path.expandvars('${appdata}/obs-studio/basic/scenes/*.json'))[0], 'w'); f.write(dump); f.close();"
echo Step 10 done.
) else (
py -c "import glob; import os; import json; print('You must run this script in twitch-integration folder.') or quit(0) if not os.path.exists(os.getcwd() + '\\twitch_integration.py') else None; user_input = input('In which profile to add twitch integration? Possible answer [' + ', '.join(path.split('\\')[-1].split('.')[0].lower() for path in glob.glob(os.path.expandvars('${appdata}/obs-studio/basic/scenes/*.json'))) + '] - '); print('Incorrect value. If you want to try again, run the script again.') or quit(0) if not os.path.exists(os.path.expandvars('${appdata}/obs-studio/basic/scenes/'+ user_input + '.json')) else None; f = open(os.path.expandvars('${appdata}/obs-studio/basic/scenes/'+ user_input + '.json'), 'r'); data = json.loads(f.read()); f.close(); quit(0) if any('twitch_integration.py' in script['path'] for script in data['modules']['scripts-tool']) else None; data['modules']['scripts-tool'].append({'path': os.getcwd().replace('\\', '/') + '/twitch_integration.py', 'settings': {}}); dump = json.dumps(data); f = open(os.path.expandvars('${appdata}/obs-studio/basic/scenes/'+ user_input + '.json'), 'w'); f.write(dump); f.close();"
echo Step 10 done.
)
echo Done.
pause