Zeige Ergebnis 8.761 bis 8.790 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; Thanks man! How could i have forgotten this :Argh::Argh:...
-
06-20-2008, 10:56 PM #8761
Thanks man! How could i have forgotten this :Argh::Argh:
-
07-01-2008, 09:38 PM #8762Raining
- Registriert seit
- Jun 2005
- Ort
- In The Fog...
- Beiträge
- 545
- Points
- 7.355
- Level
- 57
- My Mood
-
- Downloads
- 0
- Uploads
- 0
I have a very simple question and hopefully it has a very simple answer: How do I know when music will stutter? Basically, I keep making things with music and sometimes the music works really well, like in a Pong game it runs super smoothly, but other times (mostly in menus) the music stutters and/or plays very slowly. I have made two different types of menus and both times this happens. One is where you press left and right and a different option will appear on screen and the other is the more standard one where all options are on screen and you just move a selector to the preferred choice. In both though, I always use something like
orCode:if pad:down () then selector.y = selector.y + 38 end
For some reason I think that is the problem but I am not an experience doer so I may be completely off. An small example of a menu with music playing would be nice otherwise I would jsut like to know how to fix my menus and programs in general so that the music doesn't stutter all the time.Code:selection = 0 function selector () if pad:left () and selection < 5 then selection = selection + 1 end
Thank you very much,
Daniel Chan
-
07-01-2008, 09:55 PM #8763QJ Gamer Silver

- Registriert seit
- Sep 2007
- Ort
- AUS
- Beiträge
- 284
- Points
- 12.501
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Hey Daniel Chan,
What you could do use the System.setcpuspeed(300) or use the System.autoCpu().
BTW what type of music, mp3 ogg aac??
HomemisterWyvern. That is all
-
07-02-2008, 04:47 AM #8764Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Or you could just find the y position you need instead of adding
e.g
then have a IF for selectedCode:if pad:down() then selected = selected + 1 end
This is a smother way then just add the play function for your musicCode:if selected == 1 then y = 36 end
-
07-02-2008, 04:47 AM #8765Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Or you could just find the y position you need instead of adding
e.g
then have a IF for selectedCode:if pad:down() then selected = selected + 1 end
This is a smother way then just add the play function for your musicCode:if selected == 1 then y = 36 end
-
07-02-2008, 08:59 AM #8766QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
The only reason music should be stuttering is due to the lack of resources. For some reason your "simple menu" is consuming a ton a CPU power, indicating there is probably something inherently wrong with your code/coding style/logic/understanding of your program's flow. Post your entire menu code.
P.S. @dan369: That would result in a huge amount of needless if statements, which is bad coding practise. Use tables:A better way would be to create a neat little menu class. OO FTW.Code:selectionsY = {36,0,0,0,} --etc y = selectionsY[selected]
-
07-02-2008, 01:11 PM #8767Raining
- Registriert seit
- Jun 2005
- Ort
- In The Fog...
- Beiträge
- 545
- Points
- 7.355
- Level
- 57
- My Mood
-
- Downloads
- 0
- Uploads
- 0
My music file type is .xm mostly(I took the EvilMana.com Tutorials seriously when they said LuaPlayer can't play MP3's so can it?) and maybe a few .mod files.
Okay, here is my whole menu code. I removed the music because it got very annoying when I tried playing it:
What is funny is that I left in the Music.stop () commands even though I already took out the music. Anything wrong with this? Originally I did it the second way that dan369 suggested as per the menu example at Evilmana.com's Music & Sound tutorial but then I reverted back to the 'adding' method.Code:white = Color.new (255,255,255) black = Color.new (0,0,0) lime = Color.new (153,204,0) plum = Color.new (153,51,102) red = Color.new (255,0,0) blue = Color.new (0,0,255) orange = Color.new (255,102,0) fontponglogo = Font.load ("Fonts/billo.ttf") fonttagline = Font.load ("Fonts/BRADHITC.ttf") fontpong = Font.load ("Fonts/billo.ttf") fontluvtakes2 = Font.load ("Fonts/Complete in Him.ttf") fontfrantic = Font.load ("Fonts/V5PRD.ttf") fontmanic = Font.load ("Fonts/OCRAEXT.ttf") fontdinosaur = Font.load ("Fonts/mizufalp.ttf") fontponglogo:setPixelSizes (48,48) fonttagline:setPixelSizes (20,20) fontpong:setPixelSizes (0,36) fontluvtakes2:setPixelSizes (0,36) fontfrantic:setPixelSizes (0,36) fontmanic:setPixelSizes (0,36) fontdinosaur:setPixelSizes (0,30) introbar = Image.createEmpty (480,55) introbar:clear (plum) selector = {y = 63,img = Image.createEmpty (480,38)} selector.img:clear (plum) background = Image.createEmpty (480,272) background:clear (white) number = 0 gamestate = "intro" oldpad = Controls.read () function selection () if pad:cross () and selector.y == 63 then dofile "pong.lua" Music.stop () end if pad:cross () and selector.y == 139 then dofile "luvtakes2.lua" Music.stop () end if pad:cross () and selector.y == 177 then dofile "frantic.lua" Music.stop () end if pad:cross () and selector.y == 215 then dofile "manic.lua" Music.stop () end if pad:cross () and selector.y == 253 then dofile "pongdinosaur.lua" Music.stop () end if pad:down () and selector.y < 215 then selector.y = selector.y + 38 end if pad:up () and selector.y > 63 then selector.y = selector.y - 38 end end function drawSelector () screen:blit (0,selector.y,selector.img) end function drawIntro () screen:blit (0,0,background) screen:blit (0,180,introbar) screen:fontPrint (fontponglogo,100,120,"pong.MODERN",black) screen:fontPrint (fonttagline,8,150,"a step up from pong.CAVEMAN and pong.DINOSAUR",lime) screen:fontPrint (fontmanic,120,220,"Press START",white) if pad:start () then gamestate = "menu" end end function drawMenu () screen:fontPrint (fontpong,190,90,"pong?",lime) screen:fontPrint (fontluvtakes2,165,130,"l*v takes 2",red) screen:fontPrint (fontfrantic,160,170,"frantic",blue) screen:fontPrint (fontmanic,180,210,"manic",orange) screen:fontPrint (fontdinosaur,110,240,"pong.DINOSAUR",black) end while true do pad = Controls.read () screen:clear () if gamestate == "intro" then drawIntro () end if gamestate == "menu" then selection () screen:blit (0,0,background) drawSelector () drawMenu () end screen.waitVblankStart () screen.flip () if pad:select () then break end oldpad = pad end
-
07-02-2008, 04:42 PM #8768
- Registriert seit
- Feb 2008
- Beiträge
- 5
- Points
- 2.680
- Level
- 31
- Downloads
- 0
- Uploads
- 0
Hey, guys. I hope this thread is still being read, because I'm completely stumped on what the issue might be with porting my game to 3.XX using LuaPlayerHM7.
I've put in a good 6 hours at least trying to figure this out. Honestly, it doesn't make any sense.
For some reason, my line of code for loading WAV sound effects work perfectly fine in 150 but not on 3.XX.
Here it is:
Whenever it gets to that line, it gives me "error loading sound" and halts the program. So I downloaded a game I knew worked in 3.XX to check out what it did for sounds...Code:Move = Sound.load("Sounds/Move.wav", false)
This is what it does:
Why would this code work and not mine? I've tried taking out the ", false" parameter at the end, didn't work. I've tried using lowercase for the variable, caps for the files name and changing the directory... Nothing works. I've looked at his WAV sample, and it's the same exact bitrate and format as mine (352KB/s 22050Hz Mono).Code:kill5 = Sound.load("Data/Audio/DEDMAN5.WAV")
I just don't get it. Everything else works fine. Images load and display, XM music plays, controls work fine.
If anyone knows what up, or if there's a different LuaPlayer/MOD that works on 3.XX, please let me know.
-
07-02-2008, 04:49 PM #8769NetGameOrb Maker

