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 wicked_fable I don't think he wants to UN-compress he wants to compress the file. Yes I want to ...
-
09-04-2008, 12:41 PM #9391My Releases:
---------------------------------------------------
[URL="http://forums.qj.net/showthread.php?t=145654"]ROFLFlasher[/URL]
[URL="http://forums.qj.net/showthread.php?t=144892"]DTS MGS Edition[/URL]
[URL="http://forums.qj.net/showthread.php?t=143735"]Arkanoid Deluxe Beta[/URL]
[URL="http://forums.qj.net/showthread.php?p=2144700#post2144700"]SAVIOR![/URL]
-
09-04-2008, 03:19 PM #9392QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
1. Read this and listen to it. It's called indentation and it makes your code much easier to read.
2. Learn to use for loops, they'll cut lots of redundancy
3. Work through the logic of your code in your head and ask yourself why you're doing each step. If you don't know, either figure it out, or get rid of it until you do. If it makes more sense to do it a different way at seems like it would be faster, make it do it the faster way. It's called optimization.
4. Why do you need to run the CPU at 333mhz just for a SIMPLE mp3 player, especially when the ME is doing all the MP3 work?[size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]
-
09-05-2008, 05:51 PM #9393QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
09-05-2008, 05:54 PM #9394lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
-
09-05-2008, 05:58 PM #9395QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Geändert von Digikid13 (09-05-2008 um 06:08 PM Uhr)
AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13
-
09-05-2008, 06:14 PM #9396QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
1. Yes, you do need indentation. You're being ignorant if you think otherwise.
2. Close but that would make you draw 200 bars, i would do for a = 0, 100, 10 do or similar so it increments in 10 instead of 1
3. Don't shake your head at it, listen to it. It's how you get better, it's how you learn, it's how you stop needing to ask for help on trivial things like this.
4. What?[size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]
-
09-05-2008, 06:33 PM #9397QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
1. I use indentation in all of my work. I just didn't need it in the last one, because I used it.
2. That is what I wanted. It makes it look more uniform.
3. You sent me through a loop with all of that. I try to use some logic with what I do, but I can't if I don't know what I am doing.
4. In the VSH menu, you know where you select the CPU speed for the game, would it not be based off of that.
-=Double Post Merge =-
How can I record my game and turn it into my eboot pic.Geändert von Digikid13 (09-05-2008 um 06:34 PM Uhr) Grund: Automerged Doublepost
AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13
-
09-05-2008, 06:34 PM #9398lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
I think that only works for the ISOs and XMB speeds.
-
09-05-2008, 06:36 PM #9399QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
09-05-2008, 07:11 PM #9400QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
200 calls to drawRect will make it look more uniform but it'll also make it slow as all hell. And I didn't see complete proper indentation in your code
[size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]
-
09-05-2008, 08:02 PM #9401QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Well i didn't do the entire code, so i don't know if there is any. 333mhz =.= and it is not slow to me.
AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13
-
09-06-2008, 02:00 AM #9402Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
hey turtles where is the code not indented properly, unless your going to moan about the code inside the while true do loop?
As I said that code probably isn't any good, while I was coding it I came across problems (one being that mp3me.eos() returns a string not a boolean o_O), I was unsure if these were speed issues or with the code that is why there is lots more code than would be needed to accomplish this feature and the reason for the cpu being set to 333mhz.
All in all the code i posted was just a way to do what he wanted that worked, I did not say it was any good, in fact I said the complete opposite.------ 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).
-
09-06-2008, 02:25 AM #9403QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
I disagree, what you have described is premature optimisation. You should get it working, then get it working faster (not rip it out because it is slow) but only if it is seen as a performance bottleneck else leave it.
If you find that a chunk of code is getting unwieldy to work with to make constant changes or you are copying and pasting a similar line/block of code a couple of times, then consider refractoring the code to make it more maintainable and/or reusable.[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]
-
09-06-2008, 09:24 AM #9404
Spoiler for code:
(The code's a bit big so I wrapped it in spoiler tags)
So heres my code for tile engine I'm porting from QBASIC to Lua
for some reason the map shows up ( the part I want) however it's very choppy and when I come up to a wall it blits all over the screen. Is there anything wrong in the code or is it just my computer?
-
09-06-2008, 09:59 AM #9405QJ Gamer Bronze
- Registriert seit
- Mar 2007
- Beiträge
- 758
- Points
- 8.665
- Level
- 62
- Downloads
- 0
- Uploads
- 0
This isn't the Lua help thread, it's the C/C++ help thread. Post in the appropiate thread. :)
And have you tested it on your PSP?
Last thing, indent your code.
-
09-06-2008, 10:01 AM #9406No longer a community member.
- Registriert seit
- Jan 2006
- Beiträge
- 2
- Points
- 25.679
- Level
- 96
- Downloads
- 0
- Uploads
- 0
-
09-06-2008, 10:18 AM #9407QJ Gamer Bronze
- Registriert seit
- Mar 2007
- Beiträge
- 758
- Points
- 8.665
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Whoops.

