Page 2 of 2

Re: PS3 Controller joysticks sticks

Posted: Sun May 13, 2012 7:04 pm
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)

Re: PS3 Controller joysticks sticks

Posted: Sun May 13, 2012 7:56 pm
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.

Re: PS3 Controller joysticks sticks

Posted: Sun May 13, 2012 10:09 pm
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