- Registriert seit
- Jan 2008
- Ort
- New York
- Beiträge
- 683
- Points
- 6.138
- Level
- 50
- My Mood
-
- Downloads
- 2
- Uploads
- 0
GameLive name changed to NetGameOrb, Project is now online in Beta stage. Everyone encourage to register so they get news about the project and ability to play the games with NetGameOrb Support online. More info on site.
Stats Blog:http://netgameorb.blogspot.com/
Website:http://www.netgameorb.com/
-
07-02-2008, 05:02 PM #8770
- Registriert seit
- Feb 2008
- Beiträge
- 5
- Points
- 2.680
- Level
- 31
- Downloads
- 0
- Uploads
- 0
The directory is fine. It's copied over from the Game150 version, which works perfectly... And the sound is only 7KB, so there's no problem there.
I set up a new project with nothing but loading the sound and pressing X to play it. There's no problem with memory (as it's the only thing being loaded), and there's no conflict with anything else going on (as it's the only thing being processed)... But still, it gives me the same error everytime.
-
07-02-2008, 05:15 PM #8771QJ Gamer Silver

- Registriert seit
- Sep 2007
- Ort
- AUS
- Beiträge
- 284
- Points
- 12.501
- Level
- 73
- Downloads
- 0
- Uploads
- 0
I have added new wav loading functions for the next release to Fix the issue. Also it will alow for better paning and volume management of the wav.
Regards
HomemisterWyvern. That is all
-
07-02-2008, 05:23 PM #8772
- Registriert seit
- Feb 2008
- Beiträge
- 5
- Points
- 2.680
- Level
- 31
- Downloads
- 0
- Uploads
- 0
Holy crap... Good to know it's not my fault. It's been eating at me all day, lol.
Are you able to tell me how soon it will be released? It's not a pressing issue, I can keep working on 150 until then. Just curious :P.
-
07-02-2008, 05:23 PM #8773
anyone know how to fill in a shape will color ...(not a rectangle) or shapes like triangles and stars.. but not just outlines filled in aswell? point me to a tutorial or show me please and thanks :P
-
07-02-2008, 05:35 PM #8774QJ Gamer Silver

