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. ...
-
01-13-2007, 12:21 PM #5011QJ Gamer Blue
- 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
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
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....Code:name = "The undead" search = name --and search funtion would be here like search1 -- and then search stuff....
-
01-13-2007, 12:58 PM #5012words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
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
-
01-13-2007, 01:27 PM #5013QJ Gamer Blue
- 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
how would i make it?.....sorry if i ask to many questions im just eager to learn new things.
Zitat von SG57
-
01-13-2007, 01:45 PM #5014QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
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
-
01-13-2007, 02:52 PM #5015QJ Gamer Blue
- 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
ok thats basicaly what i needed, ill try it. its not exact but ill change some stuff.
Zitat von TacticalPinguin
-
01-13-2007, 06:28 PM #5016
ok i have two questions,
Zitat von TacticalPinguin
1 - why did you start the for loop at 3?
2 - what does (if not file[i].directory) do?
thanks for any answers
-
01-13-2007, 09:11 PM #5017
- Registriert seit
- Dec 2006
- Beiträge
- 14
- Points
- 3.536
- Level
- 37
- Downloads
- 0
- Uploads
- 0
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
-
01-13-2007, 10:38 PM #5018QJ Gamer Blue
- 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
try
Zitat von yotop456
thats all you doCode:wavfile = nil
-
01-14-2007, 05:32 AM #5019Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
wav = song.wav
Zitat von yotop456
wav = nil
all done
as for dofiles
dofiles are like this
say your script is like this
and in the dofile you haveCode:while true do screen:print(0,0,"I like cake a lot",red) dofile("bla.lua") screen.waitVblankStart() screen.flip() end
then according to the psp and lua player this is what script isCode:screen:print(0,10,"BUt i also like donuts",red)
-= Double Post =-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
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
And here is whats inside my text fileCode:--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
named tab.txt
Im trying to get scrollign to work also if someone could help me there too. and one more thing this lineCode:-3---3--------------2-0-------| -3-----3---3------3-----3---3-| -0-------0------2---------2---| -0------------0---------------| ------------------------------| -3----------------------------|
What is my tab is in a certain directory wouldnt it beCode:file = io.open("tab.txt","r")
right?Code:file = io.open("./tab/tab.txt","r")
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 somethignGeä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!
-
01-14-2007, 06:11 AM #5020
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
-
01-14-2007, 06:37 AM #5021Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
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!
-
01-14-2007, 02:16 PM #5022
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.
-
01-14-2007, 02:23 PM #5023lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
-
01-14-2007, 05:01 PM #5024QJ Gamer Silver
- Registriert seit
- Oct 2006
- Ort
- 貴方
- Beiträge
- 1.159
- Points
- 7.371
- Level
- 57
- Downloads
- 0
- Uploads
- 0
i cant seem to figure out y none of the menus i have coded work
here is my code
Zitat von code
-
01-14-2007, 05:25 PM #5025lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
You will see your problems when you compare your code to this,
Zitat von HeaD_ShOt
http://evilmana.com/tutorials/codebase/simple_menu.php
Also, You should try this
Also, Where is this suppose to screenprint?Code:if pad:cross() and current == 1 then dofile("alphabet.lua") end
You forgot the coordinates.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
-
01-14-2007, 05:26 PM #5026QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
its supposed to be:
you didnt put these: ./Code:dofile("./file.lua")[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-14-2007, 05:27 PM #5027lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Since when do you have to do that? I neve have to do it.
Zitat von EminentJonFrost
-
01-14-2007, 06:00 PM #5028QJ Gamer Silver
- Registriert seit
- Oct 2006
- Ort
- 貴方
- Beiträge
- 1.159
- Points
- 7.371
- Level
- 57
- Downloads
- 0
- Uploads
- 0
u dont have to put those in
-
01-14-2007, 06:10 PM #5029lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Yea, i thought so.
-
01-14-2007, 08:56 PM #5030
- Registriert seit
- Dec 2006
- Beiträge
- 14
- Points
- 3.536
- Level
- 37
- Downloads
- 0
- Uploads
- 0
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
-
01-14-2007, 08:58 PM #5031QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
You need to first of all divide it into increments smaller than 512x512.
-
01-14-2007, 10:58 PM #5032
- Registriert seit
- Dec 2006
- Beiträge
- 14
- Points
- 3.536
- Level
- 37
- Downloads
- 0
- Uploads
- 0
k then what do i need to
-
01-14-2007, 11:07 PM #5033QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
blit them scrolling down, if one goes off the bottom of the screen, blit it above the screen.
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
01-15-2007, 06:18 AM #5034QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Yea use a variable and then blit them based off the variable. Then icrease/decrease that variable.
-
01-15-2007, 09:15 AM #5035QJ Gamer Blue
- Registriert seit
- Jul 2006
- Beiträge
- 72
- Points
- 4.209
- Level
- 41
- Downloads
- 0
- Uploads
- 0
I need to know how to get the color of a pixel. I am using the code:
and when I run the program, the error is "An argument was incorrect"Code:check=screen:pixel(checkx, checky)
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 von yotop456
If you still need the exact code:
and to change the speed, just change the "1" in the line "for imageY..."Code:imageY=0 image=Image.load(imagelocation) for imageY=0, 2300, 1 do screen:blit(0, imageY, image)
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
-
01-15-2007, 09:23 AM #5036
- Registriert seit
- Jul 2006
- Beiträge
- 36
- Points
- 3.957
- Level
- 40
- Downloads
- 0
- Uploads
- 0
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
-
01-15-2007, 09:37 AM #5037QJ Gamer Blue
- Registriert seit
- Jul 2006
- Beiträge
- 72
- Points
- 4.209
- Level
- 41
- Downloads
- 0
- Uploads
- 0
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
-
01-15-2007, 09:49 AM #5038
- Registriert seit
- Jul 2006
- Beiträge
- 36
- Points
- 3.957
- Level
- 40
- Downloads
- 0
- Uploads
- 0
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
-
01-15-2007, 12:14 PM #5039words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
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
-
01-15-2007, 12:15 PM #5040
the reason he thought so was because on earlier versions of lua you did have to put them in.
Zitat von HeaD_ShOt


LinkBack URL
About LinkBacks
Mit Zitat antworten
rint(10,10,"Quick Japanese",white)

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum