[MOD/API] Named Pipes API

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

[MOD/API] Named Pipes API

Post by SirNukes » Mon, 25. Nov 19, 09:24

Download: https://github.com/bvbohnen/x4-projects/releases
Documentation: https://github.com/bvbohnen/x4-projects ... es_API.md


X4 Named Pipes API

Adds support for Windows named pipes for inter-process communication.
Named pipes are OS level psuedo-files which support inter-process communication.
Pipes avoid the overhead of disk access from normal files (eg. debug logs), and are bidirectional.
X4 will act as a client, with one or more an external applications serving the pipes.

There are three components to this API:
  • A low level lua plugin and corresponding dll for pipe access.
  • An MD wrapper that interfaces between the lua and MD pipe users.
  • A default, optional Python external pipe host server.
Requirements Installation
  • Place the named_pipes_api folder in extensions.
  • Place the X4_Python_Pipe_Server (exe or py) anywhere convenient.
    - Run this pipe server alongside X4.
Components
  • MD Pipe API
    This api is found in Named_Pipes.xml, and allows MD code to read or write pipes.
  • MD Server API
    This api is found in Pipe_Server_Host, and allows MD code to register a python module with the host server.
    The host (if running) will dynamically import the custom module.
    Such modules may be distributed with extensions.
  • Lua Pipe API
    The lower level support for X4 to use named pipes is located in Named_Pipes.lua.
    Basic pipe usage can ignore this level in favor of the MD api.
    Advanced usage may want to use this api directly.
  • Winpipe dll API
    The pipes themselves are accessed through a dll which wraps key Windows functions.
    This dll is limited to only what is needed: opening a pipe client, reading/writing/closing it, and error checking.
    If desired, the dll may be compiled freshly from source on github.
Last edited by SirNukes on Tue, 6. Jul 21, 01:21, edited 2 times in total.

User avatar
spin1/2
Posts: 288
Joined: Fri, 25. Nov 05, 11:58
x4

Re: [MOD/API] Named Pipes API

Post by spin1/2 » Wed, 27. Nov 19, 01:20

Hey,

I tried out the Simple Menu API (includes Lua Loader API), because my target is to create mission sequences like a visual novel.
For a simple test I took your "simple_menu_api_test", which means I had to inlcude the Hotkey API and the Namend Pipes API.

All four APIs are Version 1.0 and in the extensions folder. The server is running and shows the one line with the path.
When X4 is running it shows the Hotkey API and the Namend Pipes API in red (in the extensions menue).

thx for your work and help

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [MOD/API] Named Pipes API

Post by SirNukes » Wed, 27. Nov 19, 03:57

Thanks for trying it out. After checking a few things, my best guess is that the winpipe dll had an unnecessary dependency on visual studio. Version 1.0.1 is up with a fix.

