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; yea i know...*sighs* and i already made lots of changes to the code to make it smaller, but there hasnt ...
-
01-03-2007, 05:55 PM #4921QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
yea i know...*sighs* and i already made lots of changes to the code to make it smaller, but there hasnt been any actual speed changes. it sucks going back to look over what you did to see whats wrong, cause while making it you think itll all work fine, so how is it youll find whats wrong? you know? thats the point where i'm at. everything works, just not as fast as i'd hoped. not without the cpu getting a little juice.
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-03-2007, 06:00 PM #4922Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von EminentJonFrost
if you trust me enough, PM me with your code. there is simply no way a lua game should go below 50 FPS. you can use the cpu boost as well, but it would also be good if you could improve your code a bit too.--------------------------------------------------------------------------------------
-
01-03-2007, 06:02 PM #4923QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Yea if youd like Ill help you look over your code and if youve got an IM ill show you things to remember to make your code more efficient.
-
01-04-2007, 06:49 PM #4924
is there any way on of you two could do the same for me? I am coding a Super Mario Bros. game (it still isn't done and has bugs of course), and it seems to run okay on the computer, but on my PSP parts are really slow.
i really need to know more efficient ways of doing things becuase i can always seem to be able to make a program do something, yet it usually isn't the best way to do it.
any help would be greatly appreciated
-
01-04-2007, 08:07 PM #4925QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Sure, if you've got MSN or AIM add me and send me an IM and Ill be glad to help you out.
-
01-07-2007, 06:17 AM #4926QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- c:\Program Files\World of Warcraft\WoW.exe
- Beiträge
- 98
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Heres the download to the game i was working on: http://www.megaupload.com/?d=O8IQGJHF
its not that great...
It's my first lua game though.
-
01-08-2007, 12:11 AM #4927
I was wondering how to set up some code to kill an enemy when you shoot them or something, example
Code:function collisionCheckbullets(object) if (bullet.x + bulletWidth > object.x) and (bullet.x < object.x + object.width) and (bullet.y + bulletHeight > object.y) and (bullet.y < object.y + object.height) then *Insert Make Enemy Dissapear/Die Script Here* end end
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-08-2007, 06:04 AM #4928QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Well, add a variable called alive to your enemy table and set it to true.
enemy = {alive = true, x = blah, y = blah, img = blah, blah, blah}
And then only do stuff related to the enemy when alive is true.
if enemy.alive then
--AI related stuff for enemy
screen:blit(enemy.x,enemy .y,enemy.img)
end
And then make it so that enemy.alive becomes false when he is shot:
if collision(enemy,bullet) then enemy.alive = false end
-
01-08-2007, 02:42 PM #4929Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Why is this unstickied. And why is no one posting here anymore? tisk tisk. Ok ill spark it up with a question that doesnt really need to be answered now but I have to ask it sometime.
How would I make it check for text files? If if one is not found then print an error? I could look this up but I know someone here has the answer on the tip of thier tongue so you can save me some time lol.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-08-2007, 03:01 PM #4930QJ 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
good idea, I wouldn't mind being able to do that aswell!
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-08-2007, 03:06 PM #4931
Thanks alot
Zitat von TacticalPinguin
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-08-2007, 03:43 PM #4932QJ 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
any body have any idea how to do this?
Zitat von GuitarGod1134
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-08-2007, 03:53 PM #4933lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Sticked. :)
-
01-08-2007, 04:00 PM #4934Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Good job pspgamer81
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-08-2007, 04:41 PM #4935QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Checking for a text file:
if io.open("nameoffile.txt", "r") then
--File exists
else
--File doesn't exist
end
-
01-08-2007, 05:12 PM #4936words 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
Correction, checking for ANY file... Just not a directory.

...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-08-2007, 05:21 PM #4937QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
But if you're checking for a non text file then you have to change its extension.
But yes that can be used for checking for any file.
-
01-08-2007, 06:18 PM #4938
Hmm, Does anyone know whats wrong with my game,
It's very...basic so far but it is so sluggish! I even put in an FPS counter and it just shows 'NaN' and every now and then for a split second 1000fps o_O
It runs fine on the pc so I'm not sure whats wrong =\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-08-2007, 06:27 PM #4939Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Dark_Merlin
post your code. 1000 means your FPS counter is wrong.the FPS shouldnt go over 60, because of the screen.waitVblankStart() function, which limits it to 60.--------------------------------------------------------------------------------------
-
01-08-2007, 06:31 PM #4940
EDIT: New code with the Animation Lib FPS counter... now displaying just 0 EDIT2: Tabbed my code to make it easier to understand
Spoiler for Code:Geändert von Dark_Merlin (01-09-2007 um 01:54 PM Uhr)
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-08-2007, 07:31 PM #4941QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
How do I keep an image from disapearing when I release the button the blitted it to the screen?
-
01-08-2007, 07:41 PM #4942
Here you go
Code:image = Image.load("image") while true do pad = Controls.read() oldpad = pad if pad:cross() or oldpad:cross() then screen:blit(0,0, image) end screen.waitVblankStart() screen.flip() endGeändert von Dark_Merlin (01-08-2007 um 08:16 PM Uhr)
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-08-2007, 07:52 PM #4943QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
Now it doesn't load the script at all. Can you explain to me the "end" after the blitting of the image, and the oldpad stuff?
-
01-08-2007, 08:01 PM #4944QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Umm, 1. That's only going to blit the image for 1 frame.
Zitat von Dark_Merlin
2. You messed up oldpad very badly.
Anyways something like this:
oldpad = Controls.read()
while true do
pad = Controls.read()
if viewingimage then screen:blit(0,0,image) end
if pad:cross() and not oldpad:cross() and not viewingimage then viewingimage = true end
if pad:cross() and not oldpad:cross() and viewingimage then viewingimage = false end
screen.waitVblankStart()
screen.flip()
oldpad = pad
end
Thatll make x toggle between showing the image and not showing it.
-
01-08-2007, 08:06 PM #4945
Ok with the fps is wrong thing, i replaced that fps counter with the one out of alatnet's Animated Sprite Lib and now it just shows up as 0 on the comp, im going to test it on the psp now...
EDIT: Ok the psp shows the same thing.
and what I posted for him was a full program, sorry
and yeah I did oldpad wrong, sorry
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-08-2007, 08:19 PM #4946QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
So confuzed.
index.lua
menu.luaCode:white = Color.new(255,255,255) menustatus = 1 menu = Image.load("images/menu.png") cursor = Image.load("images/cursor.png") multiplayer = Image.load("images/multiplayer.png") singleplayer = Image.load("images/singleplayer.png") singleplayer2 = Image.load("images/singleplayer2.png") oldpad = Controls.read() while true do pad = Controls.read() dofile("menu.lua") screen.waitVblankStart() screen.flip() oldpad = pad end
singleplayer.luaCode:screen:clear(white) screen:blit(0,0,menu) if menustatus == 1 then screen:blit(280,172,cursor) end if menustatus == 2 then screen:blit(280,196,cursor) end if pad:down() and oldpad:down() ~= pad:down() then menustatus = menustatus + 1 end if pad:up() and oldpad:up() ~= pad:up() then menustatus = menustatus - 1 end if menustatus == 0 then menustatus = 1 end if menustatus == 3 then menustatus = 2 end if pad:circle() and menustatus == 1 then dofile("singleplayer.lua") end if pad:circle() and menustatus == 2 then dofile("multiplayer.lua") end
Maybe that will help you determine why when I load an image it won't loop.Code:screen:clear(white) screen:blit(0,0,singleplayer) if pad:r() and pad:l() and pad:circle() then screen:clear(white) screen:blit(0,0,singleplayer2) menustatus = menustatus - 1
-
01-08-2007, 08:35 PM #4947
Are you trying to make it so the l + r + circle blit and keep the singleplayer2?
Wait are you saying your menu images arent staying blitted?Geändert von Dark_Merlin (01-08-2007 um 08:47 PM Uhr)
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-08-2007, 08:45 PM #4948Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Cheez Pirate
ok, im not even gonna TRY to read that. you need to start spacing and indenting. it will make your problems much easier to identify and solve.--------------------------------------------------------------------------------------
-
01-08-2007, 08:54 PM #4949
I think he needs to put in some loops in the other files right?
From what i see he only has one loop in the index.lua and none in the others, that would be where his only blitting for one frame problems are coming from right?
If im wrong sorry, I havnt worked with calling other files of your code in before.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-08-2007, 10:50 PM #4950QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
My main menu image ("menu") stays blitted but the other 2 only last until you let go of the button. and l + r + o are supposed to load the next singleplayer menu. I'll true putting loops in other files though.


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