Seite 85 von 342 ErsteErste ... 35 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 135 185 ... LetzteLetzte
Zeige Ergebnis 2.521 bis 2.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; bronxbomber, for your code, would you want this at the beginning: Code: while true do screen:clear() screen:blit(0, 0, menu) screen.flip() ...

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

    bronxbomber, for your code, would you want this at the beginning:

    Code:
    while true do
    screen:clear()
    screen:blit(0, 0, menu)
    screen.flip()
    
    pad = Controls.read()
    if pad:cross() then
    screen:clear()
    break
    end
    end
    i=1
    while i<=17 do
        screen:clear()
        counter:start()
        screen:blit(0, 0, background) .............
    So that when you press x or 'c' the menu will be cleared, and go on to the rest of the code?



  2. #2522
    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

    Also, can someone explain using the analog stick in games. I'm not even as experienced as GrimFace when it comes to that. Any help would be appreciated.

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

    can someone explain how to draw a circle? i found this code, yet how do i make it work currectly? Can anyone explain this too?
    Code:
    function drawCirc(where, x, y, radius, color)
    
    	theta = 0
    
    	while theta<=360 do
    		where:drawLine((math.sin(    theta)*radius)+x, (math.cos(theta)*radius)+    y, (math.sin(theta+1)*radius    )+x, (math.cos(theta+1)*radius    )+y, color)
    		theta = theta+1
    	end
    end

  4. #2524
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von emericaska8r
    can someone explain how to draw a circle? i found this code, yet how do i make it work currectly? Can anyone explain this too?
    Code:
    function drawCirc(where, x, y, radius, color)
    
    	theta = 0
    
    	while theta<=360 do
    		where:drawLine((math.sin(    theta)*radius)+x, (math.cos(theta)*radius)+    y, (math.sin(theta+1)*radius    )+x, (math.cos(theta+1)*radius    )+y, color)
    		theta = theta+1
    	end
    end
    Say you want to draw a red circle on the screen at x=120 and y=100 with a radius of 20.
    You would use: drawCirc(screen, 120, 100, 20, red)
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  5. #2525
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von ShockD
    It's not possible to load an image greater than 512x512. Yeah that's exactly what I did so thanks anyway.

    ShockD
    Nevermind what he said. People are to lazy to try stuff out for them selfs.
    I used a 1000x1000 JPG so not a PNG. And my image was about 58Kb. You have to make sure it isn't too big. Im not sure where the limit is, so just keep it as low as possible. I didn't do anything special other then that. I just blit the part that is supposed to be seen on the screen.
    BTW Shine himself said it was a bug, so people are right about what it should've been. You probably read that aswell at ps2dev.

    Oh and Im using LUAplayer 0.16
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  6. #2526
    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 Altair
    Nevermind what he said. People are to lazy to try stuff out for them selfs.
    I used a 1000x1000 JPG so not a PNG. And my image was about 58Kb. You have to make sure it isn't too big. Im not sure where the limit is, so just keep it as low as possible. I didn't do anything special other then that. I just blit the part that is supposed to be seen on the screen.
    BTW Shine himself said it was a bug, so people are right about what it should've been. You probably read that aswell at ps2dev.

    Oh and Im using LUAplayer 0.16

    are you serious?? it doesnt work for me. i DID try it out. both png and jpg, and my images size was 600x700 (it was a map). on luaplayer .16, it says error loading image. sry, i guess i kinda did give the impression that i hadnt tried it out.
    --------------------------------------------------------------------------------------

  7. #2527
    sceKernelExitGame();
    Points: 19.955, Level: 89
    Level completed: 21%, Points required for next Level: 395
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    New York
    Beiträge
    3.126
    Points
    19.955
    Level
    89
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von emericaska8r
    bronxbomber, for your code, would you want this at the beginning:

    Code:
    while true do
    screen:clear()
    screen:blit(0, 0, menu)
    screen.flip()
    
    pad = Controls.read()
    if pad:cross() then
    screen:clear()
    break
    end
    end
    i=1
    while i<=17 do
        screen:clear()
        counter:start()
        screen:blit(0, 0, background) .............
    So that when you press x or 'c' the menu will be cleared, and go on to the rest of the code?
    thanks

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

    no problem.

  9. #2529
    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

    Zitat Zitat von Altair
    Say you want to draw a red circle on the screen at x=120 and y=100 with a radius of 20.
    You would use: drawCirc(screen, 120, 100, 20, red)
    Okay I get it now. Thanks

  10. #2530
    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

    Can anyone tell me whats wrong? In my game I have
    damage = math.random(0,6)
    this works fine, but everytime I play the numbers are always the same. Example: I play once, and the damages are 5 then 1 then 6. Then I play later, the damges are still 5 then 1 then 6.

  11. #2531
    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 emericaska8r
    Can anyone tell me whats wrong? In my game I have
    damage = math.random(0,6)
    this works fine, but everytime I play the numbers are always the same. Example: I play once, and the damages are 5 then 1 then 6. Then I play later, the damges are still 5 then 1 then 6.

    1. you dont need the "0" in the parenthesis. just put:
    Code:
    damage = math.random(6)
    2. put this:
    Code:
    math.randomseed(os.time())
    at the VERY top of you code. it will give you different numbers now.
    --------------------------------------------------------------------------------------

  12. #2532
    QJ Gamer Green
    Points: 13.310, Level: 75
    Level completed: 15%, Points required for next Level: 340
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    Here
    Beiträge
    2.715
    Points
    13.310
    Level
    75
    Downloads
    0
    Uploads
    0

    Standard

    I had the same exact problem, emericaska8r.
    Doing what Grimfate126 said (put: -math.randomseed(os:time() )- ) will fix that. I still dont know how it works though...but it does.
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  13. #2533
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Grimfate126
    are you serious?? it doesnt work for me. i DID try it out. both png and jpg, and my images size was 600x700 (it was a map). on luaplayer .16, it says error loading image. sry, i guess i kinda did give the impression that i hadnt tried it out.
    Yes im serious. Maybe your file was too big. Like I said, mine was pretty small. Its because its just repeating itself. So yeah i could just make it blit tiles, but when i started, this was the easiest and I just kept using it. But it is possible, my first release of REDaLUA can proof it.
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  14. #2534
    QJ Gamer Green
    Points: 13.310, Level: 75
    Level completed: 15%, Points required for next Level: 340
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    Here
    Beiträge
    2.715
    Points
    13.310
    Level
    75
    Downloads
    0
    Uploads
    0

    Standard

    Does anyone know of any strategy (doesnt necessarily have to be Advance Wars.) game? I something to give me a nudge forward in the game I'm making.
    Geändert von EminentJonFrost (05-30-2006 um 06:27 AM Uhr)
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

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

    THat worked;, thanks GrimFate.

  16. #2536
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von EminentJonFrost
    I had the same exact problem, emericaska8r.
    Doing what Grimfate126 said (put: -math.randomseed(os:time() )- ) will fix that. I still dont know how it works though...but it does.
    think about it... a tree grows from a seed no? So your random numbers shall grow from a seed too... If you dont put a puesdo seed in there then youll keep getting the same numbers since the seed is the same... but with this, your setting the seed to be the PSPs internal time/clock which is always changing, thus giving you a random number.

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  17. #2537
    QJ Gamer Green
    Points: 13.310, Level: 75
    Level completed: 15%, Points required for next Level: 340
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    Here
    Beiträge
    2.715
    Points
    13.310
    Level
    75
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    think about it... a tree grows from a seed no? So your random numbers shall grow from a seed too... If you dont put a puesdo seed in there then youll keep getting the same numbers since the seed is the same... but with this, your setting the seed to be the PSPs internal time/clock which is always changing, thus giving you a random number.
    oohhh.
    now I feel stupid. lol
    thanks for the good explanation, SG57.
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

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

    can someone PLEASE comipile a luaplayer script for me?? for some reason, it only works on luaplayer .17 dk2. PM me if you want to try compiling it. i cant do it, cause my comp cant handle cygwin, and im leaving for a month on vacation in about an hour.
    --------------------------------------------------------------------------------------

  19. #2539
    QJ Gamer Gold
    Points: 18.627, Level: 86
    Level completed: 56%, Points required for next Level: 223
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    LOLWUT
    Beiträge
    2.625
    Points
    18.627
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    How do you make text stay there if you press X, and you would need to hold it for teh text to stay there. I want it so the text appears and stays when I press X. I tried:

    Code:
    if pad:cross() then
    screen:print(10,10,"TEST TEST TEST", red)
    screen.flip() --I also tried screen.waitVblankStart()
    end
    I tried screen.flip OR screen.waitVblankStart(), neither worked. Help
    Thank you :icon_smil :icon_smil :icon_smil :icon_smil :icon_smil :icon_smil
    --PSPduh

  20. #2540
    SHOOP DA WHOOP
    Points: 12.310, Level: 72
    Level completed: 65%, Points required for next Level: 140
    Overall activity: 99,7%

    Registriert seit
    Aug 2005
    Ort
    Wii forums
    Beiträge
    7.407
    Points
    12.310
    Level
    72
    Downloads
    0
    Uploads
    0

    Standard

    you have to make it into a looping thing

    (dont ask me about it though, i only program a little bit)

    but here is the problem, your program runs, and doesnt check again, you have to get it to run and check

    code: (im not sure if this is right)

    while 1
    if pad:cross() then
    screenrint(10,10,"TEST TEST TEST", red)
    screen.flip()
    end

  21. #2541
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von Floppydrive
    you have to make it into a looping thing

    (dont ask me about it though, i only program a little bit)

    but here is the problem, your program runs, and doesnt check again, you have to get it to run and check

    code: (im not sure if this is right)

    while 1
    if pad:cross() then
    screenrint(10,10,"TEST TEST TEST", red)
    screen.flip()
    end
    Close but no cigar yet...
    Code:
    while true do
    pad = Controls.read()
    if pad:cross() then
    screen:print(10,10,"TEST TEST TEST", Color.new(255,0,0))
    screen.waitVblankStart()
    screen.flip()
    end
    Give that a whirl...

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  22. #2542
    QJ Gamer Gold
    Points: 18.627, Level: 86
    Level completed: 56%, Points required for next Level: 223
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    LOLWUT
    Beiträge
    2.625
    Points
    18.627
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    If I do what you said SG57, with the screen.waitVblankStart() and screen.flip() under the pad:cross(), it flickers when I hold X, and doesn't stay there when I press it.

  23. #2543
    Quality Haxing Since 1991
    Points: 29.255, Level: 99
    Level completed: 55%, Points required for next Level: 745
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Pennsylvania, USA Fi
    Beiträge
    6.206
    Points
    29.255
    Level
    99
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von PSPduh
    If I do what you said SG57, with the screen.waitVblankStart() and screen.flip() under the pad:cross(), it flickers when I hold X, and doesn't stay there when I press it.
    Then you probably have a screen.flip() somewhere in your code (probably near the end) and it's reflipping it. Try taking out the screen.flip() in SG57's code and see what happens.
    Zitat Zitat von Noriko
    I would call you gay but I love you.


    Wait ...huh.



  24. #2544
    QJ Gamer Gold
    Points: 18.627, Level: 86
    Level completed: 56%, Points required for next Level: 223
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    LOLWUT
    Beiträge
    2.625
    Points
    18.627
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    black = Color.new(0, 0, 0)
    white = Color.new(255, 255, 255)
    grey = Color.new(127,127,127)
    red = Color.new(255, 0, 0) 
    green = Color.new(0, 255, 0)
    blue = Color.new(0, 0, 255)
    yellow = Color.new(255,255,0)
    purple = Color.new(120,0,120)
    pink = Color.new(255,0,255)
    orange = Color.new(255,110,0)
    
    ms = 0
    x = 0
    
    while true do
    screen:clear(black)
    pad = Controls.read()
    
    if pad:up() then
    ms = ms - 1
    screen.waitVblankStart(4)
    end
    
    if pad:down() then
    ms = ms + 1
    screen.waitVblankStart(4)
    end
    
    if pad:cross() then
    screen:print(10,10,"DUHDUHDUH", white)
    screen.waitVblankStart()
    end
    
    screen.waitVblankStart()
    screen.flip()
    end
    If i try the above code then it stays there when I HOLD X, and just appears then disappears if i press it. :Argh: :Argh: :Argh: :Argh:

  25. #2545
    QJ Gamer Green
    Points: 13.310, Level: 75
    Level completed: 15%, Points required for next Level: 340
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    Here
    Beiträge
    2.715
    Points
    13.310
    Level
    75
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    if pad:cross() then
    if duh == false then
    duh = true
    elseif duh == true then
    duh = false
    end
    end
    
    if duh == true then
    screen:print(10,10,"DUHDUHDUH", white)
    end
    that what you're looking for?
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  26. #2546
    QJ Gamer Gold
    Points: 18.627, Level: 86
    Level completed: 56%, Points required for next Level: 223
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Ort
    LOLWUT
    Beiträge
    2.625
    Points
    18.627
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von EminentJonFrost
    Code:
    if pad:cross() then
    if duh == false then
    duh = true
    elseif duh == true then
    duh = false
    end
    end
    
    if duh == true then
    screen:print(10,10,"DUHDUHDUH", white)
    end
    that what you're looking for?
    YEs that what I was looking for. Thanks. :):):):):):):):):):):):): ):):):):):):):):):)

  27. #2547
    is an idiot
    Points: 7.262, Level: 56
    Level completed: 56%, Points required for next Level: 88
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    354
    Points
    7.262
    Level
    56
    Downloads
    0
    Uploads
    0

    Standard

    im trying to get a wav to play with my menu and put it as a varible like all my other sounds and my other sounds work fine but this wav file wont work when i try to load my game on the windows LUA Player the dos box sais error loading sound and crashes so why is it having an error with this wav file but none of my other wav files? is it because the wav it too big of a size or what? the one im trying to play now is 30mb

  28. #2548
    Quality Haxing Since 1991
    Points: 29.255, Level: 99
    Level completed: 55%, Points required for next Level: 745
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Pennsylvania, USA Fi
    Beiträge
    6.206
    Points
    29.255
    Level
    99
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Goldrush
    im trying to get a wav to play with my menu and put it as a varible like all my other sounds and my other sounds work fine but this wav file wont work when i try to load my game on the windows LUA Player the dos box sais error loading sound and crashes so why is it having an error with this wav file but none of my other wav files? is it because the wav it too big of a size or what? the one im trying to play now is 30mb
    www.evilmana.com/tutorials
    Zitat Zitat von Noriko
    I would call you gay but I love you.


    Wait ...huh.



  29. #2549
    QJ Gamer Bronze
    Points: 5.744, Level: 48
    Level completed: 97%, Points required for next Level: 6
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Ort
    Plainfield, IL USA
    Beiträge
    18
    Points
    5.744
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Okay... I'm a little confused right now (I'm about to fall asleep on my keyboard). Well anyway, I have created an empty image that is 480x272. I want to store my two background images in there so it only blits what is shown on screen. Can anybody show me how to do this? I think I would get it if I had a good night's sleep.

    Thanks,
    ShockD

  30. #2550
    QJ Gamer Green
    Points: 15.884, Level: 81
    Level completed: 7%, Points required for next Level: 466
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    This Forum
    Beiträge
    1.825
    Points
    15.884
    Level
    81
    Downloads
    0
    Uploads
    0

    Standard

    Is there any way to make an action ocur only if a certian two buttons are pressed at the same time? Thank you for your time :icon_smil
    Geändert von Ralan (05-31-2006 um 09:24 PM Uhr)
    Taking things too far one step at a time


 

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

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