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; Agh, I fixed my fps meter and now I see that its running at only 20 fps at best on ...
-
01-10-2007, 05:26 PM #4981
Agh, I fixed my fps meter and now I see that its running at only 20 fps at best on the psp! Help
http://upload.team-duck.com/users/Da...vector-sig.png
http://upload.team-duck.com/users/Da...n/SOTW-Bar.jpg
I do not eat my babies - twelve
View the QJ Worm!
-
01-10-2007, 07:04 PM #4982Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von yaustar
animlib does support freeing animations. (which literally frees all the images for that animation) just simply do:
animName:free()
and it will declare the image files as nil, and perform a garbagecollect().
-= Double Post =-
Zitat von Dark_Merlin
20 FPS?!?? post your code. i think youre timer is still messed up, but it could be your code as well.Geändert von Grimfate126 (01-10-2007 um 07:04 PM Uhr) Grund: Automerged Doublepost
--------------------------------------------------------------------------------------
-
01-10-2007, 07:07 PM #4983QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
Thanks EminentJonFrost. That fixed EVERYTHING lol.
-
01-10-2007, 07:10 PM #4984Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Dark_Merlin
ok, i took a quick look at that code, and here are some ways to improve it:
1. Colors.lua is a simple waste of memory. no game uses that many colors. so many colors will limit your ram. only keep the colors that you use.
2. requireC. whats the point of this?
3. bullets. you have too many directions. if you want it that way, use my tutorial which teaches you to shoot anywhere you want, and modify it.
4. elseif's. start using them.--------------------------------------------------------------------------------------
-
01-10-2007, 07:21 PM #4985
Can do, but what would a good fps speed be?
Zitat von Grimfate126
http://upload.team-duck.com/users/Da...vector-sig.png
http://upload.team-duck.com/users/Da...n/SOTW-Bar.jpg
I do not eat my babies - twelve
View the QJ Worm!
-
01-10-2007, 07:43 PM #4986Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Dark_Merlin
try to get at least 50-55. 60 is max. if you get atlest 50, ill tell you a way to make it 60, but its super secret.
--------------------------------------------------------------------------------------
-
01-10-2007, 08:22 PM #4987
50... hmm ok.
Nice tut btw! Amazing and almost EXACTLY what i wanted :)
Oh and to get it to 60, overclock ;)http://upload.team-duck.com/users/Da...vector-sig.png
http://upload.team-duck.com/users/Da...n/SOTW-Bar.jpg
I do not eat my babies - twelve
View the QJ Worm!
-
01-10-2007, 08:30 PM #4988Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Dark_Merlin
damn it. mind reader. lol. thanks for the compliment. :)--------------------------------------------------------------------------------------
-
01-10-2007, 08:55 PM #4989QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- In the shadows..
- Beiträge
- 135
- Points
- 4.936
- Level
- 44
- Downloads
- 0
- Uploads
- 0
anyone gonna help me on my question?..
-
01-11-2007, 12:08 AM #4990
Hmm, slight problem

When moving and shooting it goes really weird o_O
Ill look at it and see what causes it...
EDIT: Fixed =)
-= Double Post =-
Well I get a constant non-dipping 30fps :)Geändert von Dark_Merlin (01-11-2007 um 12:08 AM Uhr) Grund: Automerged Doublepost
http://upload.team-duck.com/users/Da...vector-sig.png
http://upload.team-duck.com/users/Da...n/SOTW-Bar.jpg
I do not eat my babies - twelve
View the QJ Worm!
-
01-11-2007, 08:44 AM #4991QJ Gamer Silver
- Registriert seit
- Aug 2006
- Ort
- The Matrix
- Beiträge
- 1.090
- Points
- 8.002
- Level
- 60
- Downloads
- 0
- Uploads
- 0
quotes
Zitat von CoolRaccoon
http://i28.tinypic.com/1znoljt.png
lolololololol - Reach 100,000 Gamerscore
-
01-11-2007, 11:53 AM #4992QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
just letting you know, your not being ignored. you just have a genuinely tough to understand problem. i have no clue how that number sentence you posted translates to a coordinate on the screen. didnt what i post in your old thread help at all?
Zitat von xmOD
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-11-2007, 12:01 PM #4993QJ Gamer Silver
- Registriert seit
- Aug 2006
- Ort
- The Matrix
- Beiträge
- 1.090
- Points
- 8.002
- Level
- 60
- Downloads
- 0
- Uploads
- 0
help please?
http://i28.tinypic.com/1znoljt.png
lolololololol - Reach 100,000 Gamerscore
-
01-11-2007, 05:29 PM #4994words 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
Your problem?
XMod - I dont know what to tell you... file:seek("set",byte) should work by 'set'ing the current position in the 'file' stream to 'byte'... Maybe youll need to convert the number returned to ASCII, so cut it into 2's, then make them a char...
EDIT
Ohhhh theres your problem i think... Try now printing whatever is in the 'file'. I dunno how to do that in Lua, youll probably need to first file:read 4 bytes into a buffer/string and then print it out... Ill make a little snippet now for you to try ;)
So say you had the text "Hello" at the offset 1124 in a file called SG57.reg...Code:offset = OFFSET_#_HERE num_digits = NUM_#s_AFTER_OFFSET_TO_READ data = "" file = io.open(filename_here, "r") if file then file:seek("set", offset) data = file:read(num_digits) file:close() end screen:print(0,0,data,Color.new(255,255,255))
Say yo uhave the VALUE '31010' at offset 1224 in a file called SG57.reg... you want toretrieve the value:Code:data = "" file = io.open("SG57.reg", "r") if file then file:seek("set", 1124) data = file:read(5) file:close() end screen:print(0,0,data,Color.new(255,255,255))
See if something like that works...Code:data = 0 file = io.open("SG57.reg", "r") if file then file:seek("set", 1124) data = file:read("*n",5) file:close() end screen:print(0,0,data,Color.new(255,255,255))
GOOD reference:
Code:file:read (format1, ...) Reads the file file, according to the given formats, which specify what to read. For each format, the function returns a string (or a number) with the characters read, or nil if it cannot read data with the specified format. When called without formats, it uses a default format that reads the entire next line (see below). The available formats are * "*n" reads a number; this is the only format that returns a number instead of a string. * "*a" reads the whole file, starting at the current position. On end of file, it returns the empty string. * "*l" reads the next line (skipping the end of line), returning nil on end of file. This is the default format. * number reads a string with up to this number of characters, returning nil on end of file. If number is zero, it reads nothing and returns an empty string, or nil on end of file. file:seek ([whence] [, offset]) Sets and gets the file position, measured from the beginning of the file, to the position given by offset plus a base specified by the string whence, as follows: * "set" --- base is position 0 (beginning of the file); * "cur" --- base is current position; * "end" --- base is end of file; In case of success, function seek returns the final file position, measured in bytes from the beginning of the file. If this function fails, it returns nil, plus a string describing the error. The default value for whence is "cur", and for offset is 0. Therefore, the call file:seek() returns the current file position, without changing it; the call file:seek("set") sets the position to the beginning of the file (and returns 0); and the call file:seek("end") sets the position to the end of the file, and returns its size.Geändert von SG57 (01-11-2007 um 05:36 PM Uhr) Grund: Automerged Doublepost

...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-12-2007, 08:52 AM #4995QJ Gamer Silver
- Registriert seit
- Aug 2006
- Ort
- The Matrix
- Beiträge
- 1.090
- Points
- 8.002
- Level
- 60
- Downloads
- 0
- Uploads
- 0
look at the top of the page (my post with quote)
Zitat von SG57
http://i28.tinypic.com/1znoljt.png
lolololololol - Reach 100,000 Gamerscore
-
01-13-2007, 03:03 AM #4996QJ Gamer Bronze
- Registriert seit
- Sep 2006
- Ort
- Denmark
- Beiträge
- 664
- Points
- 9.316
- Level
- 64
- Downloads
- 0
- Uploads
- 0
Hi all Lua Coders!
I'm currently working on a kind of browser system... im not so good at explaining, its kinda like PSPWindows.
But now i need, when my cursor is "over" a button, and i press X, then the button will blit itself into a "pressed button sprite" and it will blit a new image over itself, just like the start menu in windows.
Don't say the work "Collosion" to me, because i simply can't get that to work in any of my creations.My PSP Projects:
___________________
None.
-
01-13-2007, 03:14 AM #4997QJ 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
hehe "Collosion"..any way, do you know the "button's" X and Y value? if so, just make an if statement like....
it go like that, but really.. "collosion" would be pretty use fill there, instead of using the big IF statement.Code:if (insert Cursor X value here) >= (insert Button x value) and (Cursor Y value) and (Cursor X) <= (edge of the Button's X value) and (Cursor Y) <= (edge of Button's Y value) then blablabla if statement stuff bla blaOMGLOL11!!1! end
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-13-2007, 03:21 AM #4998QJ Gamer Bronze
- Registriert seit
- Sep 2006
- Ort
- Denmark
- Beiträge
- 664
- Points
- 9.316
- Level
- 64
- Downloads
- 0
- Uploads
- 0
That might help, i'll just post here where i need it:
Cursor = { x = 230, y = 140 }
while true do
pad = Controls.read()
screen:clear()
screen:blit(0, 0, background, false)
screen:blit(Cursor.x, Cursor.y, Cursor1, true)
screen:blit(0, 246, menu, false)
screen.flip()
if pad:left() then
Cursor.x = Cursor.x -2
end
if pad:right() then
Cursor.x = Cursor.x +2
end
if pad:up() then
Cursor.y = Cursor.y -2
end
if pad:down() then
Cursor.y = Cursor.y +2
end
(Then here goes Blacksharks code, like: if pad:cross() and (All those variables) then blablabla blitting images,
end)
if pad:start() then
break
end
endMy PSP Projects:
___________________
None.
-
01-13-2007, 03:21 AM #4999QJ Gamer Bronze
- Registriert seit
- Sep 2006
- Ort
- Denmark
- Beiträge
- 664
- Points
- 9.316
- Level
- 64
- Downloads
- 0
- Uploads
- 0
That might help, i'll just post here where i need it:
EDIT: Dammit, double post. Delete this post please, mods.Cursor = { x = 230, y = 140 }
while true do
pad = Controls.read()
screen:clear()
screen:blit(0, 0, background, false)
screen:blit(Cursor.x, Cursor.y, Cursor1, true)
screen:blit(0, 246, menu, false)
screen.flip()
if pad:left() then
Cursor.x = Cursor.x -2
end
if pad:right() then
Cursor.x = Cursor.x +2
end
if pad:up() then
Cursor.y = Cursor.y -2
end
if pad:down() then
Cursor.y = Cursor.y +2
end
(Then here goes Blacksharks code, like: if pad:cross() and (All those variables) then blablabla blitting images,
end)
if pad:start() then
break
end
endMy PSP Projects:
___________________
None.
-
01-13-2007, 03:43 AM #5000QJ 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
Alrighty, try this..
But make sure to get the X and Y value of the far Right of the button image and theCode:while true do pad = Controls.read() screen:clear() screen:blit(0, 0, background, false) screen:blit(Cursor.x, Cursor.y, Cursor1, true) screen:blit(0, 246, menu, false) screen.flip() if pad:left() then Cursor.x = Cursor.x -2 end if pad:right() then Cursor.x = Cursor.x +2 end if pad:up() then Cursor.y = Cursor.y -2 end if pad:down() then Cursor.y = Cursor.y +2 end if pad:cross() and Cursor.x >= Button.x and Cursor.y >= Button.y and Cursor.x <= (x value of the Right side of the button) and Cursor.y <= (bottom of Button's Y value) then do if statement stuff here blit an image or 2 crazyomglol getdrunk end if pad:start() then break end
Bottom of the Image, and replace the parenthesis with them. if you have any troubles then PM me with like the images or something...but give that a try first!
now, theres a much more efficient way of doing this but that involves "collosion" and functions.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-13-2007, 03:57 AM #5001Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
That looks like collision to me. Anyways
Zitat von BlackShark
Collision check and if pad:cross() then
sprite = the other sprite you want
screen:blit(x,y,bla)
and all the other stuff you want to happen
end
But if you can get collision that well go to evilmana they explain it pretty good.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-13-2007, 04:07 AM #5002QJ 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
ya, evilmana is great!
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-13-2007, 07:44 AM #5003QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
pls how do i make something go up together wit timer?
i mean:
if currentTime > 1000 then
screen:print( 10, 10, "1%", blue)
end
if curretTime > 2000 then
screen:print(10 ,10, "2%", blue)
end
the problem is %s are overriding and its unreadable...[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]
-
01-13-2007, 09:40 AM #5004Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von myschoo
that will show the number of seconds.Code:timer = Timer.new() while true do screen:print(10,10, math.floor(timer:time()/1000), blue) screen.waitVblankStart() screen:flip() end
--------------------------------------------------------------------------------------
-
01-13-2007, 10:03 AM #5005QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
thx dude... :)
edit. ok another question... how do i do it to prin only seconds? not like 14.698 sec.... :/Geändert von myschoo (01-13-2007 um 10:20 AM Uhr)
[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]
-
01-13-2007, 11:03 AM #5006QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
?
Zitat von myschoo
that does print only seconds...[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-13-2007, 11:17 AM #5007QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
yeh but somehow it always gave me error with grims methos so i just used
timeinSecs = timer:time() / 1000
print:screen(x,x, timeinSecs .. "seconds", blue)
but now i see 14.658 secs[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]
-
01-13-2007, 11:31 AM #5008QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Change timer:time() / 1000
to
math.floor(timer:time()/1000)
-
01-13-2007, 11:34 AM #5009QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Use the math.floor function which rounds down.
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
01-13-2007, 11:34 AM #5010QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
oh thx i will try this
btw. why did u change name from penguin to pinguin? o_O
yep, works perfect, thanks guys :)[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]


LinkBack URL
About LinkBacks
Mit Zitat antworten

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