Page 1 of 1

joystick.py not working

Posted: Fri Apr 12, 2013 8:23 pm
by KimiYoriBaka
my code:

Code: Select all

        joysticks = []
        for j in range(pygame.joystick.get_count()):
            joysticks.append(pygame.joystick.Joystick())
            joysticks[j].init()
the error:

Code: Select all

Full traceback:
  File "C:\vns\renpy-6.13.12\renpy\execution.py", line 265, in run
  File "C:\vns\renpy-6.13.12\renpy\ast.py", line 632, in execute
  File "C:\vns\renpy-6.13.12\renpy\python.py", line 972, in py_exec_bytecode
  File "game/script.rpy", line 12, in <module>
  File "game/tennis.rpy", line 709, in tennis
  File "C:\vns\projects\sup tennis\renpygame\joystick.py", line 27, in __init__
NameError: global name 'pygame' is not defined
the line that it's pointing to:

Code: Select all

self.joystick = pygame.joystick.Joystick(id)
I can't think of any way I could have screwed this up, and it really seems to be a problem with renpygame. I managed to get it working but simply deleting the __init__() function for Joystick, but that also stops me from using multiple joysticks in my game.

Re: joystick.py not working

Posted: Fri Apr 12, 2013 10:20 pm
by DragoonHP
If you're using renpygame shouldn't this

Code: Select all

self.joystick = pygame.joystick.Joystick(id)
be

Code: Select all

self.joystick = renpygame.joystick.Joystick(id)

Re: joystick.py not working

Posted: Sun Apr 14, 2013 5:21 pm
by KimiYoriBaka
look at the traceback a bit closer. that line is from the renpygame code, not mine.

also, I used the import method shown on the renpygame page in the wiki, which allows the code to refer to renpygame modules as pygame modules. I've only been doing so to avoid typing as much, but I don't think it would make a difference here, since the error is being caused within the renpygame.joystick code.