Seite 230 von 342 ErsteErste ... 130 180 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 280 330 ... LetzteLetzte
Zeige Ergebnis 6.871 bis 6.900 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; O gawd more questions. I have the analog working fine, but all the person does it move to the right ...

  
  1. #6871
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    O gawd more questions.

    I have the analog working fine, but all the person does it move to the right and down. How do I make left and up.

    Heres my code.
    while true do
    pad = Controls.read()
    ax = pad:analogX()
    if math.abs(ax) > 32 then
    x = x + 3
    end
    if math.abs(ax) <-32 then
    x = x - 3
    end
    ay = pad:analogY()
    if math.abs(ay) > 32 then
    y = y + 3
    end
    if math.abs(ay) <-32 then
    y = y - 3
    end

    I added the negative codes to see if they would work. It didn't.



  2. #6872
    QJ Gamer Gold
    Points: 11.942, Level: 71
    Level completed: 73%, Points required for next Level: 108
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Ort
    ...
    Beiträge
    2.080
    Points
    11.942
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    there should be a pad:analogY() also

  3. #6873
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    while true do
    pad = Controls.read()
    ax = pad:analogX()
    if math.abs(ax) > 32 then
    x = x + 3
    end
    if math.abs(ax) <-32 then
    x = x - 3
    end
    while true do
    pad = Controls.read()
    ax = pad:analogX()
    if math.abs(ax) > 32 then
    x = x + 3
    end
    if math.abs(ax) <-32 then
    x = x - 3
    end
    ay = pad:analogY()
    if math.abs(ay) > 32 then
    y = y + 3
    end
    if math.abs(ay) <-32 then
    y = y - 3
    end

    I do have one.

    I just want to be able to move up and left.

  4. #6874
    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

    ther is no way math.abs(ax) <-32 is going to be true

    math.abs() returns the absolute value of the number meaning if it is -50 it will return 50.
    -= Double Post =-
    Zitat Zitat von Urameshi
    collectgarbage() doesnt work for me, and i still dont know what it does
    Collectgarbage forces lua to free memory that is flagged as unused. Lua does this periodically, but sometimes when you are unloading a bunch of graphics, you want to have lua do it immediately. ie

    Code:
    function unloadimages()
       image1 = null
       image2 = null
       image3 = null
       collectgarbage()
    end
    Geändert von KleptoOne (04-17-2007 um 09:23 AM Uhr) Grund: Automerged Doublepost

  5. #6875
    QJ Gamer Gold
    Points: 11.942, Level: 71
    Level completed: 73%, Points required for next Level: 108
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Ort
    ...
    Beiträge
    2.080
    Points
    11.942
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    blargh im so stuck

    like when something collides in my game then i want one of them to like become inactive and disappear, so that the game doesnt restart

  6. #6876
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von KleptoOne
    ther is no way math.abs(ax) <-32 is going to be true

    math.abs() returns the absolute value of the number meaning if it is -50 it will return 50.
    -= Double Post =-


    Collectgarbage forces lua to free memory that is flagged as unused. Lua does this periodically, but sometimes when you are unloading a bunch of graphics, you want to have lua do it immediately. ie

    Code:
    function unloadimages()
       image1 = null
       image2 = null
       image3 = null
       collectgarbage()
    end
    ahh I understand.

    The thing I was following didn't explain what these things meant. It just told me to do them -.-

    I got it working now. I have an arrow pointer thingy from the computer onto my little program thing.

  7. #6877
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Urameshi
    blargh im so stuck

    like when something collides in my game then i want one of them to like become inactive and disappear, so that the game doesnt restart
    so create universal function for that ;) with collectgarbage() ;)

  8. #6878
    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

    Zitat Zitat von myschoo
    so create universal function for that ;) with collectgarbage() ;)
    you shouldn't have to use collect garbage for that purpose, say it was an enemy, why unload it when you kill it, what if you wanted to use another one of those enemies later on? I guess it depends on your game.

    Easiest way to handle your situation is to hold all your enemies in a table, and when a collision occurs, remove that table element. To add more enemies, add it to the end of the table.

    It should be a very simple process.

  9. #6879
    Monster Masher
    Points: 5.084, Level: 45
    Level completed: 67%, Points required for next Level: 66
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    Behind you...
    Beiträge
    265
    Points
    5.084
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    function MedCol()
    for y=1,en_2 do
    for u=1,no_bull do
    if asteroidmed[y].x+24>bullet[u].x and asteroidmed[y].x<bullet[u].x+6 and asteroidmed[y].y+24>bullet[u].y and asteroidmed[y].y<bullet[u].y+6 then
    score=score+20
    asteroidsm[en_3+1]={x=asteroidmed[y].x, y=asteroidmed[y].y, width=32, height=32, vspeed=(math.random(0,1))-(math.random(0,2)), hspeed=(math.random(0,1))-(math.random(0,2))}
    en_3=en_3+1
    asteroidmed[y].x=489346983
    bullet[u].x=-99999999999
    end
    end
    end
    end
    I get an error that in the collision if "attempt to index field "?" null value". There is a asteroidmed array, en_2 is equal to 1, there are several bullets, no_bull is the amount of bullets, there is an asteroidmed[1] and it has x and y coordinates, same as the bullet. However i see no difference with this code and my other one:

    Code:
    function Collision()
    for f=1,en_1 do
    for g=1, no_bull do
    if asteroid[f].x+32>bullet[g].x and asteroid[f].x<bullet[g].x+6 and asteroid[f].y+32>bullet[g].y and asteroid[f].y<bullet[g].y+6 then
    score=score+20
    asteroid[en_2+1]={x=asteroid[f].x, y=asteroid[f].y, width=32, height=32, vspeed=(math.random(0,1))-(math.random(0,2)), hspeed=(math.random(0,1))-(math.random(0,2))}
    en_2=en_2+1
    asteroid[f].x=489346983
    bullet[g].x=-99999999999
    end
    end
    end
    end
    Apart from the names. any help?!

  10. #6880
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    New problemm. I want to make it so whenever I click X within a certain perimeter it will do the USB thing. That works. Next I would like to make it so clicking there again it will disable. Theres my problem.

    Heres what I have so far:
    Code:
    sl = pad:cross()
    if x>20 and x<70 and y > 20 and y < 70 and sl then
    System.usbDiskModeActivate()
    
    end
    That works fine. When I click there USB starts up. I don't know how to make a deactivate though. Heres what I tried.

    Code:
    sl = pad:cross()
    if x>20 and x<70 and y > 20 and y < 70 and sl and v = 1 then
    System.usbDiskModeActivate()
    v = v + 1
    end
    if x>20 and x<70 and y > 20 and y < 70 and sl and v = 1 then
    System.usbDiskModeActivate()
    v = v - 1
    end
    pad and v are already set earlier. Nothing I'm trying is working. Help please?

  11. #6881
    QJ Gamer Blue
    Points: 4.561, Level: 43
    Level completed: 6%, Points required for next Level: 189
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    224
    Points
    4.561
    Level
    43
    Downloads
    0
    Uploads
    0

    Standard

    do:
    Code:
    v = 0
    sl = pad:cross()
    if x>20 and x<70 and y > 20 and y < 70 and sl and v = 0 then
    System.usbDiskModeActivate()
    v = 1
    end
    if x>20 and x<70 and y > 20 and y < 70 and sl and v = 1 then
    System.usbDiskModeDeactivate() -- not sure what it is for deactivate though. this may be right i dunno
    v = 0
    end

  12. #6882
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Still doesn't work. I tried that once but copied it wrong. I just added a different activation point for it.

  13. #6883
    Points: 24.247, Level: 94
    Level completed: 90%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    texas
    Beiträge
    2.803
    Points
    24.247
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    Thats right..
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  14. #6884
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    o.o Are you sure? I tried multiple times. D=

  15. #6885
    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

    Zitat Zitat von yumCOOKIEZZ
    Still doesn't work. I tried that once but copied it wrong. I just added a different activation point for it.
    Look at the rest of his code, the conditions of your if's are flawed.

  16. #6886
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Copied right from my code

    if x>20 and x<70 and y > 20 and y < 70 and sl and v=0 then
    System.usbDiskModeActivat e()
    v=1
    screen:blit(380, yy, usb, true)
    screen.flip()
    end

    if x>90 and x<140 and y>20 and y<70 and sl and v=1 then
    System.usbDiskModeDeactiv ate()
    screen:blit(380, yy, offusb, true)
    screen.flip()
    v=0
    end

    Error: Program.LUA:47: 'then' expected near '='

    Line 47 is the first line I posted. Removing the v=0 part makes it work.
    -= Double Post =-
    Another question...(sorry for so many questions)

    Can I write a file in a separate LUA file, and tell the main one to open this one.
    This would help me keep organized between my codes. I basically want a second frame typed thing.
    Geändert von yumCOOKIEZZ (04-17-2007 um 01:38 PM Uhr) Grund: Automerged Doublepost

  17. #6887
    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

    Zitat Zitat von yumCOOKIEZZ
    Copied right from my code

    if x>20 and x<70 and y > 20 and y < 70 and sl and v=0 then
    System.usbDiskModeActivat e()
    v=1
    screen:blit(380, yy, usb, true)
    screen.flip()
    end

    if x>90 and x<140 and y>20 and y<70 and sl and v=1 then
    System.usbDiskModeDeactiv ate()
    screen:blit(380, yy, offusb, true)
    screen.flip()
    v=0
    end

    Error: Program.LUA:47: 'then' expected near '='

    Line 47 is the first line I posted. Removing the v=0 part makes it work.
    -= Double Post =-
    Another question...(sorry for so many questions)

    Can I write a file in a separate LUA file, and tell the main one to open this one.
    This would help me keep organized between my codes. I basically want a second frame typed thing.
    v==0 is required

    in an if statement your are checking if two values are equal, this is done by ==
    to set one value equal to another, you use =

    as for the other item, research the dofile() command.

  18. #6888
    Points: 24.247, Level: 94
    Level completed: 90%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    texas
    Beiträge
    2.803
    Points
    24.247
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von KleptoOne
    as for the other item, research the dofile() command.
    But make sure you dont call it much. Having an external file is great, but it shouldnt be called much. What I do is use external files to define functions, so each file only gets ran once at startup (a lot of people make files that do stuff like display "GAME OVER", someone even had a file ran every loop that checked for collision...very bad)
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  19. #6889
    QJ Gamer Blue
    Points: 5.344, Level: 46
    Level completed: 97%, Points required for next Level: 6
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    347
    Points
    5.344
    Level
    46
    Downloads
    0
    Uploads
    0

    Standard

    Hey guys i am trying to get the battery percent to print to the screen so i am creating a function for it. her is what i have so far:
    function power()
    power = System.powerGetBatteryLif ePercent()

    Now when i try to print it to the screen i get an error so i am obviousley missing something. I tryed a few things but they did not work either.

    Thanks Bob Hoil

  20. #6890
    Points: 24.247, Level: 94
    Level completed: 90%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    texas
    Beiträge
    2.803
    Points
    24.247
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Bob Hoil
    Hey guys i am trying to get the battery percent to print to the screen so i am creating a function for it. her is what i have so far:
    function power()
    power = System.powerGetBatteryLif ePercent()

    Now when i try to print it to the screen i get an error so i am obviousley missing something. I tryed a few things but they did not work either.

    Thanks Bob Hoil
    ...why...

    do this...

    screen:print(x,y, System.powerGetBatteryLif ePercent())
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  21. #6891
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Yonathan_Jantis
    But make sure you dont call it much. Having an external file is great, but it shouldnt be called much. What I do is use external files to define functions, so each file only gets ran once at startup (a lot of people make files that do stuff like display "GAME OVER", someone even had a file ran every loop that checked for collision...very bad)
    I only plan on using it to open seperate windows for my program. N0t every window but the bigger ones with more coding that will get confusing.

    Thanks for the help once again =D

  22. #6892
    QJ Gamer Gold
    Points: 11.942, Level: 71
    Level completed: 73%, Points required for next Level: 108
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Ort
    ...
    Beiträge
    2.080
    Points
    11.942
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von KleptoOne
    you shouldn't have to use collect garbage for that purpose, say it was an enemy, why unload it when you kill it, what if you wanted to use another one of those enemies later on? I guess it depends on your game.

    Easiest way to handle your situation is to hold all your enemies in a table, and when a collision occurs, remove that table element. To add more enemies, add it to the end of the table.

    It should be a very simple process.
    how do you remove the table element?

  23. #6893
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Urameshi
    how do you remove the table element?
    http://lua-users.org/wiki/TableLibraryTutorial

  24. #6894
    QJ Gamer Gold
    Points: 11.942, Level: 71
    Level completed: 73%, Points required for next Level: 108
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Ort
    ...
    Beiträge
    2.080
    Points
    11.942
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    :Jump: thanks thanks thanks:Jump: , that was a good read and very informative

  25. #6895
    Points: 24.247, Level: 94
    Level completed: 90%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    texas
    Beiträge
    2.803
    Points
    24.247
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Urameshi
    :Jump: thanks thanks thanks:Jump: , that was a good read and very informative
    Yeah... http://lua-users.org/wiki/TutorialDirectory I keep giving out this link everywhere, yet no one seems to want to read it, instead they just ask everyone else.
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  26. #6896
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Is there a list of codes and stuff for LUA that would help me with my PSP. I looked but couldn't find anything and after a while you people will probably get annoyed with my constant errors.
    -= Double Post =-
    if x>20 and x<70 and y > 20 and y < 70 and sl and v == 0 then
    System.usbDiskModeActivat e()
    v = 1
    end
    if x>20 and x<70 and y > 20 and y < 70 and sl and v == 1 then
    System.usbDiskModeDeactiv ate()
    v = 0
    end

    Arh. Heres exactly what I have. When I go into my program and click within those boundaries, nothing happens.
    Geändert von yumCOOKIEZZ (04-17-2007 um 04:54 PM Uhr) Grund: Automerged Doublepost

  27. #6897
    QJ Gamer Gold
    Points: 11.942, Level: 71
    Level completed: 73%, Points required for next Level: 108
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Ort
    ...
    Beiträge
    2.080
    Points
    11.942
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Yonathan_Jantis
    Yeah... http://lua-users.org/wiki/TutorialDirectory I keep giving out this link everywhere, yet no one seems to want to read it, instead they just ask everyone else.
    I never seen you give that out

  28. #6898
    Points: 24.247, Level: 94
    Level completed: 90%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    texas
    Beiträge
    2.803
    Points
    24.247
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von yumCOOKIEZZ
    Is there a list of codes and stuff for LUA that would help me with my PSP. I looked but couldn't find anything and after a while you people will probably get annoyed with my constant errors.

    Zitat Zitat von Yonathan_Jantis
    Yeah... http://lua-users.org/wiki/TutorialDirectory I keep giving out this link everywhere, yet no one seems to want to read it, instead they just ask everyone else.
    Even when the preceding reply was the answer.
    I rest my case.
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  29. #6899
    QJ Gamer Blue
    Points: 5.344, Level: 46
    Level completed: 97%, Points required for next Level: 6
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    347
    Points
    5.344
    Level
    46
    Downloads
    0
    Uploads
    0

    Standard

    Thanks Yonathan for the help i got it to work.

  30. #6900
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Oh sorry. I didn't refresh the page >.<


 

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 09:01 PM Uhr.

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