Maybe I'm going blind...
-
09-06-2008, 01:30 PM #9408QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
09-06-2008, 07:06 PM #9409
lol THIS is the C/C++ help thread? Anyway no I havent tried it on my PSP and I did indent my code but the spoiler tags took it out I put them there so the post looked neat not this huge wall of code.
EDIT:
GOD I feel like an idiot I had to add the ShowMap function at the top of the loop now it works perfectly
Spoiler for code:
heres the working code if anyone watns it.Geändert von bnc9 (09-06-2008 um 07:46 PM Uhr)
-
09-06-2008, 08:43 PM #9410QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
[size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]
-
09-06-2008, 10:47 PM #9411
FINE if you don't mind seeing a wall of code here:
Code:red = Color.new(255,0,0) blue = Color.new(0,0,255) green = Color.new(0,255,0) playerImage = Image.createEmpty(16,16) ground = Image.createEmpty(16,16) -- ground tiles wall = Image.createEmpty(16,16) -- wall tiels playerImage:clear(red) ground:clear(green) wall:clear(blue) function CreateWorld() --Create a Table with Data on the world local buffer1 = {rows,cols,TopRow,TopCol,Action,Direc,PlayerY} -- {total rows,total columns, Top Row the is seen, Top Column that is seen,Check for actions in the loop,Chack for directions,Player's y(not necessary as of now} return buffer1 end function MAP() local buffer1 = {tile} local buffer2 = {} setmetatable(buffer2,buffer1) return buffer2 end North = 1 South = 2 -- Direction constants East = 3 West = 4 WorldData = CreateWorld() Map = MAP() worldMap = {} -- THE MAP worldMap[1] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1} worldMap[2] = {2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1} worldMap[4] = {2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1} worldMap[5] = {2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1} worldMap[6] = {2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1} worldMap[7] = {2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1} worldMap[8] = {2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1} worldMap[9] = {2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1,2,1} worldMap[10] ={2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1} function InitVars() -- Init of the variables on the first map blit WorldData.TopCol = 1 WorldData.TopRow = 5 end function MoveDown() WorldData.Direc = South WorldData.TopRow = WorldData.TopRow + 1 end function MoveLeft() WorldData.Direc = West WorldData.TopCol = WorldData.TopCol - 1 end function MoveRight() WorldData.Direc = East WorldData.TopCol = WorldData.TopCol + 1 end function MoveUp() WorldData.Direc = West WorldData.TopRow = WorldData.TopRow - 1 end function DrawTile(x,y,TileNumber) -- draw a specific tile if TileNumber == 1 then screen:blit(x,y,ground) end if TileNumber == 2 then screen:blit(x,y,wall) end end function ShowMap() --draw the entire map for i = 0,1 do for j = 0,4 do DrawTile(i*16,j*16,worldMap[i+WorldData.TopCol][j+WorldData.TopRow]) end end end InitVars() while true do screen:clear() pad = Controls.read() ShowMap() if pad:down() and oldpad:down() ~= pad:down()then MoveDown() WorldData.Action = true end if pad:right() and oldpad:right() ~= pad:right() then MoveRight() WorldData.Action = true end if pad:left() and oldpad:left() ~= pad:left() then MoveLeft() WorldData.Action = true end if pad:up() and oldpad:up() ~= pad:up() then MoveUp() WorldData.Action = true end screen:flip() screen.waitVblankStart() oldpad = pad end
-
09-07-2008, 03:44 PM #9412QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
You might want to add spacing too, I can't tell what goes together. Also, what is it that you want.
-=Double Post Merge =-
it only draws a corrner....Geändert von Digikid13 (09-07-2008 um 05:06 PM Uhr) Grund: Automerged Doublepost
AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13
-
09-08-2008, 03:59 AM #9413
About the corner:Well yea that's the point, I wanted to only see part of the map because say I made the map bigger I could place myself on one point that could by my start point and move my way through the level this is how 2d scrollers like zelda made their maps (of course their scrolling was way more advanced and looked much better than mine).
-
09-11-2008, 05:04 AM #9414Seven Year Vet. BOW DOWN.

- Registriert seit
- Dec 2005
- Ort
- Manchester, UK
- Beiträge
- 2.240
- Points
- 14.794
- Level
- 78
- My Mood
-
- Downloads
- 1
- Uploads
- 0
This is beggining to annoy me now. I'm trying to get a sound to play properly in a game that I'm currently developing, but it just won't work and I can't figure out why. I'm trying to get a sound to play continously as a laser if firing, without having it playing like 5 times at once, if that makes sense. I want it to loop continuously up until the point the laser stops firing. I'm not good at explaining things, so maybe this will help:
That's something I wrote in another file, just to see if I could get it to work elsewhere first, but it still gives me the same error, just saying 'Loop ingettable'. I don't see what I'm doing wrong. Oh, and if it helps at all, I'm using Luaplayer v0.16.Code:abc = Sound.load("a.wav", false) while true do if abc:playing() == false then abc:play() end end
Thanks in advance.
-
09-11-2008, 07:51 AM #9415QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
The wav file needs to be mono and at a specific bitrate IIRC.
[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]
-
09-12-2008, 05:53 AM #9416Seven Year Vet. BOW DOWN.

- Registriert seit
- Dec 2005
- Ort
- Manchester, UK
- Beiträge
- 2.240
- Points
- 14.794
- Level
- 78
- My Mood
-
- Downloads
- 1
- Uploads
- 0
I had the mono / stereo problem at first, because I created the wav file myself, but that was quickly resolved. Also, thanks for the advice, I hadn't thought of that; I do have other sound effects that have worked in other lua programs, so I'll go find out what bitrate they are. Thanks a lot.
EDIT:
It's still being weird. I've tried quite a lot of bitrates and none of them will work, it will load and play the sound but at the point where I check to see if the siound is already playing, I always get an error. Odd.Geändert von Freshmilk (09-12-2008 um 06:09 AM Uhr)
-
09-12-2008, 07:55 AM #9417Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
use a PCM unsigned 8 bit, mono .wav file, you can change the format of your sound files with goldwave audio player, if that is a bit too much hastle for you then just send me a link to the sound file and ill convert it for 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).
-
09-12-2008, 08:17 AM #9418QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
A sound object does not have the method "playing"
sound: play() returns a voice object, which you can then manipulate (e.g. stop, playing, etc)
so:
Next time, read the function documentationCode:sound = Sound.load(file) soundVoice = sound:play() ... if not soundVoice:playing() then soundVoice = sound:play() end
http://wiki.ps2dev.org/psp:lua_playe...ound_and_music
-
09-12-2008, 12:14 PM #9419QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
I had I sound problem too I tried to play a wav. file, for the sound of a ball bumping against the wall =, but the problem was that it played a sec. later.
Also, I had it in front of the calculation, would that matter.AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13
-
09-15-2008, 08:02 AM #9420Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Hi, haven't posted here in a while, i was wondering, how could someone code Layers in Lua? For images in Lua. E.g background layer, spirte layer etc.


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