need help understanding this code

This code is from the blender game kit 2.0 (sub racer) it is used to make the bullets faster then the sub. I get everything, except for a few unexplained additions that are not notated in the book for why they are there. I just know removing these parameters does not initiate the add object actuators. Here is the code, and I’ll explain what I need help with.

Gun script

This script takes the velocity of the ship into account for firing the cannons

also uses instantAddObject to prevent 1 frame lag of the Add Object Actuator

import GameLogic

cont = GameLogic.getCurrentController()
me = cont.getOwner()

fire = cont.getSensor(“Fire”)
g1 = cont.getActuator(“G1”)
g2 = cont.getActuator(“G2”)

if fire.isPositive():
ys = me.getLinearVelocity(1)[1]

As I said, I get all of this except for a few parts of this, " ys = me.getLinearVelocity(1)[1]" line. I know it assigns the velocitry of the ship to ys, which is later used to add to the initial force of the bullet, but when I find “getLinearVelocity()” it does not explain ‘(1)[1]’ what that details I have no clue, it looks like it activates the call and starts at array point 1, but I don’t I understand this very much.

Anyone think they could break this down a bit more for me?

the argument to getLinearVelocity is to indicate whether the vector to return is in local or in world coordinates. If its 1 (the default) you get world coordinates (world coordinates take into account any parent relationships etc). The return value of the function is a vector. A Blender vector is subscriptable, so [1] will get you the y-component.

for more info check

OK, thanks dude, that makes a lot of sense now, well kinda anyways. Because what that’s saying is to get the linear velocity on the global axes, axes ’ y ', but it needs to be on the local axes because the object is connect to empties which display local coordinates, and so it only measures the forward speed of the ship.