PS3 Controller joysticks sticks

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
McPandaBurger
Prole
Posts: 16
Joined: Sat Apr 28, 2012 3:32 pm

Re: PS3 Controller joysticks sticks

Post by McPandaBurger »

I think I might be too new to lua and love to understand it correctly, but I'll give it a shot

Code: Select all

 local j = state[joy]
      if not j then
         state[joy] = {}
         j = state[joy]
         j.name = love.joystick.getName(joy)
         j.axes = {}
         j.numAxes = love.joystick.getNumAxes(joy)
         for axis = 1, j.numAxes do
            j.axes[axis] = 0
         end
correct me here if i'm not right:

you made a table called state.
you then assigned that to j
where you assign the values such as .getNumAxes

what I don't get is what this does:

Code: Select all

for axis = 1, j.numAxes do
            j.axes[axis] = 0
I'm not getting how that gives you each axis.

and most importantly I still don't get how I would refer to each axis if I wanted to use it in joystick.isDown.
Sorry dude I understand this must be very annoying to watch from your perspective, but keep in mind due to my noobness I've clearly got hung up on some ideas that are probably wrong for using the joysticks. Once I see it you way it'll all click I'm sure.

Thanks for you continued input It's helping a lot (second day using love / lua and doing any serious scripting)
I have no idea what I'm doing
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: PS3 Controller joysticks sticks

Post by bartbes »

Well, first I loop over every joystick, and assign the current joystick's info table to 'j', if it doesn't exist yet (so 'not j'), I create it, assigning default values to everything. (That's why I set every axis to 0 in my table.) If you go past that if, you can see where I actually get up-to-date information for the axes.
User avatar
McPandaBurger
Prole
Posts: 16
Joined: Sat Apr 28, 2012 3:32 pm

Re: PS3 Controller joysticks sticks

Post by McPandaBurger »

Cool cheers Dude, I'll give this some study and get my head around it and let you know if I blow anything up :P
I have no idea what I'm doing
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests