Seite 285 von 342 ErsteErste ... 185 235 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 335 ... LetzteLetzte
Zeige Ergebnis 8.521 bis 8.550 von 10238

Lua Programming Help Thread

This is a discussion on Lua Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; could i see the section of code that that part is in, and the table that the data is being ...

  
  1. #8521
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    could i see the section of code that that part is in, and the table that the data is being loaded from again, as it is in the script


    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  2. #8522
    QJ Gamer Blue
    Points: 7.014, Level: 55
    Level completed: 32%, Points required for next Level: 136
    Overall activity: 0%

    Registriert seit
    Jan 2007
    Ort
    U.S.
    Beiträge
    405
    Points
    7.014
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Okay.

    Code:
    locations = {}
    
    while true do
    	pad = Controls.read()
    	screen:clear()
    	dx = pad:analogX()
    	dy = pad:analogY()
    
        if gamestate == "game" then
            if locations ~= nil then
    	    for i = 1, table.getn(locations) do
    	       screen:blit(locations[i].x,locations[i].y,dot)
                end
            end
       elseif gamestate == "menu" then
               pad = Controls.read()
            
            --if user is loading... took that out for this example
            if pad:square() and not oldpad:square() then
                  System.usbDiskModeDeactivate()
                  loadFile = io.open("Saved Sets/" .. loadFile2 .. ".txt","r")
                  number = 0
    
                  for line in loadFile:lines() do
                      number = number + 1
                  end
    
                  for j = 1, math.floor(number/2)*2, 2 do
                      xc = loadFile:read()
                      yc = loadFile:read()
    
                      table.insert(locations,{x=xc,y=yc})
                  end
    
                  loadFile:close()
    
                  System.usbDiskModeActivate()
                  gamestate = "game"
                  pausestate = "select"
            end
       end
    end
    That's the heart of it. It's taken from throughout the entire script but hopefully it makes sense. I can give you the whole thing if you want, but it's probably not necessary.

  3. #8523
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    hmm you know this part

    Code:
    xc = loadFile:read()
    yc = loadFile:read()
    could you check for me by printing the data to the screen before continuing what these are, because i think that what you are doing is this

    Code:
    xc = 4, 10
    yc = 4, 10
    so calling a screen:blit() with those valuse it is causing the loop in gettable error where 4, 10 is the value

    also try using the code that i made for you it does work, it loads and saves files easier, and you wouldnt get that error

    if what i said is the case then it would be easier to use the code that i made that i know works, than to recode what you have to work, because it isnt the right way to load data from a table anyway, not saying mine is the right way but it is better than the current method that you are using

    thanks
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  4. #8524
    QJ Gamer Blue
    Points: 7.014, Level: 55
    Level completed: 32%, Points required for next Level: 136
    Overall activity: 0%

    Registriert seit
    Jan 2007
    Ort
    U.S.
    Beiträge
    405
    Points
    7.014
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Printing them told me that they were nil. But I used the way you showed me a few posts ago, and it worked like a charm. Thanks a lot!

  5. #8525
    QJ Gamer Bronze
    Points: 5.381, Level: 47
    Level completed: 16%, Points required for next Level: 169
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    550
    Points
    5.381
    Level
    47
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von andyauff
    Okay.
    Code:
                  for j = 1, math.floor(number/2)*2, 2 do
                      xc = loadFile:read()
                      yc = loadFile:read()
    
                      table.insert(locations,{x=xc,y=yc})
                  end

    You are still not reading the file correctly.

    loadFile:read() is returning "x,y", correct? (where x and y are the co-ordinates in each case) So, you are basically stating:
    Code:
    xc = "x,y"
    yc = "x,y"
    Even if you stated:
    Code:
    xc,yc = "x,y"
    It still wouldn't work because Lua cannot convert "x,y" (A string) into a group of numbers.

    You would need something like this:
    Code:
    loc = loadFile:read()
    xc = string.sub(loc,1,string.find(loc,",") - 1)
    yc = string.sub(loc,string.find(loc,",") + 1)
    But even that wouldn't work because you are just reading the the first line over and over, you need to move forward a line every time. So you would need something like this: (I'm not sure what the for loop looping through in your code, but this is general)
    Code:
            if pad:square() and not oldpad:square() then
                  for line in io.lines("Saved Sets/" .. loadFile2 .. ".txt") do
                          table.insert(locations,{x=string.sub(line,1,string.find(line,",") - 1),y=string.sub(line,string.find(line,",") + 1)})
                  end
    
                  System.usbDiskModeDeactivate()
                  System.usbDiskModeActivate()
                  gamestate = "game"
                  pausestate = "select"
            end
    EDIT: Oh, I see. You are iterating in groups of 2, so your files are just stored as a list of numbers. in that case:
    Code:
                  local n = 0
                  for line in io.lines("Saved Sets/" .. loadFile2 .. ".txt") do
                          n = n + 1
                          if math.floor(n / 2) * 2 == n then
                                    locations[n / 2 + 1].y = line
                          else
                                    locations[(n - 1) / 2 + 1] = {x = line}
                          end
                  end
    Or if you are adding to an existing list:
    Code:
                  local p = table.getn(locations)
                  local n = 0
                  for line in io.lines("Saved Sets/" .. loadFile2 .. ".txt") do
                          n = n + 1
                          if math.floor(n / 2) * 2 == n then
                                    locations[p + n / 2 + 1].y = line
                          else
                                    locations[p + (n - 1) / 2 + 1] = {x = line}
                          end
                  end
    Geändert von Nielkie (04-24-2008 um 11:20 PM Uhr)

  6. #8526
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von andyauff
    Printing them told me that they were nil. But I used the way you showed me a few posts ago, and it worked like a charm. Thanks a lot!
    no problem, glad it worked
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  7. #8527
    QJ Gamer Blue
    Points: 7.014, Level: 55
    Level completed: 32%, Points required for next Level: 136
    Overall activity: 0%

    Registriert seit
    Jan 2007
    Ort
    U.S.
    Beiträge
    405
    Points
    7.014
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Nielkie
    You are still not reading the file correctly.

    loadFile:read() is returning "x,y", correct? (where x and y are the co-ordinates in each case) So, you are basically stating:
    Code:
    xc = "x,y"
    yc = "x,y"
    Even if you stated:
    Code:
    xc,yc = "x,y"
    It still wouldn't work because Lua cannot convert "x,y" (A string) into a group of numbers.

    You would need something like this:
    Code:
    loc = loadFile:read()
    xc = string.sub(loc,1,string.find(loc,",") - 1)
    yc = string.sub(loc,string.find(loc,",") + 1)
    But even that wouldn't work because you are just reading the the first line over and over, you need to move forward a line every time. So you would need something like this: (I'm not sure what the for loop looping through in your code, but this is general)
    Code:
            if pad:square() and not oldpad:square() then
                  for line in io.lines("Saved Sets/" .. loadFile2 .. ".txt") do
                          table.insert(locations,{x=string.sub(line,1,string.find(line,",") - 1),y=string.sub(line,string.find(line,",") + 1)})
                  end
    
                  System.usbDiskModeDeactivate()
                  System.usbDiskModeActivate()
                  gamestate = "game"
                  pausestate = "select"
            end
    I see what you mean, but that would be if I had the x and y values on the same line in the file. The way I had it was an x value on the first line, y on the second, x on the third, y on the fourth, etc. But I'm using a completely different method now, thanks to FaT3oYCG, so it's all good. But thanks :).

  8. #8528
    QJ Gamer Bronze
    Points: 5.381, Level: 47
    Level completed: 16%, Points required for next Level: 169
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    550
    Points
    5.381
    Level
    47
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von andyauff
    I see what you mean, but that would be if I had the x and y values on the same line in the file. The way I had it was an x value on the first line, y on the second, x on the third, y on the fourth, etc. But I'm using a completely different method now, thanks to FaT3oYCG, so it's all good. But thanks :).
    I updated my post when I saw what the for loop was doing. Anyway, it's always nice to know the reason for a problem.

  9. #8529
    QJ Gamer Blue
    Points: 7.014, Level: 55
    Level completed: 32%, Points required for next Level: 136
    Overall activity: 0%

    Registriert seit
    Jan 2007
    Ort
    U.S.
    Beiträge
    405
    Points
    7.014
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Nielkie
    I updated my post when I saw what the for loop was doing. Anyway, it's always nice to know the reason for a problem.
    Okay, thanks Nielkie. Yes, I agree, it is certainly important to understand the problem.

  10. #8530
    QJ Gamer Bronze
    Points: 7.637, Level: 58
    Level completed: 44%, Points required for next Level: 113
    Overall activity: 23,0%

    Registriert seit
    Mar 2007
    Beiträge
    547
    Points
    7.637
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    hey would anyone know how to get a decimal converted to a whole number ?
    for example i get 88.3333333333333 but i want it to print 88
    http://img489.imageshack.us/img489/5841/99862310tg8.jpg
    Zitat Zitat von qwerty6523
    tobias what do you mean by a hump and run
    plz explain what that is
    Zitat Zitat von jaymes
    hump and run.. =] thats called a one night stand

  11. #8531
    QJ Gamer Blue
    Points: 7.014, Level: 55
    Level completed: 32%, Points required for next Level: 136
    Overall activity: 0%

    Registriert seit
    Jan 2007
    Ort
    U.S.
    Beiträge
    405
    Points
    7.014
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    math.floor(83.33333333333 33)

    I'm pretty sure that's it.

  12. #8532
    QJ Gamer Bronze
    Points: 7.637, Level: 58
    Level completed: 44%, Points required for next Level: 113
    Overall activity: 23,0%

    Registriert seit
    Mar 2007
    Beiträge
    547
    Points
    7.637
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    thanks andyauff :]]
    http://img489.imageshack.us/img489/5841/99862310tg8.jpg
    Zitat Zitat von qwerty6523
    tobias what do you mean by a hump and run
    plz explain what that is
    Zitat Zitat von jaymes
    hump and run.. =] thats called a one night stand

  13. #8533
    QJ Gamer Blue
    Points: 7.014, Level: 55
    Level completed: 32%, Points required for next Level: 136
    Overall activity: 0%

    Registriert seit
    Jan 2007
    Ort
    U.S.
    Beiträge
    405
    Points
    7.014
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    No problem.

  14. #8534
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    oops ill put this in in just a moment

    EDIT: there you go

    Code:
    function round_number(number)
    check_number_full = string.format("%.1f", number)
    check_number_single = string.sub(check_number_full, -1)
    if check_number_single < 5 then
    return math.floor(number)
    else
    return math.ceil(number)
    end
    end
    if the number after the decimal is smaller than 5 then it will round down like it would in propper maths and if it is 5 or above then it will round up

    e.g. 5.27577 woud return 5 and 5.78435 would return 6
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  15. #8535
    QJ Gamer Blue
    Points: 7.014, Level: 55
    Level completed: 32%, Points required for next Level: 136
    Overall activity: 0%

    Registriert seit
    Jan 2007
    Ort
    U.S.
    Beiträge
    405
    Points
    7.014
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Yeah, I thought there was a function for rounding up too. That's why I said I was pretty sure. math.floor worked because you were rounding down. Thanks for adding that function, FaT3oYCG.
    Geändert von andyauff (04-25-2008 um 01:43 PM Uhr)

  16. #8536
    QJ Gamer Bronze
    Points: 7.637, Level: 58
    Level completed: 44%, Points required for next Level: 113
    Overall activity: 23,0%

    Registriert seit
    Mar 2007
    Beiträge
    547
    Points
    7.637
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von FaT3oYCG
    oops ill put this in in just a moment

    EDIT: there you go

    Code:
    function round_number(number)
    check_number_full = string.format("%.1f", number)
    check_number_single = string.sub(check_number_full, -1)
    if check_number_single < 5 then
    return math.floor(number)
    else
    return math.ceil(number)
    end
    end
    if the number after the decimal is smaller than 5 then it will round down like it would in propper maths and if it is 5 or above then it will round up

    e.g. 5.27577 woud return 5 and 5.78435 would return 6
    thanks :]
    the math.floor worked for me but its always good to see exactly how it works thanks
    http://img489.imageshack.us/img489/5841/99862310tg8.jpg
    Zitat Zitat von qwerty6523
    tobias what do you mean by a hump and run
    plz explain what that is
    Zitat Zitat von jaymes
    hump and run.. =] thats called a one night stand

  17. #8537
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    yeah i just though id put that in because it can be used all the time, ill explain the functions for you aswell

    math.floor(number) - all this does is remove any decimals on the number after the point, to return the whole number

    math.ceil(number) - all this does is add one to the number and then remove any decimals after the point, to return a whole number

    i made that function because it rounds depending on the decimal not by just rounding up or down all of the time
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  18. #8538
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Wow. That is a horrible rounding function, and you explained what math.floor and ceil do incorrectly. For negative numbers, your explanation no longer holds true.
    Also, nonsucky rounding function:
    Code:
    function math.round(n)
    return math.floor(n+0.5)
    end

  19. #8539
    QJ Gamer Bronze
    Points: 8.665, Level: 62
    Level completed: 72%, Points required for next Level: 85
    Overall activity: 0%

    Registriert seit
    Mar 2007
    Beiträge
    758
    Points
    8.665
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    Doesn't math.floor round down to the nearest whole number and math.ceil round up?

  20. #8540
    QJ Gamer Bronze
    Points: 7.637, Level: 58
    Level completed: 44%, Points required for next Level: 113
    Overall activity: 23,0%

    Registriert seit
    Mar 2007
    Beiträge
    547
    Points
    7.637
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von michaelp
    Doesn't math.floor round down to the nearest whole number and math.ceil round up?
    yes but the way he just wrote it is that it adds .5 to any of ur decimals and rounds down... so if ur deciam is say 1.5 it would be 1.5 +.5 witch = 2 and 2 rounds to 2... if it were 1.3 then it would be 1.3 +.5 witch = 1.8 witch with math.floor would round to 1 so..it still works :P cool and simple rounding function :}]]
    http://img489.imageshack.us/img489/5841/99862310tg8.jpg
    Zitat Zitat von qwerty6523
    tobias what do you mean by a hump and run
    plz explain what that is
    Zitat Zitat von jaymes
    hump and run.. =] thats called a one night stand

  21. #8541
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    michaelp - yes. that would be what it does. please refer to above posts (although incorrect it still gets the point across) and http://lua-users.org/wiki/TutorialDirectory before asking more questions.

  22. #8542
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    lol

    everyday when im walking down the street, every turtle that i meet says, its a simple message and it comes from the shell, you help people and then i pwn you, hey!!!. every day when im ...

    thanks lol

    yeah my function sux, but i did make it a long time ago

    oh and

    math.floor (x)
    Returns the largest integer smaller than or equal to x.

    math.ceil (x)
    Returns the smallest integer larger than or equal to x.
    Geändert von FaT3oYCG (04-26-2008 um 12:20 AM Uhr)
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  23. #8543
    QJ Gamer Blue
    Points: 3.563, Level: 37
    Level completed: 43%, Points required for next Level: 87
    Overall activity: 54,0%

    Registriert seit
    Sep 2007
    Beiträge
    149
    Points
    3.563
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    CAn someone can show me how to use this function in he Lua Player HM.

    System.usbDevUMD()

    If I try it like that :

    if pad:cross() then
    System.usbDevUMD()
    end

    Nothing happen when i push X. CAn someone help me please.

  24. #8544
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    System.usbDevUMD() sets the usb to the umd
    System.diskModeActivate() still turns it on so

    if pad:cross() then
    System.usbDevUMD()
    System.diskModeActivate()
    end
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  25. #8545
    QJ Gamer Blue
    Points: 3.563, Level: 37
    Level completed: 43%, Points required for next Level: 87
    Overall activity: 54,0%

    Registriert seit
    Sep 2007
    Beiträge
    149
    Points
    3.563
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Attemp to call field 'diskmodeActivate" (a nil value)

    Do you know what does that means ?

  26. #8546
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    sorry

    System.usbDiskModeActivat e()
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  27. #8547
    QJ Gamer Blue
    Points: 3.563, Level: 37
    Level completed: 43%, Points required for next Level: 87
    Overall activity: 54,0%

    Registriert seit
    Sep 2007
    Beiträge
    149
    Points
    3.563
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Thanks. For the fastest with anwser me. What abotu that one.

    I'll want to creat a drum app. I wnt to load my sound and associate them to a name. Then I want to, if i push X, per exemple, play the sound associate to "kick" bu tonly once. Do u know how i have to do that.

    I alerdy try but i wasn'n able.

  28. #8548
    QJ Gamer Blue
    Points: 4.268, Level: 41
    Level completed: 59%, Points required for next Level: 82
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Beiträge
    497
    Points
    4.268
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    you need to put

    oldpad = Controls.read()

    at the top of your code by like the colors, or what not and put

    if pad:cross() and oldpad:cross() ~= pad:cross() then

    before the sound you want to be heard

    and finally right before the end of your code put

    oldpad=pad

    that should work, Please correct me if I'm wrong Fat3oYCG

    also I think your idea sounds cool, keep up the good work

  29. #8549
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    PSProgrammer - that gets the job done, but personally I believe it is a horrible way to accomplish that job.

    Replace:
    Code:
    pad = Controls.read()
    with:
    Code:
    oldpad = pad
    pad = Controls.read()
    and then for button press detection, use:
    Code:
    if pad:cross() and not oldpad:cross() then
    Basically, that will make the logic of it say, if cross has been pressed but it was not pressed last loop (aka it JUST got pushed down) then blah
    If you want to change that logic to, if cross was pressed down but just got released then blah, then do this:
    Code:
    if oldpad:cross() and not pad:cross() then

  30. #8550
    Developer
    Points: 4.205, Level: 41
    Level completed: 28%, Points required for next Level: 145
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    San Diego
    Beiträge
    177
    Points
    4.205
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    TurtlesPwn - that gets the job done, but personally I believe it is a horrible way to accomplish that job.

    Replace:

    Code:
    Dpad = Controls.read()
    with:

    Code:
    oldDpad = Dpad
    Dpad = Controls.read()
    and then for button press detection, use:

    Code:
    if Dpad:cross() and not oldDpad:cross() then
    Basically, that will make the logic of it say, if cross has been pressed but it was not pressed last loop (aka it JUST got pushed down) then blah
    If you want to change that logic to, if cross was pressed down but just got released then blah, then do this:

    Code:
    if oldDpad:cross() and not Dpad:cross() then
    Think about this before responding.


 

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 07:54 AM Uhr.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © , Caputo Media, LLC. All Rights Reserved. Cluster .