top of page
Search

Powershell VRChat OSC V2 Complete

  • Writer: kamiesiokam
    kamiesiokam
  • Jan 1
  • 3 min read

On the 1st of Jan 2026 I have made a compressed portable version of my script Here is a list and paragraph what the script does what is in the script What this package is:

This is a Windows PowerShell “Train Board” application that:

  • Monitors live UK train station data

  • Displays it in a single Windows Forms GUI

  • Sends formatted train updates into VRChat’s chatbox via OSC

  • Can be run as a .ps1 script or built into a standalone .exe

It’s very much in the same ecosystem as VRChat OSC tooling you’ve worked on before, just focused on UK rail data instead of VRChat instances/DNS.

Files in the ZIP

1. TrainBoard_with_StationInfo_restoreTotals.ps1 (main script)

This is the actual application.

2. run.cmd

A helper to:

  • Set the working directory correctly

  • Run the PowerShell script with ExecutionPolicy Bypass

  • Let you double-click to start it

3. build_exe.ps1

Uses PS2EXE to turn the PowerShell script into:

dist\TrainBoard.exe

4. README.txt

Explains how to run it and how to build the EXE.

What the main PowerShell script does

1. Data source (UK trains)

  • Uses the Huxley2 UK rail API

  • Polls live departure/arrival data for a user-selected station

  • Optionally fetches per-service details (/service/{rid}) when needed

⚠️ Train unit numbers (e.g. 800001) are not available via Huxley2 — the script explicitly notes this.

2. GUI (Windows Forms)

It creates one window divided into five sections:

  1. Trains due to arrive

  2. Trains due to depart (non-terminating)

  3. Terminating trains

  4. Ongoing trains

    • Trains that have departed within the last 10 seconds

  5. Station totals / platform summary

Each train row includes:

  • Service ID / headcode

  • Operator name

  • Platform (PLT)

  • Scheduled & actual times

  • Delay info

  • Destination

  • Train class (e.g. Class 800)

3. Delay & status highlighting

Color-coding logic:

  • 🟠 Delay > 10 minutes

  • 🔴 Delay > 15 minutes

  • Cancelled trains shown in red

This applies in both the GUI and VRChat output.

4. VRChat integration (OSC)

This is a big part of the script.

  • Sends /chatbox/input OSC messages

  • Posts one message per “ongoing train”

  • Includes terminating trains as well

  • Sends them sequentially, not all at once

  • Also sends:

    • Total train count

    • Platform summaries

This makes it readable inside VRChat instead of spamming the chatbox.

5. Smarter data handling

The script goes well beyond a basic API poller:

  • Departure time logic

    • Prioritizes atd (actual time of departure)

    • Falls back to eta / sta when necessary

  • Busy station fixes

    • If platforms are missing, it fetches service details

  • Destination correction

    • Uses later calling points if the API returns ambiguous destinations

  • Ongoing train detection

    • Uses actual departure timestamps instead of schedule guesses

6. Logging

Writes a log file that records:

  • API calls

  • Platform fetch attempts

  • Destination corrections

  • Time estimation attempts

  • Warnings and edge cases

Also:

  • Clears the PowerShell console every 10 minutes to keep it readable.

Operator → Train class mapping

The script contains a large lookup table like:

  • GWR → Class 800 / 802

  • LNER → Class 800 / 801 / 91

  • EMR → Class 170 / 222

  • Freight operators → Class 66 / 70 / 73, etc.

This is how it displays train types even though the API doesn’t provide unit numbers.

How the helpers work

run.cmd

Just does:

powershell -NoProfile -ExecutionPolicy Bypass -File TrainBoard_with_StationInfo_restoreTotals.ps1

No magic — it’s there for convenience.

build_exe.ps1

  • Uses PS2EXE

  • Produces a Windows EXE

  • Can optionally be:

    • GUI-only (no console)

    • Or console + GUI

In short

This script is:

  • A live UK train station monitor

  • With a Windows GUI

  • That also acts as a VRChat OSC broadcaster

  • Designed for streaming, VR worlds, or public displays

  • Carefully engineered to handle real-world rail data edge cases

 
 
 

Comments


bottom of page