Python bindings behavior

Find any bugs in Vega Strike? See if someone has already found it, or report them here!
Post Reply
pyramid
Expert Mercenary
Expert Mercenary
Posts: 988
Joined: Thu Jun 15, 2006 1:02 am
Location: Somewhere in the vastness of space
Contact:

Python bindings behavior

Post by pyramid »

I'm trying to determine if player is docked to a planet or not by using the following code:

Code: Select all

        playa=VS.getPlayer()
        self.startplanet=unit.getUnitByName('Atlantis')
        print "isDocked: "
        print playa.isDocked(self.startplanet)
        print "isCleared: "
        print playa.IsCleared(self.startplanet)
No matter if I am docked with the planet or already in space, with both bindings (isDocked, IsCleared) I get a 'False'. I suppose 'IsCleared' is meant for docking clearance anyway, At least 'isDocked' should return true when I am in the hangar, right?
ace123
Lead Network Developer
Lead Network Developer
Posts: 2560
Joined: Sun Jan 12, 2003 9:13 am
Location: Palo Alto CA
Contact:

Post by ace123 »

I think it's flipped... i.e. you ask the planet if the player is docked:

Code: Select all

        playa=VS.getPlayer()
        self.startplanet=unit.getUnitByName('Atlantis')
        print "isDocked: "
        print self.startplanet.isDocked(playa)
        print "isCleared: "
        print self.startplanet.IsCleared(playa) 
pyramid
Expert Mercenary
Expert Mercenary
Posts: 988
Joined: Thu Jun 15, 2006 1:02 am
Location: Somewhere in the vastness of space
Contact:

Post by pyramid »

ace123 wrote:I think it's flipped... i.e. you ask the planet if the player is docked
That not's the point (anyway there is no binding like isUndocked). What I was saying is that the property always returns 'FALSE' no matter if I'm docked or not.
What I would expect from a boolean variable is to return:
* isDocked = true, when I am in a station
* isDocked = false, when I have undocked

This however doesn't seem to be the case, at least with planets. Haven't tried on stations, but planets are basically units in the same way as stations are, so the treatment should be equal in this binding.
It's either a problem of the code/python interface (improbable) or a bug in the code itself.
ace123
Lead Network Developer
Lead Network Developer
Posts: 2560
Joined: Sun Jan 12, 2003 9:13 am
Location: Palo Alto CA
Contact:

Post by ace123 »

Sorry... flipped maybe wasn't the right term for me to use.

The object and the argument are switched from what would be obvious:

The correct code is:
Base.isDocked(player)

Instead of doing:
player.isDocked(Base)

The reason is that the Base unit is what holds the list of docking ports. Therefore the base holds the master list of who is docked to it.

In theory it could have been the other way around, but that was a decision made a while ago.
pyramid
Expert Mercenary
Expert Mercenary
Posts: 988
Joined: Thu Jun 15, 2006 1:02 am
Location: Somewhere in the vastness of space
Contact:

Post by pyramid »

ace123 wrote:The correct code is:
Base.isDocked(player)
That explains it all. It's less intuitive this way but makes absolute sense from the code handling point of view. And one gets used to it if you remember reading this line from right to left.

Happy :D :lol: :wink: :)

Many thanks.
Post Reply