Unable to generate code for java and c# libraries with krpc-clientgen python tool while following tutorial
andandiv opened this issue ยท 2 comments
What happened?
I am trying to implement a new service for a server with krpc-clientgen by following the documentation, but krpc-clientgen fails to find service.
krpc-clientgen csharp LaunchControl LaunchControl.dll --ksp="D:\Games\steamapps\common\Kerbal Space Program" Error: b'Service LaunchControl not found\r\n'
I also tried to call krpc-clientgen with different arguments but tool still fails to find service
How can someone else reproduce it?
Generate dll file with example code from documentation:
using KRPC.Service;
using KRPC.Service.Attributes;
using KSP.UI.Screens;
namespace LaunchControl
{
/// <summary>
/// Service for staging vessels and controlling their throttle.
/// </summary>
[KRPCService (GameScene = GameScene.Flight)]
public static class LaunchControl
{
/// <summary>
/// The current throttle setting for the active vessel, between 0 and 1.
/// </summary>
[KRPCProperty]
public static float Throttle {
get { return FlightInputHandler.state.mainThrottle; }
set { FlightInputHandler.state.mainThrottle = value; }
}
/// <summary>
/// Activate the next stage in the vessel.
/// </summary>
[KRPCProcedure]
public static void ActivateStage ()
{
StageManager.ActivateNextStage ();
}
}
}
call krpc-clientgen csharp LaunchControl LaunchControl.dll --ksp="D:\Games\steamapps\common\Kerbal Space Program"
in cmd
(calling this way fails as well krpc-clientgen --ksp=/path/to/ksp csharp LaunchControl LaunchControl.dll LaunchControl.cs
)
What is your environment?
tool called via window's cmd and was installed via pip.
krpc-clientgen version 0.5.2
krpc version 0.5.2
Anything else we need to know?
No response
I tried it (although, in my existing service code base I admit) and it works just fine. I was able to build LaunchControl service from the provided example and generate client code.
Works fine for me too. The error would suggest that the krpc-servicedefs tool isn't returning anything to krpc-clientgen.
If you run:
krpc-servicedefs "D:\Games\steamapps\common\Kerbal Space Program" LaunchControl LaunchControl.dll
Do you get anything? I get this:
{
"LaunchControl": {
"id": 4287385107,
"documentation": "",
"procedures": {
"ActivateStage": {
"id": 1,
"parameters": [],
"game_scenes": [
"FLIGHT"
],
"documentation": ""
},
"get_Throttle": {
"id": 2,
"parameters": [],
"return_type": {
"code": "FLOAT"
},
"return_is_nullable": false,
"game_scenes": [
"FLIGHT"
],
"documentation": ""
},
"set_Throttle": {
"id": 3,
"parameters": [
{
"name": "value",
"type": {
"code": "FLOAT"
}
}
],
"game_scenes": [
"FLIGHT"
],
"documentation": ""
}
},
"classes": {},
"enumerations": {},
"exceptions": {}
}
}