Skip to content

Instantly share code, notes, and snippets.

@MikuAuahDark
Last active November 8, 2024 00:29
Show Gist options
  • Save MikuAuahDark/eabf54e9db3f5004e3ccd9a72f0d79d5 to your computer and use it in GitHub Desktop.
Save MikuAuahDark/eabf54e9db3f5004e3ccd9a72f0d79d5 to your computer and use it in GitHub Desktop.
NPPS4 Run Script
#!/bin/bash
socat tcp-listen:51376,fork,reuseaddr tcp:$1:51376

How to run NPPS4 locally

Big Disclaimer: NPPS4 is currently work-in-progress!

Currently the recommended way to run NPPS4 is by running it locally in your PC/laptop and have the phone forward specific request to your PC/laptop. However running the server entirely on-device is also possible.

Important

Your phone must be allowed to install APK from unknown sources. If your phone is managed using parental control or other control by your organization and does not allow sideloading, then you can't run any form of private servers.

Phone Setup

There are 2 ways to perform phone setup:

  1. Using SIF patcher
  2. Using Termux

Which method to pick?

  • If you plan on hosting the whole server in your phone, pick option 2.
  • If your PC (W)LAN IP is dynamic, pick option 2.
  • If you don't mind signing the APK yourself and your PC (W)LAN is static, pick option 1.

SIF Patcher

Step 1: Open https://ethanaobrien.github.io/sif-patcher/ in your PC.

Step 2: Specify http://<PC (W)LAN IP>:51376 for the Server URL.

Important

Type the http:// too. Peplace the <PC (W)LAN IP> with your PC (W)LAN IP address. Don't replace http:// with https://.

Step 3: Press the Patch button.

Step 4: Sign the APK!. This does not cover on the how to, but it's briefly explained in the SIF patcher website.

Step 5: Once the APK is signed, sideload them to your phone.

Termux

Step 1: Install SchoolIdol APK: https://kachagain.com/npps4/lovelive-community.apk or https://ethanthesleepy.one/public/lovelive/sif/lovelive-community.apk (both are same file).

Step 2: Install Termux from F-droid: https://f-droid.org/en/packages/com.termux/. Scroll down to see the text that says "Download APK".

Step 3: Open Termux. Please type these commands (you don't need to type # and any characters after it):

termux-change-repo # if asked anything, just press Enter
pkg update # if asked, type Y and enter
pkg upgrade # if asked, type Y and enter
exit

Termux will exit after you type exit and press enter. It's normal.

Now you have 2 ways of running NPPS4:

  1. NPPS4 in PC/Laptop
  2. NPPS4 entirely in device

Which option to pick?

  • If you plan on contributing to the codebase, pick option 1.
  • If you don't have PC/laptop or want to run everything in your device, pick option 2.
  • Otherwise, pick option 1 (more reliable).

NPPS4 in PC/Laptop

Important

This method requires both your phone AND your PC/laptop connected to same (W)LAN. If you can't do that for particular reason, then the only way to run NPPS4 is through your device. The reason this method is recommended is that it will be easy to modify the code as needed and if you're willing to contribute changes to the codebase.

Warning

For Windows users, the usage of Command Prompt is assumed! Using any other shell is not supported (this includes any version of Powershell and git-bash/MinGW/MSYS(2)/Cygwin shell). If you insist on using something other than Command Prompt, proceed on your own and make sure to know how to account for the command differences.

Step 0: There are certain prerequisite you need to install: Git and Python 3.12. Have them installed first. On Windows, if you have multiple Python versions and 3.12 is not the default python, replace any python calls to py -3.12. In Linux case, replace them with python3.12. This tutorial doesn't cover on how to get Python 3.12 on Linux in case your distro doesn't provide one!

Step 1: Open Terminal/Command Prompt (referred as "Terminal" from now on). Set the terminal directory to any directory you like.

Step 2: Run git clone https://github.com/DarkEnergyProcessor/NPPS4 npps4.

Step 3: Enter npps4 directory in your terminal using cd npps4.

Step 4: Create new Python virtual environment using python -m venv venv.

Step 5: Activate the virtual environment. In Windows, it's venv\Scripts\activate. In Linux, it's source venv/bin/activate.

Step 6: Run pip install -r requirements.txt.

Step 7: Copy config.sample.toml to config.toml.

Step 8: Modify config.toml. Find backend = "none" and replace none with n4dlapi. Find server = "http://localhost:8000" and replace http://localhost:8000 with https://ll.sif.moe/npps4_dlapi. Save it afterwards.

Step 9: Run alembic upgrade head.

Step 10: Run uvicorn npps4.run.app:main --port 51376 --host <PC/laptop LAN IP> --reload. Look your LAN IP address in Task Manager (Windows) or with ip a (Linux). Alternatively, you can specify 0.0.0.0 but it can be considered security risk. NPPS4 is now running.

Step 11: (skip if picking #1 for phone setup) Reopen Termux in the phone then type these commands (as-is, including all the symbols but skip # and any characters followed by it afterwards):

pkg install socat # if asked, type Y and enter
nano npps4_run.sh # Please re-type the contents of npps4_run.sh in this Gist. To save, use Ctrl+X -> Y -> Enter.
chmod +x npps4_run.sh

Step 12: (skip if picking #1 for phone setup) Run ./npps4_run.sh <PC/laptop LAN IP>. Unlike in Step 10, you can't specify 0.0.0.0 here, so look up your PC/laptop (W)LAN IP address at Step 10.

Step 13: Open SchoolIdol and it should connect successfully.

Note

To re-run the server, you need to repeat step 5, 10, 12, and 13.

NPPS4 in Device/Phone

Important

This method requires knowledge on Unix command, im particular copying files, executing command, and modifying text files through TUI. This is because you'll do that entirely in Termux without anny help on GUI apps. If you're bothered learning them, don't use this method!

Warning

Your Mielage May Vary. There have been reports with reliability issues with this method (including but not limited to: transmission error and slow performance). If you experience either of them, please blame your Android ROM vendor of having too aggresive optimization to background apps. Not to mention instability of Termux packages.

Running NPPS4 in phone requires using Alpine Proot.

First of all, setup Alpine Proot and its necessary bits to be able to run NPPS4 (only need to be done once):

Step 1: Open Termux and run these commands (one line per command; you don't need to type # and any characters after it):

termux-change-repo # if asked anything, just press Enter
pkg update # if asked, type Y and enter
pkg upgrade # if asked, type Y and enter
pkg install proot-distro
proot-distro install alpine
proot-distro login alpine

Step 2: You should be in Alpine Proot, indicated by # shell instead of $. Run these commands (one line per command):

apk update
apk upgrade
apk add --update python3 py3-pip git

Step 3: Whilst inside Alpine Proot, run step 2 through 9 from above guide.

Step 4: Exit Alpine Proot and Termux by pressing Ctrl+D twice (in sequence, so Ctrl+D then Ctrl+D).

To run the server (needs to be done everytime):

  1. Open Termux and enter the Alpine Proot using proot-distro login alpine.
  2. Enter the NPPS4 installation using cd npps4.
  3. Run bash npps4_run.sh. In here, open the game and it should connect.
  4. To stop the server, press Ctrl+C. To close Alpine Proot and Termux, press Ctrl+D twice (in sequence, so Ctrl+D then Ctrl+D).

How to change in-game language

Assume you're using the APK from link above (any options for phone setup), the app is bilingual. The game will be in Japanese if your device language is Japan, but English otherwise. If you want to change it manually, go to its App Settings and change the Language there (Android 13 or later). On Android 12 or earlier, the only way to change it is by changing the entire system language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment