Seite 237 von 342 ErsteErste ... 137 187 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 287 337 ... LetzteLetzte
Zeige Ergebnis 7.081 bis 7.110 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; Zitat von PSPJunkie_ And? It was the exact same thing... @[email protected] I bet you $10 that if you tried your ...

  
  1. #7081
    QJ Gamer Blue
    Points: 4.412, Level: 42
    Level completed: 31%, Points required for next Level: 138
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    Tokoroa, New Zealand
    Beiträge
    103
    Points
    4.412
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von PSPJunkie_
    And? It was the exact same thing... @[email protected]
    I bet you $10 that if you tried your code in Luaplayer, it would give you an error.



  2. #7082
    QJ Gamer Green
    Points: 11.300, Level: 70
    Level completed: 13%, Points required for next Level: 350
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Ort
    main();
    Beiträge
    1.071
    Points
    11.300
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    What? The,
    Code:
    screen:clear(Color.new(0, 0, 0))
    I wasn't sure so I looked in the tut's on PSP-Programming for the syntax and that was it...

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

    PSPJunkie_ - screen:clear( [Color] ). Without a parameter, its black. With, it requires a Color class (Color.new(r,g,b[,a])), so yours was correct. However, you have a typo... screenrint(200,100, <snip>)?

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


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

    Because they didn't check off "Disable smilies in text" so :p turned into a smiley face.

  5. #7085
    QJ Gamer Blue
    Points: 3.768, Level: 38
    Level completed: 79%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    70
    Points
    3.768
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von emericaska8r
    sure ahrimanes, thanks.
    will send wen be on pc

  6. #7086
    QJ Gamer Blue
    Points: 3.679, Level: 38
    Level completed: 20%, Points required for next Level: 121
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Ort
    Relative
    Beiträge
    135
    Points
    3.679
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    How can I declare a table that doesn't have to be initialized all at once (it should be at runtime) and can be accessed like
    Code:
    table[1].arg1 = something
    table[1].arg2 = something
    table[2].arg1 = something
    ...
    Because when I do it like
    Code:
    table = {arg1, arg2}
    I get error "attempt to index filed '?' <a nil value>"
    I don't want to do it like
    Code:
    table = {{arg1, arg2},{arg1, arg2},{arg1, arg2}...
    because I don't know how long the table should be when it is created.
    Basically I want to create something like a class that can just be filled with values latter.

    Sorry if the answer is obvious. :)

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

    unlike c, everything in lua is declared at runtime. So once you declare a table, ie table = {} , then you can index it however you like, whenever you like.

  8. #7088
    QJ Gamer Blue
    Points: 3.679, Level: 38
    Level completed: 20%, Points required for next Level: 121
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Ort
    Relative
    Beiträge
    135
    Points
    3.679
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    So
    Code:
    tab = {}
    
    for i = 0, 50 do
    	tab[i].arg1 = something
    	tab[i].arg2 = somethingother
    end
    should work? Because it doesn't.
    How would I make this work?

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

    each index has to be declared a table if you want to index it further, so

    tab = {}

    for i =1,50 do
    tab[i] = {}
    tab[i].arg1 = something
    ...ect...
    end

    That would work

  10. #7090
    QJ Gamer Blue
    Points: 3.679, Level: 38
    Level completed: 20%, Points required for next Level: 121
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Ort
    Relative
    Beiträge
    135
    Points
    3.679
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Thanks, while I was waiting for your reply I played with the code around and found that this works
    Code:
    tab = {}
    
    for i = 1, 20 do
    	tab[i] = {arg1 = 7, arg2 = 8}
    end
    Which is basically same as you said.

  11. #7091
    QJ Gamer Green
    Points: 11.300, Level: 70
    Level completed: 13%, Points required for next Level: 350
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Ort
    main();
    Beiträge
    1.071
    Points
    11.300
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    PSPJunkie_ - screen:clear( [Color] ). Without a parameter, its black. With, it requires a Color class (Color.new(r,g,b[,a])), so yours was correct. However, you have a typo... screenrint(200,100, <snip>)?
    It's good there was typo. That why it wasn't as easy as one idiot copying and pasting code. I was trying to help, too. Do people always have an aditude in here?

  12. #7092
    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

    well sometimes TP does, and i never seen SG with one, but Youresam does, and that is because he's tired of answering the same question

  13. #7093
    QJ Gamer Blue
    Points: 4.296, Level: 41
    Level completed: 73%, Points required for next Level: 54
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    132
    Points
    4.296
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von cruisx
    You know how you can move back and forth through pics in the psp XMB by pressing R and L. Well is their any way to do this in lua? like by pressing R u go to the next pick and pressing L u go back to the previous pic?
    can someone pls help?

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

    do you want to use pics in your pic folder or have the user stash their pics into your lua folder? This is really simple to do, you might want to look for some tuts on file browsing and controls.

  15. #7095
    QJ Gamer Blue
    Points: 4.296, Level: 41
    Level completed: 73%, Points required for next Level: 54
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    132
    Points
    4.296
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von KleptoOne
    do you want to use pics in your pic folder or have the user stash their pics into your lua folder? This is really simple to do, you might want to look for some tuts on file browsing and controls.

    i want to use the pics in the lua folder, can someone help me with the code or possiably link me to some tuts so that i can do it =). Thx for the rply Kelp

  16. #7096
    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 PSPJunkie_
    TP is cool. :Punk: Youresam, on the other hand.....
    To be fair to Yoursam, there are a lot of repeated questions that get ask that are super simple to figure out if you stop to think about it for a moment. If really need help, then you should have some code posted showing that you at least made an attempt to figure the problem out. Plus with code, it's alot easier to determine what you are attempting to do.

  17. #7097
    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 cruisx
    i want to use the pics in the lua folder, can someone help me with the code or possiably link me to some tuts so that i can do it =). Thx for the rply Kelp
    check this out (system portion specifically)
    http://wiki.ps2dev.org/psp:lua_player:functions#system

    It would assume a certain level of familiarity with tables. If you can't figure out how to apply it, I know I have a simple file browser programmed somewhere that I'll post, I just have to find it.

  18. #7098
    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 was wondering if there are any tutorials on making a file browser. I need it for my project i am working on. I want to learn how to make one then make my own to go with what i need. It should end up being a lot different then the tutorial one though.

    Thanks Bob Hoil

  19. #7099
    lol
    Points: 20.859, Level: 91
    Level completed: 2%, Points required for next Level: 491
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Whittier, CA
    Beiträge
    5.791
    Points
    20.859
    Level
    91
    Downloads
    0
    Uploads
    0

    Standard

    I don't think theirs a tutorial but check outs TacticalPenguin's file browser in the lua snippets thread.

  20. #7100
    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

    Ok thanks a lot. I appreciate it a ton.

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

    NOEZ! That file browser is ancient and horribiblistical. I'll find the much more uberer one I made for my shell tomorrow just remind me and I'll show it to you. (im about ready to go to sleep so not now)
    -= Double Post =-
    Oh and here's a general idea for the concept of it:
    Code:
    --get the directory listing
    blah = System.listDirectory("./pictures")
    --remove the "." and ".." files
    table.remove(blah,1)
    table.remove(blah,1)
    --get the number of pics
    for i = 1, table.getn(blah) do
        if string.lower(string.sub(blah[i].name,-4)) == (".png" or ".jpg") then
            blah[i].ispic = true
        else
            blah[i].ispic = false
        end
    end
    _currentpic = 1
    if pad:r() and not oldpad:r() then _currentpic = _currentpic + 1 elseif pad:l() and not oldpad:l() then _currentpic = _currentpic - 1 end
    if _currentpic ~= _oldcurrentpic and blah[i].ispic then
    _pic = Image.load("./pictures/"..blah[i].name)
    elseif _currentpic ~= _oldcurrentpic then
    _currentpic = _currentpic + (_oldcurrentpic - _currentpic)
    end
    etc then blit the image and just make it so when you press l/r it changes the image and checks that its an image. play with it and see what you can come up with.
    Geändert von TacticalPinguin (04-25-2007 um 08:15 PM Uhr) Grund: Automerged Doublepost

  22. #7102
    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

    TP - Have you considered using a OO approach to your programming? Nothing's wrong with what you currently do, but I highly recommend it (that doesnt mean much though, as ive yet to release anything decent using it (anything actually :P) but that will change soon).

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


  23. #7103
    QJ Gamer Blue
    Points: 3.768, Level: 38
    Level completed: 79%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    70
    Points
    3.768
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    hi wy math.random is just giving me int values? is there way to get floats?

  24. #7104
    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

    i don't know, i was fiddling with it, but nothing :Cry:

    you could use math.random for the integer part, then the decimal part, and then put them together, but that would be stupid

  25. #7105
    QJ Gamer Blue
    Points: 3.768, Level: 38
    Level completed: 79%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    70
    Points
    3.768
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von emericaska8r
    i don't know, i was fiddling with it, but nothing :Cry:

    you could use math.random for the integer part, then the decimal part, and then put them together, but that would be stupid
    im doing this
    a=0.5*100
    random(a-10,a+10)
    a=a/100
    soo i got a random float

  26. #7106
    QJ Gamer Blue
    Points: 4.369, Level: 42
    Level completed: 10%, Points required for next Level: 181
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    246
    Points
    4.369
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    lol, it's easier to just do this:

    var = math.random(100)+math.ran dom()

  27. #7107
    Developer
    Points: 4.318, Level: 41
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    205
    Points
    4.318
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    function math.randfloat(low, high)
       x=math.random()*(high-low)+low
       return x
    end
    That might work.

  28. #7108
    QJ Gamer Blue
    Points: 3.768, Level: 38
    Level completed: 79%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    70
    Points
    3.768
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    well the fact is that i have a fl value then ineed a range fl values and my original fl is the center thats wi do that ,now wiLL that function works for me ? im on_psp_far_from_pc so cant test

  29. #7109
    QJ Gamer Blue
    Points: 4.369, Level: 42
    Level completed: 10%, Points required for next Level: 181
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    246
    Points
    4.369
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    well if you take my version and just use a range in the first section like this:

    var = math.random(-10, 10)+math.random()

    you will get a float between -10 and 10

    if you want to set the range based on your original value, then do it like this:

    var = math.random( (orig-10), (orig+10) )+math.random()

  30. #7110
    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

    To make it more portable, here's a function for what you want:
    Code:
    function randomFloatFromOrigin(center,range)
         return ( math.random( (center-range), (center+range) )+math.random() )
    end
    I believe that will work, however, i havent tested it.

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



 

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 .