- Registriert seit
- Sep 2007
- Ort
- AUS
- Beiträge
- 284
- Points
- 12.501
- Level
- 73
- Downloads
- 0
- Uploads
- 0
I should relese it with in the next week.
I have to finish some other things first.
Check the news on my site for what is already included in the next playerWyvern. That is all
-
07-02-2008, 11:22 PM #8775QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
The problem is that fontprints are ridiculously CPU-intensive (rendering a font every frame is not a good idea). Fontprint to images first, or use bitmap fonts.
Also, your code is not very good. Aside from the obvious lack of indenting (learn to indent, else you will never cope with more complex code) You do know you can have if-statements within if-statements right? (MUCH neater)
Also, Elseifs
e.g:
Also, use a selector value indicating which option is to be selected, and use a table like mentioned previously. You use too many magic numbers.Code:if pad:cross() then if selector.y == 63 then dofile("pong.lua") Music.stop () elseif selector.y == 139 then dofile("luvtakes2.lua") Music.stop () elseif selector.y == 177 then dofile("frantic.lua") Music.stop () elseif selector.y == 215 then dofile("manic.lua") Music.stop () elseif selector.y == 253 then dofile("pongdinosaur.lua") Music.stop () end end
-
07-03-2008, 01:15 PM #8776Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Could someone explain math.mod() and math.asin()
-
07-03-2008, 02:56 PM #8777Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
HELP!!!
is loadiing the background "background = image.load(*/background.png)" ?
and whatever text i print after that will go over the background right?
-
07-03-2008, 03:05 PM #8778Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
loading a image
after you've blitted the image print watever text u want :)Code:file = Image.load("lok.png") screen:blit(0,0,file)
-
07-03-2008, 03:45 PM #8779
-
07-03-2008, 04:05 PM #8780QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
asin: inverse sine (or arcsine) (sin ^ -1)
mod: returns modulus (remainder). Deprecated, so use the "modulo" operator instead: "%"
e.g: 20 % 3
= 2
more info:
http://www.lua.org/manual/5.1/manual.html#2.5.1
http://en.wikipedia.org/wiki/Modulo_operation
http://en.wikipedia.org/wiki/Inverse...etric_function
http://lua-users.org/wiki/MathLibraryTutorialGeändert von Nielkie (07-03-2008 um 04:15 PM Uhr)
-
07-03-2008, 04:14 PM #8781Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
okay thanks
after i loaded it how can i make it appear on the screen?
-
07-03-2008, 04:23 PM #8782Raining
- Registriert seit
- Jun 2005
- Ort
- In The Fog...
- Beiträge
- 545
- Points
- 7.355
- Level
- 57
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Thanks for the help! It isn't, though, that I don't know how to indent but I was never taught too. I have just been using Devsgen.com and Evilamana.com tutorials so far and I have yet to see any lessons on proper code organization. Also, that code was redone numerous times in order to figure out what was wrong so I am sorry for my lack of certain obvious things like using "elsifs"'s and such.
When you say fontprint to images first do you mean open up some sort of program like paint and write the font on there then save it? If so that would seem like a lot of work though.
-
07-03-2008, 04:25 PM #8783Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
oh NVM i found out how to get it to the screen...
but the problem is
once i do screen:clear() that means the background leaves for ever too!
how can i make the background stay no matter what?
-
07-03-2008, 04:40 PM #8784
-
07-03-2008, 04:57 PM #8785Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
yeah thanks
i found out its blit
but is there any way to keep the bg image even though i do
Code:screen:clear()
-
07-03-2008, 05:14 PM #8786
-
07-03-2008, 06:19 PM #8787Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
OH YEAH right... i missed the while true do...
thanks so much
btw to everyone...
is this a good idea?? (my very first homebrew EVER - no past coding experience)
a tax calculator
calculates tax on the go by inputting amount and setting % multiplied and finally adding both for final price
for "on the go" situations like the one i had today at Winners.
please dont steal my idea and make an app like this just because you are better than me in lua/c
i really wanna try this
and noone made one yet :)
-
07-03-2008, 06:24 PM #8788QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- U.S.
- Beiträge
- 405
- Points
- 7.014
- Level
- 55
- Downloads
- 0
- Uploads
- 0
-
07-03-2008, 06:48 PM #8789Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
cool thanks! :)
my first words of encouragement LOL
btw
im having some trouble at the very beginning..
impossible
but still
my error shows up (in luaplayer.exe for pc)Code:green = Color.new(0, 255, 0) white = Color.new(255, 255, 255) black = Color.new(0, 0, 0) background = Image.load("images/background.jpg") while true do screen:clear() screen:blit(0,0,background) screen.waitVblankStart() screen.flip() screen:print(144, 74, "Welcome to Tax Calculator", black) screen.flip() while true do screen.waitVblankStart() end
btw ive been always wondering whats eof?Code:error: script.lua:22: `end' expected (to close `while' at line 8) near `<eof>'
-
07-03-2008, 06:58 PM #8790QJ Gamer Blue
- Registriert seit
- Dec 2006
- Beiträge
- 251
- Points
- 4.872
- Level
- 44
- Downloads
- 0
- Uploads
- 0
Alright, so I'm just making a simple game in Lua but my PNG images don't display correctly. They are supposed to fill the screen, but they only fill a portion of it and they are all green, when in reality the image is mostly black and white.
Any help?
I'm not sure what I'm doing wrong as this is all the code I used for the image:
It's not just one image that's doing it either.Code:screen:blit(0,0,startImg) screen.flip()
I'm using the HM Mod. Could this be the problem? 3.90 M33


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