kRPC: Control the game using C#, C++, Java, Lua, Python...

kRPC: Control the game using C#, C++, Java, Lua, Python...

7.8k Downloads

Cannot get parachute state after loading a save

Rhahi opened this issue ยท 0 comments

commented

What happened?

  1. Server start
  2. Start flying a craft and create a save file.
  3. Connect to KRPC
  4. Get a parachute part
  5. Get parachute's state. It should work.
  6. Load the save. I used KRPC to load it.
  7. Connect to KRPC.
  8. Get the parachute part and get its state.
  9. Error!
---------------------------------------------------------------------------
RPCError                                  Traceback (most recent call last)
Cell In[3], line 1
----> 1 chute.parachute.state

File [~/.julia/dev/SpaceLib/python/venv/lib64/python3.11/site-packages/krpc/services/spacecenter.py:15454](https://vscode-remote+ssh-002dremote-002bbuilder.vscode-resource.vscode-cdn.net/home/rhahi/.julia/dev/SpaceLib/python/~/.julia/dev/SpaceLib/python/venv/lib64/python3.11/site-packages/krpc/services/spacecenter.py:15454), in Parachute.state(self)
  15449 @property
  15450 def state(self) -> ParachuteState:
  15451     """
  15452     The current state of the parachute.
  15453     """
> 15454     return self._client._invoke(
  15455         "SpaceCenter",
  15456         "Parachute_get_State",
  15457         [self],
  15458         ["self"],
  15459         [self._client._types.class_type("SpaceCenter", "Parachute")],
  15460         self._client._types.enumeration_type("SpaceCenter", "ParachuteState")
  15461     )

File [~/.julia/dev/SpaceLib/python/venv/lib64/python3.11/site-packages/krpc/client.py:208](https://vscode-remote+ssh-002dremote-002bbuilder.vscode-resource.vscode-cdn.net/home/rhahi/.julia/dev/SpaceLib/python/~/.julia/dev/SpaceLib/python/venv/lib64/python3.11/site-packages/krpc/client.py:208), in Client._invoke(self, service, procedure, args, param_names, param_types, return_type)
    206 # Check for an error in the procedure results
    207 if response.results[0].HasField('error'):
--> 208     raise self._build_error(response.results[0].error)
    210 # Decode the response and return the (optional) result
    211 result = None

RPCError: Object reference not set to an instance of an object
Server stack trace:
  at KRPC.SpaceCenter.Services.Parts.Parachute.get_Deployed () [0x00022] in <7ed7d61af49940fa8a93b5df435e46bc>:0 
  at KRPC.SpaceCenter.Services.Parts.Parachute.get_State () [0x0002e] in <7ed7d61af49940fa8a93b5df435e46bc>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <9577ac7a62ef43179789031239ba8798>:0

How can someone else reproduce it?

User specific configuration:

  • Hostname
  • A vessel with a part tag "chute" on parachute of Kerbal X.
  • A save file called "kerbalx_chute" which situates the upper stage of Kerbal X at 20 km altitude, about to fall.
import krpc
conn = krpc.connect("Test", "10.0.0.51")

sc = conn.space_center
sc.load("kerbalx_chute")
ves = sc.active_vessel
chute = ves.parts.with_tag("chute")[0]
chute.parachute.state  # works well

sc.load("kerbalx_chute")
sc = conn.space_center
ves = sc.active_vessel
chute = ves.parts.with_tag("chute")[0]
chute.parachute.state  # does not work.

What is your environment?

  • KSP 1.12.3
  • Mods: KRPC 0.5.3, KOS, LaserDist
  • Python: 3.11.2

Anything else we need to know?

  • Might be a similar issue with this #210