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

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

7.8k Downloads

Antenna class from part returns None

kpa23 opened this issue ยท 1 comments

commented

KSP 1.6.1 with RO mods.
Trying "Communotron 16" (part name = longAntenna)
Getting part and calling Antenna method returns None, so i can't access any of antenna properties.

P.S. Passive antena in avionics module doesn't show up at all.
example:

import krpc
import time

conn = krpc.connect(name='Science Test')
vessel = conn.space_center.active_vessel
# Get info about the vessels communications
comms = conn.remote_tech.comms(vessel)

print('Signal delay = %.4f seconds' % comms.signal_delay)

an = [x for x in vessel.parts.all if (not x.antenna is None)]
an = vessel.parts.with_name('longAntenna')
print(an)
for a in an:
    print(a.name)
    print(a.antenna) # prints None
# go by remote_tech
for a in comms.antennas:
    x = a.part
    print(x.title)
    print(x.antenna) # prints None
commented

This works as intended, although maybe poorly documented...

With Remote Tech installed, Part.antenna will always return None. Part.antenna only works with stock (remote tech modifies all the antennas in the game, so even though the part is stock, with Remote Tech installed it doesn't behave as stock).

To interact with the antenna, you need to use the Antenna object from the Remote Tech API (https://krpc.github.io/krpc/python/api/remote-tech/antenna.html#RemoteTech.Antenna). For example:

import krpc

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

parts = vessel.parts.with_name('longAntenna')
for part in parts:
    print(part.name)
    antenna = conn.remote_tech.antenna(part)
    print(antenna.has_connection)