The online racing simulator
Godot InSim
For anyone using the Godot game engine, I released an InSim library written in GDScript, which includes support for InSim, OutSim OutGauge and InSimRelay.

GitHub link to the library (MIT license)
GitHub link to a very simple demo



The library supports InSim version 9 as of LFS version 0.7F.

What is included:
  • All InSim packets are implemented.
  • All text input is done from UTF8 and converted to LFS format, all packets convert text back to UTF8.
  • OutSim can be used from the configuration file.
  • OutGauge can be used from the configuration file.
  • InSimRelay is available.
  • There are some utility functions in the GISUtils class for converting units.
Feel free to try it if you're interested, I will update with examples as I have time to work on them.
There are also a .pth file reader and a .smx file reader included, for 3D rendering.


Special thanks:
Flame CZE and his Node InSim library, where I found how to parse car names for mods and took inspiration for text conversion.
I found some time to work on text encoding, once again shamelessly adapting/stealing code from Flame CZE and adapting it to Godot.
I have released version 0.8.1 on GitHub containing this feature as well as fixes for several other issues with various packets.


I should now have everything I wanted to add (unless I'm forgetting something), so will bump the version to 1.0 after some more testing and bug fixing.

Some projects I am working on with this tool:
  • Telemetry recording and display
  • Live race stats (minimap with driver names, standings with tyre compounds, pit stops, time deltas, etc.)
  • PTH and SMX file parsers to display them in 3D
This is awesome, tnx very much man.
Quote from Bokujishin :
  • Live race stats (minimap with driver names, standings with tyre compounds, pit stops, time deltas, etc.)

That would be really cool! Big grin
Very cool man, great job!
I just released version 0.9, including a bunch of fixes for various packets, better color handling for text (including stripping and conversion to/from BBCode), and utility functions for unit conversion (kph to mph, rad to deg and various other units).

I will now work on adding InSimRelay support, and try to test host packets, as I haven't managed to connect to InSim with host/admin privileges yet.

Thanks for the kind words!
Tnx very much for you hard work. The code is very readable, great job !
GodotInSim v1.2 is now available on GitHub.
I forgot to announce v1.1 last weekend, which added the new IPB packet in LFS 0.7F.

v1.2 goes back to using the "standard" plid syntax instead of player_id, which is a breaking change. It also fixes MST packets not interpreting messages starting with a slash a commands.

I'm also working on a more advanced tool as a demo, which will display race standings and driver statistics as well as a minimap showing blue/yellow flags and coloring cars by car/category/lapped/etc.
The goal is to allow preparing a race by specifying categories (e.g. P2/GT3), separating safety car/rescue vehicles in a dedicated category, and showing standings by category.
GodotInSim v1.3 is now available on GitHub.
It introduces more format customization for GISUtils time strings, the default grey color for LFSText, as well as fixes for LFSText (some characters in the extended characters of the Latin code page were not being converted properly), and a few other minor additions or quality of life improvements.

Also, while I haven't had as much time as I would like to work on actual projects using this tool, here are a couple sneak peeks:
  • Multi-class standings and live gaps, each class can be configured with arbitrary cars, and a "hidden/ignored" class can be used for safety car and other utility vehicles if necessary.
  • Live delta, displaying the time delta to the best recorded lap of the session, and colored arrows showing the derivative (current improvement (or lack thereof) over the best lap, that's the rate of change of the delta). Also displays final deltas for each sector.
Attached images
lfs_multiclass_gaps.png
lfs_delta.png
GodotInSim v1.4 is now available on GitHub.
It introduces the AI control packets added in LFS 0.7F2, and the project is now using Godot 4.4 (still in beta).
Alright, time to announce a new project with GodotInSim: GIS Hub (as in GodotInSim Hub).

This is an application, built on GodotInSim of course, that aims to become a small ecosystem, an InSim manager if you will; you get a GUI with tabs, where each tab corresponds to an InSim module, and therefore each module can provide its own user interface based on Godot Control nodes, as well as its own logic, based on a packet subscription system: modules initialize by telling the hub which packets they want to handle, and optionally which packets they want to ignore. They can also request notifications for packets sent by other modules, as well as the list of active modules.

As a bonus, all modules share the same InSim connection, so it can be interesting to make modules more specialized instead of having a very broad scope, without risking going over the maximum 8 connections LFS supports.

The idea here is to allow multiple people (or myself Big grin) to work on smaller-scale projects, and potentially use functionality from other modules where it makes sense (although I hope this won't make dependencies too big of an issue).

To allow for a single InSim connection, I start a separate instance of the app, create a TCP server on it (default port 29990), and connect the hub to it. The server connects to InSim and relays packets to and from the hub, which then dispatches them to the modules.

Since each module only needs to implement a few GISModule functions, but is completely free otherwise, you can even manage your own InSim connection if you want to bypass the server, while still being able to monitor other modules. OutSim and OutGauge, as well as InSimRelay, must be managed at the module level.

As a very quick example, here is a simple log module, which writes the contents of packets it receives, packets sent by other modules, and formats messages in a nicer way instead of the raw data: (yes, the messages are just tests and sent by the log module itself)


The InSim-managing server also includes a log, but writes it to a file instead, which means that even if the hub crashes because of a module error, packets keep being logged by the InSim connection, and the hub can reconnect to the server when restarted.

I am planning to make a few "core" modules, that would always be active, but other modules would be discovered at runtime and enabled or disabled dynamically by the user. Currently planned core modules include Hub functionality (general settings, InSim setup) and Player Management (UCID and PLID lists - this might be included in the Hub module instead), I am open to suggestions for additional core features (something that the vast majority of InSim apps could use). I will also try to convert my own projects to modules and distribute them along with this app.

Speaking of which: modules need to be exported as a Godot pck file (you need the Godot Editor for this), and placed in the modules folder next to the executable. The pck should be contained in a folder of the same name (modules/my_module/my_module.pck), to avoid conflicts in the filesystem after importing multiple modules.

Security: Modules have access to all Godot functionality, including potentially dangerous functions, like deleting files or simply executing any kind of code - you should only download pck files from trusted sources (ideally directly from the author's online code repository like GitHub or GitLab), and not from random people (that would be like launching .exe files random people send you).

GIS Hub features:
  • Modular InSim application with a TCP server managing packet input/output to/from LFS
  • Very basic crash protection for the InSim server, running in a separate process from the hub (does not prevent loss of functionality from the modules)
  • Allows for cohabitation of many independent modules while "consuming" only one InSim connection
  • Full InSim, OutSim, OutGauge and InSimRelay support on a per-module level
  • Module communication: modules can request the list of active modules, as well as monitor packets sent by other modules
Planned core module features:
  • (WIP) GIS Hub options, InSim setup
  • (Planned) UCID and PLID management
  • (Other) Open to more suggestions (for actual core features)
Planned modules:
  • (Done) Packet logs
  • (Planned) Message helper (write or copy/paste Unicode characters, change selected text's color, send as user or local message)
  • (WIP) Telemetry
  • (WIP) Race Stats
  • (WIP) Lap Delta (a certain someone has been persistently asking for this since I showed a proof of concept last summer Big grin, even though other apps already do this)
  • (Maybe) Setup Validation Tool (not sure it warrants a module as it does not actually use InSim (it would if setups could be sent via InSim), but why not)
I may also investigate the possibility of separating tabs into their own windows, so you can see multiple modules at the same time (e.g. minimap + telemetry + race stats).

I will probably repeat some of this, and include more details about actually creating modules, in a dedicated thread and in a link to the GitLab repository I'm hosting this on, once I have improved basic functionality and tested it properly.
Attached images
gishub_log_module.jpg

FGED GREDG RDFGDR GSFDG