Seite 268 von 342 ErsteErste ... 168 218 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 318 ... LetzteLetzte
Zeige Ergebnis 8.011 bis 8.040 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 Savagefreak Could anyone tell me how to print the OS time with a custom TTF font? I have ...

  
  1. #8011
    Ænima
    Points: 6.447, Level: 52
    Level completed: 49%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Sep 2007
    Beiträge
    587
    Points
    6.447
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Savagefreak
    Could anyone tell me how to print the OS time with a custom TTF font?
    I have this now:
    See this line that was posted above yours?

    math.randomseed(os.time())

    Code:
    screen:fontPrint(font_top,210,25,os.time(),black)
    Haven't coded lua in a while, but it should work.



  2. #8012
    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 Screen Buffer

    Does anyone know how to take what is on the screen front buffer and blit it to the back buffer without reblitting all items and without blitting to a storage image first.

    What I want to do is,

    Code:
    screen:blit(x,y,image)
    screen:blit(x,y,image)
    screen.flip()
    
    screen:blit(0,0,screen)
    I know its a wierd request, but it has to do with some userforms I'm developing.

    funny thing is that this process works in windows luaplayer, but not on the psp. Any help would be greatly appreciated. (and this does need to be quick so saving and loading a screen shot would not be a useful technique.)

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

    why not use a .txt file load it let the user enter the data and use a save button or something
    ------ 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. #8014
    Ænima
    Points: 6.447, Level: 52
    Level completed: 49%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Sep 2007
    Beiträge
    587
    Points
    6.447
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von KleptoOne
    Does anyone know how to take what is on the screen front buffer and blit it to the back buffer without reblitting all items and without blitting to a storage image first.

    What I want to do is,

    Code:
    screen:blit(x,y,image)
    screen:blit(x,y,image)
    screen.flip()
    
    screen:blit(0,0,screen)
    I know its a wierd request, but it has to do with some userforms I'm developing.

    funny thing is that this process works in windows luaplayer, but not on the psp. Any help would be greatly appreciated. (and this does need to be quick so saving and loading a screen shot would not be a useful technique.)
    I'm not sure what you're asking, but do you want to basically stick two pictures together as one? If so, load the first image. Then, blit the second, but not to the screen, to the other image. I know the C graphics library has it (blitAlphaImagetoImage), but I'm not sure what the Lua function is. You could also modify the Lua source code to make the save image function to save into the RAM.

  5. #8015
    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 Judas
    I'm not sure what you're asking, but do you want to basically stick two pictures together as one? If so, load the first image. Then, blit the second, but not to the screen, to the other image. I know the C graphics library has it (blitAlphaImagetoImage), but I'm not sure what the Lua function is. You could also modify the Lua source code to make the save image function to save into the RAM.
    The lua function is image:blit(x,y,loadedimag e). Thats not what I'm trying to do though. Basically I'm making vba like userforms, and I would like to be able to call them on the fly without worrying about the background. When the form is called, it is stuck within a loop until the user finishes input, so I would like to reblit the already existing front buffer to a temp image and reblit that within my form loop. All I want is to be able to access the front or back buffer in the screen object, but doing a pairs printout of the screen table, it doesn't look like that will be possible, oh well.

  6. #8016
    dsi
    dsi ist offline
    PREMIUM Member
    Points: 4.816, Level: 44
    Level completed: 33%, Points required for next Level: 134
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    29
    Points
    4.816
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von emericaska8r
    i don't think you can run 1.50 homebrew on a slim. try the 1.00 Eboot version maybe.

    No, that one doesn't work, it gives me a crash message. Team Noobz recommended the 1.50 version, which does start. The only problem is it can't find the script file for some reason, as I mentioned above.

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

    Talking

    Zitat Zitat von KleptoOne
    The lua function is image:blit(x,y,loadedimag e). Thats not what I'm trying to do though. Basically I'm making vba like userforms, and I would like to be able to call them on the fly without worrying about the background. When the form is called, it is stuck within a loop until the user finishes input, so I would like to reblit the already existing front buffer to a temp image and reblit that within my form loop. All I want is to be able to access the front or back buffer in the screen object, but doing a pairs printout of the screen table, it doesn't look like that will be possible, oh well.
    yes it would it would be quite simple

    e.g.
    Code:
    make a menu say the third option was a form
     
    if
    pad:cross()
    and
    current == 3
    then
    whichever form = true
    end
     
    if
    whichever form == true
    then
    -->form code<--
    end

    -= Double Post =-
    Zitat Zitat von KleptoOne
    The lua function is image:blit(x,y,loadedimag e). Thats not what I'm trying to do though. Basically I'm making vba like userforms, and I would like to be able to call them on the fly without worrying about the background. When the form is called, it is stuck within a loop until the user finishes input, so I would like to reblit the already existing front buffer to a temp image and reblit that within my form loop. All I want is to be able to access the front or back buffer in the screen object, but doing a pairs printout of the screen table, it doesn't look like that will be possible, oh well.
    yes it would it would be quite simple

    e.g.
    Code:
    make a menu say the third option was a form
     
    if
    pad:cross()
    and
    current == 3
    then
    whichever form = true
    end
     
    if
    whichever form == true
    then
    -->form code<--
    end
    Geändert von FaT3oYCG (09-20-2007 um 04:00 AM Uhr) Grund: Automerged Doublepost
    ------ 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).

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

    why
    do
    you
    type
    your
    code
    like
    this?

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

    because
    i
    find
    it
    easier
    to
    understand
    in
    this
    format

    is
    that
    ok
    with
    you
    ???
    ------ 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).

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

    proof that number of lines doesnt mean anything

  11. #8021
    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 myschoo
    proof that number of lines doesnt mean anything
    i agree with that but i have not once bragged about how many lines of code anything i have made has
    ------ 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).

  12. #8022
    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 FaT3oYCG
    yes it would it would be quite simple

    e.g.
    Code:
    make a menu say the third option was a form
     
    if
    pad:cross()
    and
    current == 3
    then
    whichever form = true
    end
     
    if
    whichever form == true
    then
    -->form code<--
    end

    -= Double Post =-


    yes it would it would be quite simple

    e.g.
    Code:
    make a menu say the third option was a form
     
    if
    pad:cross()
    and
    current == 3
    then
    whichever form = true
    end
     
    if
    whichever form == true
    then
    -->form code<--
    end
    Using a state system defeats the purpose of creating a vba like form (for my purpose). I'm trying to generalize the process and not make it specific to my application, so that I can load a userform library into whatever application I am working on and have it function the same way each time.

    Edit
    if you've ever worked with vba, it would be the same as creating a dialog window, specifying what type of form you are creating and where you would like it to display within the window. But all of this is irrelevent, all I wanted to know was if there was a quick way to transfer the front buffer to the back buffer, nothing else.

  13. #8023
    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

    OK i have a question what i want to do is load a file e.g. a txt file a lua file and put the text on the screen nothing else no movement i can do that myself

    basically i can get it to put the text on the screen on different lines but i want it to follow on a line instead of going off the screen

    e.g.

    if i had a really long line like this one then it would go off the edge of the psp's screen

    what i am asking is how would i make it do something
    like this does by going onto the next line automatically
    but not chopping off bits of words

    also

    on a different note does anyone know how i would backup the entire flash of my psp by coding it in lua i have used many different ways and none of them seem to work
    Geändert von FaT3oYCG (09-21-2007 um 03:40 PM 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).

  14. #8024
    QJ Gamer Bronze
    Points: 4.912, Level: 44
    Level completed: 81%, Points required for next Level: 38
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    90
    Points
    4.912
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von FaT3oYCG
    i agree with that but i have not once bragged about how many lines of code anything i have made has
    Uh...yes you have >_> :

    Zitat Zitat von FaT3oYCG
    i have done all of the code myself and there are 9 files with over one hundred lines some with more

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

    lol
    PWN'd!

  16. #8026
    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 nataku92
    Uh...yes you have >_> :
    ok i take that back lol

    anyway

    OK i have a question what i want to do is load a file e.g. a txt file a lua file and put the text on the screen nothing else no movement i can do that myself

    basically i can get it to put the text on the screen on different lines but i want it to follow on a line instead of going off the screen

    e.g.

    if i had a really long line like this one then it would go off the edge of the psp's screen

    what i am asking is how would i make it do something
    like this does by going onto the next line automatically
    but not chopping off bits of words

    also

    on a different note does anyone know how i would backup the entire flash of my psp by coding it in lua i have used many different ways and none of them seem to work

    could someone help me with that
    ------ 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).

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

    Print the text and if the text is going to reach the end of the screen start printing it on the next line.
    Simple, or will it take a month to code it? lol

  18. #8028
    Ænima
    Points: 6.447, Level: 52
    Level completed: 49%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Sep 2007
    Beiträge
    587
    Points
    6.447
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    You have to figure out how many characters can be put on a line. Then, when the number of characters you are printing gets close to the max number, find the nearest space, and break it off, and start printing on the next line.

  19. #8029
    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

    is there function to replace character?

    ie. i have string = "hello" and i want to replace all "o" characters wth "0" so it would look like "hell0"

    anyone?

    edit. nvm got it:

    string = string.gsub(string, "o", "0")

  20. #8030
    Ænima
    Points: 6.447, Level: 52
    Level completed: 49%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Sep 2007
    Beiträge
    587
    Points
    6.447
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    Does anyone know if you can use switch loops in Lua?

  21. #8031
    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 Judas
    You have to figure out how many characters can be put on a line. Then, when the number of characters you are printing gets close to the max number, find the nearest space, and break it off, and start printing on the next line.
    easily said not so easily done

    or does someone want to post some code and completeley rip me again
    ------ 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).

  22. #8032
    Ænima
    Points: 6.447, Level: 52
    Level completed: 49%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Sep 2007
    Beiträge
    587
    Points
    6.447
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von FaT3oYCG
    easily said not so easily done

    or does someone want to post some code and completeley rip me again
    Easily said, and easily done. The font is 8 pixels wide, so the screen can hold 60 characters across. Seek to the 60th character in the file. Check to see if it's a space. If it is, print on a new line. If it's not, start seeking backwards checking for spaces. When you find one, break it off there, and print on a new line. If for some reason, you don't find a space, because you have a 61 character long word, insert a hyphen after character 59, and then print on the next line.

  23. #8033
    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

    Zitat Zitat von Judas
    Does anyone know if you can use switch loops in Lua?
    You mean like switch case statements in C/C++? If that's what you mean, then no.

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

    hmm when i use function file:read(), it only reads 1st line from the file.. is that ok? o_O

  25. #8035
    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

    Zitat Zitat von Judas
    Easily said, and easily done. The font is 8 pixels wide, so the screen can hold 60 characters across. Seek to the 60th character in the file. Check to see if it's a space. If it is, print on a new line. If it's not, start seeking backwards checking for spaces. When you find one, break it off there, and print on a new line. If for some reason, you don't find a space, because you have a 61 character long word, insert a hyphen after character 59, and then print on the next line.
    But the problem is he dont know how to do that.

  26. #8036
    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

    yeah lol exactly...

    but it just takes few string manipulations...

  27. #8037
    Ænima
    Points: 6.447, Level: 52
    Level completed: 49%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Sep 2007
    Beiträge
    587
    Points
    6.447
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Anti-QuickJay
    But the problem is he dont know how to do that.
    Then he's not a very good coder. That's fairly simple to do.

    Anyway, I found the answer to my other question on switch-case loops. Here's the documentation in case anyone else wants it.

    http://lua-users.org/wiki/SwitchStatement

  28. #8038
    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

    Zitat Zitat von Judas
    Does anyone know if you can use switch loops in Lua?
    Lua doesn't have switch/select case, but you can rig an approximation using a table of functions (pseudocode):

    Code:
    select = {}
    function select.case1()
         code...
    end
    
    function select.case2()
        code...
    end
    
    function select.case3()
         code...
    end
    
    case = "case1"
    
    select[case]()
    *edit*
    lol, you beat me to it..

    myschoo, file:read("*a") will put the entire text of the file into a single variable.

    alternately, you can use this to read each line from the file into a table:
    Code:
    data = {}
    for line in io.lines(filename) do 
         table.insert(data, line)
    end
    note: io.lines will automatically open the file for reading and then close it once the entire file has been read

    file:lines() will do the same thing for an already opened file, and will keep the file open after it's been read

  29. #8039
    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

    merick: i know io.lines but i didnt want to use it. thx 4 answer

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

    merick: umm ... *a doesnt work... tried a and a+ and that didnt help


 

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

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