Seite 222 von 342 ErsteErste ... 122 172 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 272 322 ... LetzteLetzte
Zeige Ergebnis 6.631 bis 6.660 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; Em...yeah. Lua scripters not writing their own code is what is hurting the scene....

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

    Em...yeah. Lua scripters not writing their own code is what is hurting the scene.


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

  2. #6632
    QJ Gamer Blue
    Points: 3.689, Level: 38
    Level completed: 26%, Points required for next Level: 111
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    168
    Points
    3.689
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    ok, i made my own code, but it just keeps play the animation for what ever button you press here is my code:
    Code:
    dofile("animLib.lua")
    standright = SS.new("jackstandright", "png", 24, 50, "images/jack/")
    standleft = SS.new("jackstandleft", "png", 24, 50, "images/jack/")
    runright = SS.new("jackrunright", "png", 64, 48, "images/jack/")
    runleft = SS.new("jackrunleft", "png", 64, 48, "images/jack/")
    
    oldpad = Controls.read()
    
    player = {}
    player.x = 20
    player.y = 210
    player.img = standright
    
    while true do
    
    screen:clear()
    
    pad = Controls.read()
    
    oldpad = pad
    
    if pad:right() then
    player.img = runright
    player.x = player.x + 7
    end 
    
    if pad:left() then
    player.img = runleft
    player.x = player.x - 7
    end  
    
    if pad:buttons() < 1 and oldpad:left() then
    player.img = standleft
    end 
    
    player.img:blit(player.x, player.y, 50)
    
    screen.waitVblankStart()
    screen.flip()
    end

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

    eww anim lib, cant help you there

    ...



    ...

    *sigh*
    Code:
    player.img = standright
    
    while true do
    Flip those. Youre also gonna have to mod it a bit for standleft.
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  4. #6634
    QJ Gamer Blue
    Points: 3.689, Level: 38
    Level completed: 26%, Points required for next Level: 111
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    168
    Points
    3.689
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    just look at the main loop

    p.s. i made a sprite of the player image standing left or right with the same frame so it repeats and gives the illusion of an image

  5. #6635
    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

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

  6. #6636
    QJ Gamer Blue
    Points: 3.689, Level: 38
    Level completed: 26%, Points required for next Level: 111
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    168
    Points
    3.689
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    it's not clearing the screen making player.img stand left if no buttons are pressed and if left was pressed
    Code:
    dofile("animLib.lua")
    standright = SS.new("jackstandright", "png", 24, 50, "images/jack/")
    standleft = SS.new("jackstandleft", "png", 24, 50, "images/jack/")
    runright = SS.new("jackrunright", "png", 64, 48, "images/jack/")
    runleft = SS.new("jackrunleft", "png", 64, 48, "images/jack/")
    
    oldpad = Controls.read()
    
    player = {}
    player.x = 20
    player.y = 210
    
    while true do
    
    player.img = standright
    
    screen:clear()
    
    pad = Controls.read()
    
    oldpad = pad
    
    if pad:right() then
    player.img = runright
    player.x = player.x + 7
    end 
    
    if pad:left() then
    player.img = runleft
    player.x = player.x - 7
    end  
    
    if pad:buttons() < 1 and oldpad:left() then
    screen:clear()
    player.img = standleft
    end
    
    
    player.img:blit(player.x, player.y, 50)
    
    screen.waitVblankStart()
    screen.flip()
    end

  7. #6637
    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

    that's why i dont use animLib, too confusing

  8. #6638
    QJ Gamer Gold
    Points: 11.629, Level: 70
    Level completed: 95%, Points required for next Level: 21
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    1.633
    Points
    11.629
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Why don't you just make a function to flip the image in lua and only need 1 image?
    Code:
    function flip(img)
    for i = 0, img:width() do
    for j = 0, img:height() do
    img:pixel(i,j,img:pixel(img:width()-i,img:height()-j))
    end
    end
    return img
    end
    That would (if i didnt mess anything up) flip the image horizontally and be used like this:

    Code:
    someimage = Image.load("image.png")
    someflippedimage = flip(someimage)

  9. #6639
    QJ Gamer Blue
    Points: 3.689, Level: 38
    Level completed: 26%, Points required for next Level: 111
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    168
    Points
    3.689
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    ya, but how would i get it to load a certain image after an animation is done, like if i press left, load playerleft or if i press right load imageright after an animation

  10. #6640
    QJ Gamer Gold
    Points: 11.629, Level: 70
    Level completed: 95%, Points required for next Level: 21
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    1.633
    Points
    11.629
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    if oldpad:right() and not pad:right() then
    player.img = facingright

    aka if right was pressed last loop but isnt this loop then make the playerimg facing right

  11. #6641
    QJ Gamer Blue
    Points: 3.689, Level: 38
    Level completed: 26%, Points required for next Level: 111
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    168
    Points
    3.689
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    the problem im encountering is that it won't load the image i tell it to here is the code:
    Code:
    dofile("animLib.lua")
    standright = SS.new("jackstandright", "png", 24, 50, "images/jack/")
    standleft = SS.new("jackstandleft", "png", 24, 50, "images/jack/")
    runright = SS.new("jackrunright", "png", 64, 48, "images/jack/")
    runleft = SS.new("jackrunleft", "png", 64, 48, "images/jack/")
    
    oldpad = Controls.read()
    
    player = {}
    player.x = 20
    player.y = 210
    
    while true do
    
    player.img = standright
    
    screen:clear()
    
    pad = Controls.read()
    
    oldpad = pad
    
    if pad:right() then
    player.img = runright
    player.x = player.x + 7
    end 
    
    if pad:left() then
    player.img = runleft
    player.x = player.x - 7
    end  
    
    if oldpad:left() and not pad:left() then
    player.img = standleft
    end
    
    player.img:blit(player.x, player.y, 50)
    
    screen.waitVblankStart()
    screen.flip()
    end

  12. #6642
    QJ Gamer Gold
    Points: 11.629, Level: 70
    Level completed: 95%, Points required for next Level: 21
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    1.633
    Points
    11.629
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    You need to put oldpad = pad before pad = Controls.read()

  13. #6643
    QJ Gamer Blue
    Points: 3.689, Level: 38
    Level completed: 26%, Points required for next Level: 111
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    168
    Points
    3.689
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    ok i did that:
    Code:
    dofile("animLib.lua")
    standright = SS.new("jackstandright", "png", 24, 50, "images/jack/")
    standleft = SS.new("jackstandleft", "png", 24, 50, "images/jack/")
    runright = SS.new("jackrunright", "png", 64, 48, "images/jack/")
    runleft = SS.new("jackrunleft", "png", 64, 48, "images/jack/")
    
    oldpad = Controls.read()
    
    player = {}
    player.x = 20
    player.y = 210
    
    while true do
    
    player.img = standright
    
    screen:clear()
    
    oldpad = pad
    
    pad = Controls.read()
    
    if pad:right() then
    player.img = runright
    player.x = player.x + 7
    end 
    
    if pad:left() then
    player.img = runleft
    player.x = player.x - 7
    end  
    
    if oldpad:left() and not pad:left() then
    player.img = standleft
    end
    
    player.img:blit(player.x, player.y, 50)
    
    screen.waitVblankStart()
    screen.flip()
    end
    now i get the error: lua:31:attempt to index globa 'oldpad' <a nil value>

  14. #6644
    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

    Because on the first loop you assign it to pad, which is nil
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  15. #6645
    QJ Gamer Blue
    Points: 3.689, Level: 38
    Level completed: 26%, Points required for next Level: 111
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    168
    Points
    3.689
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    but he said to put old = pad before pad = Controls.read

  16. #6646
    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

    yes, but you need a first value.
    do
    pad = oldpad
    right under oldpad = COntrols.read()
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  17. #6647
    QJ Gamer Blue
    Points: 3.689, Level: 38
    Level completed: 26%, Points required for next Level: 111
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    168
    Points
    3.689
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    my code:
    Code:
    dofile("animLib.lua")
    standright = SS.new("jackstandright", "png", 24, 50, "images/jack/")
    standleft = SS.new("jackstandleft", "png", 24, 50, "images/jack/")
    runright = SS.new("jackrunright", "png", 64, 48, "images/jack/")
    runleft = SS.new("jackrunleft", "png", 64, 48, "images/jack/")
    
    oldpad = Controls.read()
    pad = oldpad
    
    player = {}
    player.x = 20
    player.y = 210
    
    while true do
    
    player.img = standright
    
    screen:clear()
    
    oldpad = pad
    
    pad = Controls.read()
    
    if pad:right() then
    player.img = runright
    player.x = player.x + 7
    end 
    
    if pad:left() then
    player.img = runleft
    player.x = player.x - 7
    end  
    
    if oldpad:left() and not pad:left() then
    player.img = standleft
    end
    
    player.img:blit(player.x, player.y, 50)
    
    screen.waitVblankStart()
    screen.flip()
    end
    still doesn't make player.img standleft
    Geändert von moncristo_da_dev (04-07-2007 um 04:58 PM Uhr) Grund: Automerged Doublepost

  18. #6648
    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

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

  19. #6649
    QJ Gamer Blue
    Points: 3.689, Level: 38
    Level completed: 26%, Points required for next Level: 111
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    168
    Points
    3.689
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    man, i think im cursed with noobness

  20. #6650
    QJ Gamer Blue
    Points: 3.680, Level: 38
    Level completed: 20%, Points required for next Level: 120
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    172
    Points
    3.680
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    if oldpad:left() and not pad:left() then
    player.img = standleft
    end

    shouldn't it be

    if oldpad:left() and ~pad:left() then
    player.img = standleft
    end
    -= Double Post =-
    i never seen not be called i don't even know if it can be called as not
    Geändert von seenit (04-07-2007 um 06:06 PM Uhr) Grund: Automerged Doublepost

  21. #6651
    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

    Not checks if all the following code block is false. Ive never seen ~pad:left(), that works?
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  22. #6652
    QJ Gamer Blue
    Points: 3.680, Level: 38
    Level completed: 20%, Points required for next Level: 120
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    172
    Points
    3.680
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    i know you can use oldpad:left ~= pad:left

    idk it's been a long time since i programmed with lua

  23. #6653
    QJ Gamer Blue
    Points: 3.689, Level: 38
    Level completed: 26%, Points required for next Level: 111
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    168
    Points
    3.689
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    it doesn't work, i have tried a lot of things before asking you guys here

  24. #6654
    QJ Gamer Blue
    Points: 3.680, Level: 38
    Level completed: 20%, Points required for next Level: 120
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    172
    Points
    3.680
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    o ok

  25. #6655
    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 youresam
    blame animlib, it sux0rz
    i agree with that

    that's why i use sprite sheets to do the animations

  26. #6656
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Urameshi
    i agree with that

    that's why i use sprite sheets to do the animations
    umm, animlib supports all sprite sheets. (v4)

    :)
    --------------------------------------------------------------------------------------

  27. #6657
    QJ Gamer Blue
    Points: 3.689, Level: 38
    Level completed: 26%, Points required for next Level: 111
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    168
    Points
    3.689
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Urameshi
    i agree with that

    that's why i use sprite sheets to do the animations
    i am using sprite sheets on animlib
    -= Double Post =-
    grim solve my problem please!!!!
    Geändert von moncristo_da_dev (04-07-2007 um 07:09 PM Uhr) Grund: Automerged Doublepost

  28. #6658
    QJ Gamer Blue
    Points: 3.680, Level: 38
    Level completed: 20%, Points required for next Level: 120
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    172
    Points
    3.680
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    @mon lose animlib make the images into their own images then just load them as there names and then it should work

  29. #6659
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von moncristo_da_dev
    the problem im encountering is that it won't load the image i tell it to here is the code:
    Code:
    dofile("animLib.lua")
    standright = SS.new("jackstandright", "png", 24, 50, "images/jack/")
    standleft = SS.new("jackstandleft", "png", 24, 50, "images/jack/")
    runright = SS.new("jackrunright", "png", 64, 48, "images/jack/")
    runleft = SS.new("jackrunleft", "png", 64, 48, "images/jack/")
    
    oldpad = Controls.read()
    
    player = {}
    player.x = 20
    player.y = 210
    
    while true do
    
    player.img = standright
    
    screen:clear()
    
    pad = Controls.read()
    
    oldpad = pad
    
    if pad:right() then
    player.img = runright
    player.x = player.x + 7
    end 
    
    if pad:left() then
    player.img = runleft
    player.x = player.x - 7
    end  
    
    if oldpad:left() and not pad:left() then
    player.img = standleft
    end
    
    player.img:blit(player.x, player.y, 50)
    
    screen.waitVblankStart()
    screen.flip()
    end
    try putting this line:

    Code:
    player.img = standright
    before your main loop. also, your state system is faulty. gimme a min, ill show you how to improvise yours.
    --------------------------------------------------------------------------------------

  30. #6660
    QJ Gamer Blue
    Points: 3.689, Level: 38
    Level completed: 26%, Points required for next Level: 111
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    168
    Points
    3.689
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    ok thanks a lot


 

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 08:59 PM Uhr.

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