move the ship

Hello, I need aid to be able to move a ship with aid of the keyboard would like to move arrives it, down, left, right, ahead, back

I am using the zeta variable so that it can raise or lower whenever the button is pressed

the actor is naveActor i want move

import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.actor import Actor
from direct.interval.IntervalGlobal import *
import math

#importar para que salga presionando boton
from direct.showbase.DirectObject import DirectObject
import direct.directbase.DirectStart 
import sys

#Texto en pantalla
#from direct.gui.OnscreenText import OnscreenText  

zeta=1

#cargar sonido
mySound = loader.loadSfx("planeador.mp3")
mySound.play()


#Leer el primer escenario modelo
environ = loader.loadModel("models/streetscene/street-scene")
environ.reparentTo(render)
environ.setScale(0.5,0.5,0.5)
environ.setPos(0,40,-7)

#Lectura del actor nave fighter
naveActor = loader.loadModel("models/fighter/fighter")
naveActor.setScale(0.05,0.05,0.05)
naveActor.reparentTo(render)

class World(DirectObject): 
   def __init__(self): 
      self.accept("escape",sys.exit)
-------------------------------------------
      self.accept("s",subir)
      def subir():
          zeta = zeta + 1
-------------------------------------------
###I want add 1 to trajectory (zeta+1)###

w= World() 

#creacion de puntos de intervalos
navePosInterval1= naveActor.posInterval(13,Point3(0,20,zeta), startPos=Point3(0,40,zeta))
navePosInterval2= naveActor.posInterval(13,Point3(0,40,zeta), startPos=Point3(0,20,zeta))
naveHprInterval1= naveActor.hprInterval(3,Point3(0,0,0), startHpr=Point3(180,0,0))
naveHprInterval2= naveActor.hprInterval(3,Point3(180,0,0), startHpr=Point3(0,0,0))

#secuencia de intervalos
navePace = Sequence(navePosInterval1, naveHprInterval1, navePosInterval2, naveHprInterval2, name = "navePace")
navePace.loop()

#para que la camara siga al actor
#camera.reparentTo(naveActor)
#camera.setY(-0.03)
#camera.setZ(3)
#camera.lookAt(naveActor)

run()

The error that marks is:
World instance has no attribute “subir”

In the function, it must go in outside the class?

Somebody could help me to that east code worked so that increases z and the actor raises (ship) and I already could do it with the other coordinates.

You define subdir after you use it. Move the subdir to a place above where you would use it.

There is another way so the function does not need to be defined before it’s called. Make it a function in the class, and because it’s a class function then, you need to call it with self.subir. Like:

class World(DirectObject):
   def __init__(self):
      self.accept("escape",sys.exit)
      self.accept("s",self.subir)
   def subir(self):
      zeta = zeta + 1 

Btw. your coding style is horrible this way. I suggest putting the rest also in the class constructor or don’t use classes at all.