FactorioSharp.Rcon
0.3.12
See the version list below for details.
dotnet add package FactorioSharp.Rcon --version 0.3.12
NuGet\Install-Package FactorioSharp.Rcon -Version 0.3.12
<PackageReference Include="FactorioSharp.Rcon" Version="0.3.12" />
paket add FactorioSharp.Rcon --version 0.3.12
#r "nuget: FactorioSharp.Rcon, 0.3.12"
// Install FactorioSharp.Rcon as a Cake Addin #addin nuget:?package=FactorioSharp.Rcon&version=0.3.12 // Install FactorioSharp.Rcon as a Cake Tool #tool nuget:?package=FactorioSharp.Rcon&version=0.3.12
Factorio RCON
Provide an RCON client for Factorio in .NET Standard 2.1. This library provides two clients:
FactorioRemoteConsole
: a low-level client that provides direct access to the factorio console, it allows to execute any string in the Factorio console through the RCON connection.FactorioRconClient
: a high-level client that exposes the runtime API model as C# symbols to help explore and type check the commands being executed
Quick start
The RCON interface must be enabled when running factorio. It must also be secured using a password.
Add the following parameters to the factorio launch command: --rcon-port 25575 --rcon-password factory
For example
bin\x64\factorio.exe --start-server saves/save.zip --rcon-port 27015 --rcon-password password
You should see a log message in the factorio console that looks like:
Info RemoteCommandProcessor.cpp:133: Starting RCON interface at IP ADDR:({0.0.0.0:27015})
Using the console
Once the server is running with RCON enabled, we can attach a client:
using FactorioSharp.Rcon.Core;
using FactorioRemoteConsole console = new("127.0.0.1", 27015);
bool connected = await console.ConnectAsync("password");
Console.WriteLine("Connected: " + connected);
You should now see a new log message in the factorio console:
Info RemoteCommandProcessor.cpp:252: New RCON connection from IP ADDR:({127.0.0.1:57463})
Using the client
The client compiles the C# expressions that it receives into Lua commands that are executed through the console:
using FactorioSharp.Rcon;
using FactorioRconClient client = new("127.0.0.1", 27015);
bool connected = await client.ConnectAsync("password");
Console.WriteLine("Connected: " + connected);
string mapString = await client.ReadAsync(g => g.Game.GetMapExchangeString());
Console.WriteLine($"Map string: {mapString}");
The specification used to generate the model is that of Factorio v1.1.104.
The compiler is available in the SpecificationCompiler
project.
Limitations
The client is meant to make writing Lua commands feel as much as possible like writing C# code. However, it is NOT the same.
External context
The command cannot use variables from outside the lambda that defines it because the translator that produces the Lua code doesn't have access to that. So the following code will result in an exception:
uint index = 1;
string playerName = await client.ReadAsync(g => g.Game.Players[index].Name);
To make it possible to use variables from the outside, the ReadAsync
and ExecuteAsync
methods can be given a context:
- either a single value:
uint index = 1;
string playerName = await client.ReadAsync((g, i) => g.Game.Players[i].Name, index);
- or multiple values as a dictionary:
uint index = 1;
Dictionary<string, object> context = new() {{ "index", index }};
string playerName = await client.ReadAsync((g, ctx) => g.Game.Players[(uint)ctx["index"]].Name, context);
WIP In a future version, it will be possible to use an anonymous object instead of a dictionary to remove the need of casting the values.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- OneOf (>= 3.0.263)
- OneOf.SourceGenerator (>= 3.0.263)
- RconSharp (>= 2.0.1)
- System.Text.Json (>= 8.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on FactorioSharp.Rcon:
Package | Downloads |
---|---|
FactorioSharp.Instrumentation
Factorio instrumentation for .NET Standard 2.1 |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.3.16 | 288 | 4/7/2024 |
0.3.15 | 362 | 4/4/2024 |
0.3.14 | 110 | 4/3/2024 |
0.3.13 | 205 | 4/2/2024 |
0.3.12 | 126 | 4/2/2024 |
0.3.10 | 208 | 4/1/2024 |
0.3.9 | 139 | 4/1/2024 |
0.3.8 | 244 | 4/1/2024 |
0.3.7 | 174 | 4/1/2024 |
0.3.6 | 180 | 3/31/2024 |
0.3.5 | 147 | 3/30/2024 |
0.3.4 | 142 | 3/30/2024 |
0.3.3 | 139 | 3/30/2024 |
0.3.2 | 173 | 3/30/2024 |
0.3.1 | 122 | 3/30/2024 |
0.3.0 | 167 | 3/30/2024 |