joystick.py not working

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
KimiYoriBaka
Miko-Class Veteran
Posts: 636
Joined: Thu May 14, 2009 8:15 pm
Projects: Castle of Arhannia
Contact:

joystick.py not working

#1 Post 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.

DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: joystick.py not working

#2 Post 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)

KimiYoriBaka
Miko-Class Veteran
Posts: 636
Joined: Thu May 14, 2009 8:15 pm
Projects: Castle of Arhannia
Contact:

Re: joystick.py not working

#3 Post 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.

Post Reply

Who is online

Users browsing this forum: No registered users