Seite 168 von 342 ErsteErste ... 68 118 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 218 268 ... LetzteLetzte
Zeige Ergebnis 5.011 bis 5.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; ok so, ive been reading up on files and what not but i cant find anything usefull that i need. ...

  
  1. #5011
    QJ Gamer Blue
    Points: 4.918, Level: 44
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    6ft. Down Underground........Oh and guess what my avatar is
    Beiträge
    387
    Points
    4.918
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    ok so, ive been reading up on files and what not but i cant find anything usefull that i need. im trying to make it were i have a string like
    Code:
    name = "The undead"
    search = name
    
    --and search funtion would be here like
    search1 -- and then search stuff....
    and i want to search for a file named wehat ever is in the string, then open that file and read it. but i cant figure out how to do this, ive spent months looking....



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

    the_undead, there is no function for that at your disposal right now. But, you can easily make it.

    You'd need to make it recursively scan each directory on the memory stick for a file name with the string specified, and if found - try to open it with read-only permission.

    Or something similar Im sure...

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


  3. #5013
    QJ Gamer Blue
    Points: 4.918, Level: 44
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    6ft. Down Underground........Oh and guess what my avatar is
    Beiträge
    387
    Points
    4.918
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    the_undead, there is no function for that at your disposal right now. But, you can easily make it.

    You'd need to make it recursively scan each directory on the memory stick for a file name with the string specified, and if found - try to open it with read-only permission.

    Or something similar Im sure...
    how would i make it?.....sorry if i ask to many questions im just eager to learn new things.

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

    Ill give you an example to scan a single directory:

    files = System.listDirectory()
    for i = 3, table.getn(files) do
    if not files[i].directory then
    if files[i].name == "somefilename.someextensi on" then
    *whatever you wanna do when it finds it*
    end
    end
    end

  5. #5015
    QJ Gamer Blue
    Points: 4.918, Level: 44
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    6ft. Down Underground........Oh and guess what my avatar is
    Beiträge
    387
    Points
    4.918
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von TacticalPinguin
    Ill give you an example to scan a single directory:

    files = System.listDirectory()
    for i = 3, table.getn(files) do
    if not files[i].directory then
    if files[i].name == "somefilename.someextensi on" then
    *whatever you wanna do when it finds it*
    end
    end
    end
    ok thats basicaly what i needed, ill try it. its not exact but ill change some stuff.

  6. #5016
    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 TacticalPinguin
    Ill give you an example to scan a single directory:

    files = System.listDirectory()
    for i = 3, table.getn(files) do
    if not files[i].directory then
    if files[i].name == "somefilename.someextensi on" then
    *whatever you wanna do when it finds it*
    end
    end
    end
    ok i have two questions,

    1 - why did you start the for loop at 3?
    2 - what does (if not file[i].directory) do?

    thanks for any answers

  7. #5017
    Points: 3.536, Level: 37
    Level completed: 24%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Beiträge
    14
    Points
    3.536
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    hi i have a few problems that i cant seem to figure out.

    can someone tell me if there is a code to unload .wav files? because i seem to run out of memory when i load more then 4 of them ( there very short and small in size).

    also when you dofile a script, is the script that is being dofiled being executed over the script before it, meaning the script remains loaded in the memory while the new script is loaded?

    Thanks

  8. #5018
    QJ Gamer Blue
    Points: 4.918, Level: 44
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    6ft. Down Underground........Oh and guess what my avatar is
    Beiträge
    387
    Points
    4.918
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von yotop456
    hi i have a few problems that i cant seem to figure out.

    can someone tell me if there is a code to unload .wav files? because i seem to run out of memory when i load more then 4 of them ( there very short and small in size).

    also when you dofile a script, is the script that is being dofiled being executed over the script before it, meaning the script remains loaded in the memory while the new script is loaded?

    Thanks
    try
    Code:
    wavfile = nil
    thats all you do

  9. #5019
    Ponies and Unicorns
    Points: 5.778, Level: 49
    Level completed: 14%, Points required for next Level: 172
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Pelennor Fields
    Beiträge
    547
    Points
    5.778
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von yotop456
    hi i have a few problems that i cant seem to figure out.

    can someone tell me if there is a code to unload .wav files? because i seem to run out of memory when i load more then 4 of them ( there very short and small in size).

    also when you dofile a script, is the script that is being dofiled being executed over the script before it, meaning the script remains loaded in the memory while the new script is loaded?

    Thanks
    wav = song.wav

    wav = nil

    all done

    as for dofiles

    dofiles are like this
    say your script is like this

    Code:
    while true do
    screen:print(0,0,"I like cake a lot",red)
    dofile("bla.lua")
    screen.waitVblankStart()
    screen.flip()
    end
    and in the dofile you have
    Code:
    screen:print(0,10,"BUt i also like donuts",red)
    then according to the psp and lua player this is what script is

    Code:
    while true do
    screen:print(0,0,"I like cake a lot",red)
    screen:print(0,10,"BUt I also like donuts",red)
    screen.waitVblankStart()
    screen.flip()
    end
    -= Double Post =-
    Ok im trying to get my tab reader working and im trying to print all the lines of a tab to the screen from a text file named tab.txt and its not working. So far here is my code
    Code:
    --declare some colors and whatnot
    blue = Color.new(0,0,255)
    red = Color.new(255,0,0)
    background = Image.createEmpty(480,272)
    background:clear(blue)
    --main loop
    while true do
    screen:blit(0,0,background)
    --now lets read the tab
    y = 5
    file = io.open("tab.txt","r")
    for line in file:lines() do
    y = y + 5
    screen:print(0,y,line,white)
    end
    file:close
    screen.waitVblankStart()
    screen.flip()
    end
    And here is whats inside my text file
    named tab.txt
    Code:
    -3---3--------------2-0-------|
    -3-----3---3------3-----3---3-|
    -0-------0------2---------2---|
    -0------------0---------------|
    ------------------------------|
    -3----------------------------|
    Im trying to get scrollign to work also if someone could help me there too. and one more thing this line

    Code:
    file = io.open("tab.txt","r")
    What is my tab is in a certain directory wouldnt it be
    Code:
    file = io.open("./tab/tab.txt","r")
    right?

    Could use some help.
    -= Double Post =-
    O yah adn the error im getting is like something wrong with the argument screen on line 20 or somethign
    Geändert von GuitarGod1134 (01-14-2007 um 05:32 AM Uhr) Grund: Automerged Doublepost
    If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
    Gold donations are highly appreciated!

  10. #5020
    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 look on the page before for my question?

    and for guitargod, i don't see anything wrong with that code to read the lines, but i just want to let you know that instead of defining background as an image, and clearing it, and then blitting it; you could just do screen:clear(blue)

    and let us all know what you need exactly for scrolling
    -= Double Post =-
    wait, i don't know if this is right, but could you do:
    Code:
    for 0,  line in file:lines() do
    Geändert von emericaska8r (01-14-2007 um 06:11 AM Uhr) Grund: Automerged Doublepost

  11. #5021
    Ponies and Unicorns
    Points: 5.778, Level: 49
    Level completed: 14%, Points required for next Level: 172
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Pelennor Fields
    Beiträge
    547
    Points
    5.778
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    like when you press down it scrolls down the lines of text that are being read from the file.
    If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
    Gold donations are highly appreciated!

  12. #5022
    QJ Gamer Silver
    Points: 11.326, Level: 70
    Level completed: 19%, Points required for next Level: 324
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    871
    Points
    11.326
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Hi does anyone know how to do a Typewriter effect?
    Free Prizes at Prizerebel Join us!
    I already got 11 Gifts. Ask me for details or proof.

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

  14. #5024
    QJ Gamer Silver
    Points: 7.371, Level: 57
    Level completed: 11%, Points required for next Level: 179
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    貴方
    Beiträge
    1.159
    Points
    7.371
    Level
    57
    Downloads
    0
    Uploads
    0

    Standard

    i cant seem to figure out y none of the menus i have coded work
    here is my code
    Zitat Zitat von code
    --Quick Japanese
    --By Cheese the psp
    --Thank you to all those that have writen a tutorial

    System.usbDiskModeActivat e()

    white = Color.new(255,255,255)
    red = Color.new(255,0,0)

    current = 1
    oldpad = Controls.read()
    while true do
    pad = Controls.read()
    screen:clear()

    screenrint(10,10,"Quick Japanese",white)
    screenrint(10,20,"by Cheese the Psp, from the QJ forums",white)
    screenrint(192,95,"Categories", white)
    screenrint(192,105,"Alphabet",w hite)
    screenrint(192,115,"Usefull Phrases",white)
    screenrint(192,125,"Dictionary" ,white)

    if current == 1 then
    screenrint("Alphabet",red)
    end
    if current == 2 then
    screenrint("Usefull Phrases",red)
    end
    if current == 3 then
    screenrint("Dictionary",red)
    end

    if pad:up() then
    current = current - 1
    if current == 0 then
    current = 3
    end
    end

    if pad:down() then
    current = current + 1
    if current == 4 then
    current = 1
    end
    end

    if pad:cross() then
    if current == 1 then
    dofile("alphabet.lua")
    elseif current == 2 then
    dofile("usefullphrases.lu a")
    elseif current == 3 then
    dofile("dictionary.lua")
    end

    screen.waitvblankStart()
    screen.flip()
    oldpad = pad
    end
    end

  15. #5025
    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 HeaD_ShOt
    i cant seem to figure out y none of the menus i have coded work
    here is my code
    You will see your problems when you compare your code to this,
    http://evilmana.com/tutorials/codebase/simple_menu.php
    Also, You should try this

    Code:
    if pad:cross() and current == 1 then
         dofile("alphabet.lua")
    end
    Also, Where is this suppose to screenprint?

    Code:
    if current == 1 then
    screen:print("Alphabet",red)
    end
    if current == 2 then
    screen:print("Useful Phrases",red)
    end
    if current == 3 then
    screen:print("Dictionary" ,red)
    end
    You forgot the coordinates.

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

    its supposed to be:

    Code:
    dofile("./file.lua")
    you didnt put these: ./
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  17. #5027
    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 EminentJonFrost
    its supposed to be:

    Code:
    dofile("./file.lua")
    you didnt put these: ./
    Since when do you have to do that? I neve have to do it.

  18. #5028
    QJ Gamer Silver
    Points: 7.371, Level: 57
    Level completed: 11%, Points required for next Level: 179
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    貴方
    Beiträge
    1.159
    Points
    7.371
    Level
    57
    Downloads
    0
    Uploads
    0

    Standard

    u dont have to put those in

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

    Yea, i thought so.

  20. #5030
    Points: 3.536, Level: 37
    Level completed: 24%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Beiträge
    14
    Points
    3.536
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    hey

    for my program i have an image 2300 pixels in hight, and 200 pixels in width. I need this picture to scroll down the screen vertically at a speed i chose,

    does anyone no any code that would allow me to do this?

    thanks

  21. #5031
    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 first of all divide it into increments smaller than 512x512.

  22. #5032
    Points: 3.536, Level: 37
    Level completed: 24%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Beiträge
    14
    Points
    3.536
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    k then what do i need to

  23. #5033
    QJ Gamer Silver
    Points: 7.278, Level: 56
    Level completed: 64%, Points required for next Level: 72
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    Pimp'en in the US F#
    Beiträge
    1.254
    Points
    7.278
    Level
    56
    Downloads
    0
    Uploads
    0

    Standard

    blit them scrolling down, if one goes off the bottom of the screen, blit it above the screen.
    The Wentire Worls in two Sectors....
    When did I get dev statz?
    Spoiler for my PSP homebrewReleases:
    Ace of Space V1|PvP Pong Online|PvP Pong v3 | 3.03 BlackShark Custom Firmware
    (PvP Pong DL'ed well over 2403 times combined! get yours now!)
    Spoiler for Great Quotes:

    "No Snowflake in an Avalanche ever feels responsible....." - Fortune Cookie.

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

    Yea use a variable and then blit them based off the variable. Then icrease/decrease that variable.

  25. #5035
    QJ Gamer Blue
    Points: 4.209, Level: 41
    Level completed: 30%, Points required for next Level: 141
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    72
    Points
    4.209
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    I need to know how to get the color of a pixel. I am using the code:

    Code:
    check=screen:pixel(checkx, checky)
    and when I run the program, the error is "An argument was incorrect"

    So I'm probably not using the pixel command correctly. If I wanted to check if the pixel at (checkx, checky) has RGB values of (255, 255, 0) How would I do that? would I have to try:

    Code:
    check=color.new(screen:pixel(checkx, checky))
    if check==(255, 255, 0) then
    ... end

    Is that how to do it? I doubt that...

    Please help me!
    -= Double Post =-
    Zitat Zitat von yotop456
    hey

    for my program i have an image 2300 pixels in hight, and 200 pixels in width. I need this picture to scroll down the screen vertically at a speed i chose,

    does anyone no any code that would allow me to do this?

    thanks

    If you still need the exact code:

    Code:
    imageY=0
    image=Image.load(imagelocation)
    for imageY=0, 2300, 1 do
    screen:blit(0, imageY, image)
    and to change the speed, just change the "1" in the line "for imageY..."

    I hope I did that right. I'm still new to this:dj:
    Geändert von PSPhakkor (01-15-2007 um 09:41 AM Uhr) Grund: Automerged Doublepost

  26. #5036
    Points: 3.957, Level: 40
    Level completed: 4%, Points required for next Level: 193
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    36
    Points
    3.957
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    grass = Image.load("menu.png")

    while true do

    screen:clear()

    screen:blit(0, 0, grass)

    screen.waitVblankStart()
    screen.flip()
    end


    y wont that work please help

  27. #5037
    QJ Gamer Blue
    Points: 4.209, Level: 41
    Level completed: 30%, Points required for next Level: 141
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    72
    Points
    4.209
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    You're clearing the screen on every loop, so you can't really see your image. Try this instead:

    Code:
    grass = Image.load("menu.png")
    screen:clear()
    while true do
    
    
    
    screen:blit(0, 0, grass)
    
    screen.waitVblankStart()
    screen.flip()
    end

  28. #5038
    Points: 3.957, Level: 40
    Level completed: 4%, Points required for next Level: 193
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    36
    Points
    3.957
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    ah never mind the problem is i dont have enough memory for all my images.
    is there a way to solve this.

    the images that are taking up the space are only viewed when x is pressed or w/e is there a way around this

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

    jamz1825 - Yes. Think logically about this first though... Theres 2 ways I see to work... One - combine the images into a sprite sheet (probably your easiest method) and use offsets to blit them from certain images.

    Two - when X is pressed, load the image and blit it at the same time, but you;d need that old pad thing so it only would load the image once, while still blitting the image if held down (so 2 if pad:cross, one with the oldpad, one without). Then, you could free the image once cross is let go. This would be the best way to be memory efficient, but not so much framerate and whatnot, as that means each time you press X and let go, it would load the image, display it, then free the image, so if you pressed X again, itd do it all over again. Does anyone have a different way then the 2 i listed?

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


  30. #5040
    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 HeaD_ShOt
    u dont have to put those in
    the reason he thought so was because on earlier versions of lua you did have to put them in.


 

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:53 AM Uhr.

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