Regarding the menu api, the extra test extension only uses the hotkey/pipes stuff for opening a standalone test menu (using shift+b). Without the pipes, that same test menu can also be opened using the options menu. (Also, the hotkey stuff uses 3.0 md commands, so won't work on 2.6, but the menu api should be fine.)

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [MOD/API] Named Pipes API

Post by SirNukes » Mon, 24. Feb 20, 10:08

Updated to 1.1. This changes the access timeout behavior a little bit. By default timeout is now disabled (used to be 10 seconds). When a timeout is requested by the user of this api, a new option is available to also flush out all pending accesses to the pipe that timed out. The change is motivated by the Key Capture API losing inputs due to their matching read requests having been timed out.

Misunderstood Wookie
Posts: 377
Joined: Mon, 15. Mar 04, 08:07
x4

Re: [MOD/API] Named Pipes API

Post by Misunderstood Wookie » Mon, 24. Feb 20, 10:27

You're going to have give some solid reasons why this is better then every other Lua API. I mean you require us to run server side software just to use it so what exactly does this do that is beneficial?

Is this just a method for live debug output?
Unless you're using a HDD I can't see how disk overhead is much concern tho.
*modified*
*X3 LiteCube User*
MOD GemFX Real Space Shaders
MOD Variety and Rebalance Overhaul Icon Pack
I lost my Hans and should not be flying Solo.
Image

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [MOD/API] Named Pipes API

Post by SirNukes » Mon, 24. Feb 20, 18:56

Misunderstood Wookie wrote:
Mon, 24. Feb 20, 10:27
You're going to have give some solid reasons why this is better then every other Lua API. I mean you require us to run server side software just to use it so what exactly does this do that is beneficial?
This API enables run-time communication with X4 from external processes. That is, you can send data *to* X4 dynamically. There is nothing comparable to it across any of the X games. (The closest I know of is that one modder that was trying to add multiplayer to X3 by messing around at the exe level.)

I leave to your imagination what can be done with such a capability. Personally, I actively use it for creating new hotkeys.

Misunderstood Wookie
Posts: 377
Joined: Mon, 15. Mar 04, 08:07
x4

Re: [MOD/API] Named Pipes API

Post by Misunderstood Wookie » Tue, 25. Feb 20, 03:35

I see so it's used to make things like we have for elite dangerous and push data to some their party tool or display live, or something else like maybe a live galaxy map which runs on a second screen all the time and shows everything you know ingame without slowing the game down having the map open hahaha
*modified*
*X3 LiteCube User*
MOD GemFX Real Space Shaders
MOD Variety and Rebalance Overhaul Icon Pack
I lost my Hans and should not be flying Solo.
Image

Inchínn
Posts: 18
Joined: Tue, 7. Mar 17, 21:37
x4

Re: [MOD/API] Named Pipes API

Post by Inchínn » Tue, 15. Feb 22, 19:28

Any mods that utilise this so far?

Would love a html map screen etc,

magitsu
Posts: 399
Joined: Wed, 12. Dec 18, 21:59
x4

Re: [MOD/API] Named Pipes API

Post by magitsu » Tue, 15. Feb 22, 23:24

Inchínn wrote:
Tue, 15. Feb 22, 19:28
Any mods that utilise this so far?

Would love a html map screen etc,
Mycu's External App.
https://github.com/mycumycu/X4-External-App

Inchínn
Posts: 18
Joined: Tue, 7. Mar 17, 21:37
x4

Re: [MOD/API] Named Pipes API

Post by Inchínn » Fri, 18. Feb 22, 15:39

magitsu wrote:
Tue, 15. Feb 22, 23:24
Inchínn wrote:
Tue, 15. Feb 22, 19:28
Any mods that utilise this so far?

Would love a html map screen etc,
Mycu's External App.
https://github.com/mycumycu/X4-External-App
i found it straight after my comment - its really slick, so cool to see the job offers on another screen without having to click into the menus.

I really hope they expand on its features.

User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 24950
Joined: Sun, 2. Apr 06, 16:38
x4

Re: [MOD/API] Named Pipes API

Post by X2-Illuminatus » Wed, 23. Feb 22, 21:25

Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

User avatar
beko
Posts: 53
Joined: Thu, 11. Jun 20, 21:14
x4

Re: [MOD/API] Named Pipes API

Post by beko » Sun, 26. Mar 23, 19:54

It's not yet ready for public usage and has some issues that need to be ironed out but… I present you: Named Pipes on Linux PC :D

https://beko.famkos.net/wp-content/uplo ... pc_too.jpg

Hooked into this great mod by using Lua-Socket with only a few extra lines of code. Used the "X4 External App" to get some noise on the socket and here we go :o
Last edited by Terre on Mon, 27. Mar 23, 08:38, edited 1 time in total.
Reason: Images posted directly to the forums should not be greater than 640x480 or 100kb, oversize image now linked

Strohmann
Posts: 2
Joined: Tue, 28. Mar 23, 07:19
x4

Re: [MOD/API] Named Pipes API

Post by Strohmann » Tue, 28. Mar 23, 07:34

beko wrote:
Sun, 26. Mar 23, 19:54
It's not yet ready for public usage and has some issues that need to be ironed out but… I present you: Named Pipes on Linux PC :D

https://beko.famkos.net/wp-content/uplo ... pc_too.jpg

Hooked into this great mod by using Lua-Socket with only a few extra lines of code. Used the "X4 External App" to get some noise on the socket and here we go :o
Great news! Where can I follow your progress?
P.S.: Great blog! Enthusiastic people are always admired. And I perfectly understand the state when setting up or learning something is one of the most exciting elements of the game.

User avatar
beko
Posts: 53
Joined: Thu, 11. Jun 20, 21:14
x4

Re: [MOD/API] Named Pipes API

Post by beko » Tue, 28. Mar 23, 10:18

Strohmann wrote:
Tue, 28. Mar 23, 07:34
Great news! Where can I follow your progress?
P.S.: Great blog! Enthusiastic people are always admired. And I perfectly understand the state when setting up or learning something is one of the most exciting elements of the game.
Thanks mate. My blog is my primary source and you can follow it thanks to bridges from various social media. They are linked in the upper left (not on mobile). I also have a tiny Discord channel where we're mostly bouncing ideas about SimPits around. Let me know if that is your jam :)

Currently looking for some testers to not run into "Works On My Machine"

Strohmann
Posts: 2
Joined: Tue, 28. Mar 23, 07:19
x4

Re: [MOD/API] Named Pipes API

Post by Strohmann » Tue, 28. Mar 23, 14:26

beko wrote:
Tue, 28. Mar 23, 10:18

Currently looking for some testers to not run into "Works On My Machine"
I'm ready to take part in testing.
But now there is not too much free time - all the time is occupied by a little baby and work.

I use X4 External App when playing on windows. I am also a Python backend developer, it would be interesting to understand how the Pipe-server works.

Is there a fork of the bvbohnen/mycumycu projects or instructions for the necessary changes?

User avatar
beko
Posts: 53
Joined: Thu, 11. Jun 20, 21:14
x4

Re: [MOD/API] Named Pipes API

Post by beko » Wed, 29. Mar 23, 19:45

I did fork it but I didn't push to it yet. Really hacking away every free second and writing a well versed tutorial is kinda obsolete the moment I start typing :| Wouldn't mind to walk you through and brainstorm some ideas.

Post Reply

Return to “X4: Foundations - Scripts and Modding”