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

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

7.8k Downloads

Open Cargo Bay impossible

Hansastro opened this issue ยท 3 comments

commented

Opening a Cargo Bay produce an error in execution by changing the open state of the cargo_bay. The value is readable but written produce the error.

Object used: Service Bay 1,25m
KSP version 1.4.3 and 1.4.4
KRPC Version: 0.4.6

Script to reproduce:
import krpc
import time

conn = krpc.connect()
vessel = conn.space_center.active_vessel

for part in vessel.parts.all:
    if part.name == 'ServiceBay.125':
        if part.cargo_bay:
            print("Part {} {}\n".format(part.name, part.cargo_bay.open))
            part.cargo_bay.open = True
time.sleep(5)

Generated output:

Part ServiceBay.125 False

Traceback (most recent call last):
File "listParts.py", line 12, in
part.cargo_bay.open = True
File "", line 1, in
File "/home/jean-phi/Projects/KSP_Adventure/krpc-env/lib/python3.5/site-packages/krpc/client.py", line 140, in _invoke
raise self._build_error(response.results[0].error)
krpc.error.RPCError: Field '.BaseEvent.guiName' not found.
Server stack trace:
at System.Linq.Enumerable.First[BaseEvent] (IEnumerable1 source, System.Func2 predicate, Fallback >fallback) [0x00000] in :0
at System.Linq.Enumerable.FirstOrDefault[BaseEvent] (IEnumerable1 source, System.Func2 predicate) >[0x00000] in :0
at KRPC.SpaceCenter.Services.Parts.CargoBay.get_OpenEvent () [0x00000] in :0 >
at KRPC.SpaceCenter.Services.Parts.CargoBay.set_Open (Boolean value) [0x00000] in unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke >>>> (object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0

commented

I can reproduce the error using kRPC 0.4.6 downloaded from the github release page, but not when recompiling it from source. There is a similar strange build related error in #483

I must have built the release incorrectly, but I can't work out what went wrong. Can you try this release to see if it works for you: https://krpc.s3.amazonaws.com/deploy/master/1195.1/krpc-0.4.7-20-g63d290b.zip

commented

With your version it works. It is possible to read and write the value and the door open and closed correctly.

commented

Should be fixed in v0.4.7. Please reopen if not.