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; bronxbomber, for your code, would you want this at the beginning: Code: while true do screen:clear() screen:blit(0, 0, menu) screen.flip() ...
-
05-28-2006, 11:34 AM #2521
bronxbomber, for your code, would you want this at the beginning:
So that when you press x or 'c' the menu will be cleared, and go on to the rest of the code?Code:while true do screen:clear() screen:blit(0, 0, menu) screen.flip() pad = Controls.read() if pad:cross() then screen:clear() break end end i=1 while i<=17 do screen:clear() counter:start() screen:blit(0, 0, background) .............
-
05-28-2006, 11:40 AM #2522
Also, can someone explain using the analog stick in games. I'm not even as experienced as GrimFace when it comes to that. Any help would be appreciated.
-
05-28-2006, 12:21 PM #2523
can someone explain how to draw a circle? i found this code, yet how do i make it work currectly? Can anyone explain this too?
Code:function drawCirc(where, x, y, radius, color) theta = 0 while theta<=360 do where:drawLine((math.sin( theta)*radius)+x, (math.cos(theta)*radius)+ y, (math.sin(theta+1)*radius )+x, (math.cos(theta+1)*radius )+y, color) theta = theta+1 end end
-
05-28-2006, 02:52 PM #2524
Say you want to draw a red circle on the screen at x=120 and y=100 with a radius of 20.
Zitat von emericaska8r
You would use: drawCirc(screen, 120, 100, 20, red)LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
05-28-2006, 02:57 PM #2525
Nevermind what he said. People are to lazy to try stuff out for them selfs.
Zitat von ShockD
I used a 1000x1000 JPG so not a PNG. And my image was about 58Kb. You have to make sure it isn't too big. Im not sure where the limit is, so just keep it as low as possible. I didn't do anything special other then that. I just blit the part that is supposed to be seen on the screen.
BTW Shine himself said it was a bug, so people are right about what it should've been. You probably read that aswell at ps2dev.
Oh and Im using LUAplayer 0.16LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
05-28-2006, 06:55 PM #2526Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Altair
are you serious?? it doesnt work for me. i DID try it out. both png and jpg, and my images size was 600x700 (it was a map). on luaplayer .16, it says error loading image. sry, i guess i kinda did give the impression that i hadnt tried it out.--------------------------------------------------------------------------------------
-
05-28-2006, 06:58 PM #2527sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
thanks
Zitat von emericaska8r
-
05-28-2006, 08:22 PM #2528
no problem.
-
05-29-2006, 06:14 AM #2529
Okay I get it now. Thanks
Zitat von Altair
-
05-29-2006, 06:29 AM #2530
Can anyone tell me whats wrong? In my game I have
damage = math.random(0,6)
this works fine, but everytime I play the numbers are always the same. Example: I play once, and the damages are 5 then 1 then 6. Then I play later, the damges are still 5 then 1 then 6.
-
05-29-2006, 06:49 AM #2531Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von emericaska8r
1. you dont need the "0" in the parenthesis. just put:
2. put this:Code:damage = math.random(6)
at the VERY top of you code. it will give you different numbers now.Code:math.randomseed(os.time())
--------------------------------------------------------------------------------------
-
05-29-2006, 09:23 AM #2532QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
I had the same exact problem, emericaska8r.
Doing what Grimfate126 said (put: -math.randomseed(os:time() )- ) will fix that. I still dont know how it works though...but it does.[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-29-2006, 10:06 AM #2533
Yes im serious. Maybe your file was too big. Like I said, mine was pretty small. Its because its just repeating itself. So yeah i could just make it blit tiles, but when i started, this was the easiest and I just kept using it. But it is possible, my first release of REDaLUA can proof it.
Zitat von Grimfate126
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
05-29-2006, 10:19 AM #2534QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
Does anyone know of any strategy (doesnt necessarily have to be Advance Wars.) game? I something to give me a nudge forward in the game I'm making.
Geändert von EminentJonFrost (05-30-2006 um 06:27 AM Uhr)
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-29-2006, 12:42 PM #2535
THat worked;, thanks GrimFate.
-
05-29-2006, 01:01 PM #2536words 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
think about it... a tree grows from a seed no? So your random numbers shall grow from a seed too... If you dont put a puesdo seed in there then youll keep getting the same numbers since the seed is the same... but with this, your setting the seed to be the PSPs internal time/clock which is always changing, thus giving you a random number.
Zitat von EminentJonFrost

...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
-
05-30-2006, 06:26 AM #2537QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
oohhh.
Zitat von SG57
now I feel stupid. lol
thanks for the good explanation, SG57.[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-30-2006, 09:50 AM #2538Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
can someone PLEASE comipile a luaplayer script for me?? for some reason, it only works on luaplayer .17 dk2. PM me if you want to try compiling it. i cant do it, cause my comp cant handle cygwin, and im leaving for a month on vacation in about an hour.
--------------------------------------------------------------------------------------
-
05-31-2006, 02:09 PM #2539QJ Gamer Gold
- Registriert seit
- Mar 2006
- Ort
- LOLWUT
- Beiträge
- 2.625
- Points
- 18.627
- Level
- 86
- Downloads
- 0
- Uploads
- 0
How do you make text stay there if you press X, and you would need to hold it for teh text to stay there. I want it so the text appears and stays when I press X. I tried:
I tried screen.flip OR screen.waitVblankStart(), neither worked. HelpCode:if pad:cross() then screen:print(10,10,"TEST TEST TEST", red) screen.flip() --I also tried screen.waitVblankStart() end

Thank you :icon_smil :icon_smil :icon_smil :icon_smil :icon_smil :icon_smil
--PSPduh
-
05-31-2006, 02:35 PM #2540SHOOP DA WHOOP

- Registriert seit
- Aug 2005
- Ort
- Wii forums
- Beiträge
- 7.407
- Points
- 12.310
- Level
- 72
- Downloads
- 0
- Uploads
- 0
you have to make it into a looping thing
(dont ask me about it though, i only program a little bit)
but here is the problem, your program runs, and doesnt check again, you have to get it to run and check
code: (im not sure if this is right)
while 1
if pad:cross() then
screen
rint(10,10,"TEST TEST TEST", red)
screen.flip()
end
-
05-31-2006, 03:01 PM #2541words 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
Close but no cigar yet...
Zitat von Floppydrive
Give that a whirl...Code:while true do pad = Controls.read() if pad:cross() then screen:print(10,10,"TEST TEST TEST", Color.new(255,0,0)) screen.waitVblankStart() screen.flip() end

...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
-
05-31-2006, 03:23 PM #2542QJ Gamer Gold
- Registriert seit
- Mar 2006
- Ort
- LOLWUT
- Beiträge
- 2.625
- Points
- 18.627
- Level
- 86
- Downloads
- 0
- Uploads
- 0
If I do what you said SG57, with the screen.waitVblankStart() and screen.flip() under the pad:cross(), it flickers when I hold X, and doesn't stay there when I press it.
-
05-31-2006, 03:25 PM #2543Quality Haxing Since 1991
- Registriert seit
- Oct 2005
- Ort
- Pennsylvania, USA Fi
- Beiträge
- 6.206
- Points
- 29.255
- Level
- 99
- Downloads
- 0
- Uploads
- 0
Then you probably have a screen.flip() somewhere in your code (probably near the end) and it's reflipping it. Try taking out the screen.flip() in SG57's code and see what happens.
Zitat von PSPduh
Zitat von Noriko
-
05-31-2006, 03:32 PM #2544QJ Gamer Gold
- Registriert seit
- Mar 2006
- Ort
- LOLWUT
- Beiträge
- 2.625
- Points
- 18.627
- Level
- 86
- Downloads
- 0
- Uploads
- 0
If i try the above code then it stays there when I HOLD X, and just appears then disappears if i press it. :Argh:Code:black = Color.new(0, 0, 0) white = Color.new(255, 255, 255) grey = Color.new(127,127,127) red = Color.new(255, 0, 0) green = Color.new(0, 255, 0) blue = Color.new(0, 0, 255) yellow = Color.new(255,255,0) purple = Color.new(120,0,120) pink = Color.new(255,0,255) orange = Color.new(255,110,0) ms = 0 x = 0 while true do screen:clear(black) pad = Controls.read() if pad:up() then ms = ms - 1 screen.waitVblankStart(4) end if pad:down() then ms = ms + 1 screen.waitVblankStart(4) end if pad:cross() then screen:print(10,10,"DUHDUHDUH", white) screen.waitVblankStart() end screen.waitVblankStart() screen.flip() end
:Argh:
:Argh:
:Argh:
-
05-31-2006, 03:36 PM #2545QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
that what you're looking for?Code:if pad:cross() then if duh == false then duh = true elseif duh == true then duh = false end end if duh == true then screen:print(10,10,"DUHDUHDUH", white) end
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-31-2006, 04:01 PM #2546QJ Gamer Gold
- Registriert seit
- Mar 2006
- Ort
- LOLWUT
- Beiträge
- 2.625
- Points
- 18.627
- Level
- 86
- Downloads
- 0
- Uploads
- 0
YEs that what I was looking for. Thanks. :):):):):):):):):):):):): ):):):):):):):):):)
Zitat von EminentJonFrost
-
05-31-2006, 05:41 PM #2547is an idiot
- Registriert seit
- May 2006
- Beiträge
- 354
- Points
- 7.262
- Level
- 56
- Downloads
- 0
- Uploads
- 0
im trying to get a wav to play with my menu and put it as a varible like all my other sounds and my other sounds work fine but this wav file wont work when i try to load my game on the windows LUA Player the dos box sais error loading sound and crashes so why is it having an error with this wav file but none of my other wav files? is it because the wav it too big of a size or what? the one im trying to play now is 30mb
-
05-31-2006, 06:36 PM #2548Quality Haxing Since 1991
- Registriert seit
- Oct 2005
- Ort
- Pennsylvania, USA Fi
- Beiträge
- 6.206
- Points
- 29.255
- Level
- 99
- Downloads
- 0
- Uploads
- 0
www.evilmana.com/tutorials
Zitat von Goldrush
Zitat von Noriko
-
05-31-2006, 06:43 PM #2549QJ Gamer Bronze
- Registriert seit
- Aug 2005
- Ort
- Plainfield, IL USA
- Beiträge
- 18
- Points
- 5.744
- Level
- 48
- Downloads
- 0
- Uploads
- 0
Okay... I'm a little confused right now (I'm about to fall asleep on my keyboard). Well anyway, I have created an empty image that is 480x272. I want to store my two background images in there so it only blits what is shown on screen. Can anybody show me how to do this? I think I would get it if I had a good night's sleep.
Thanks,
ShockD
-
05-31-2006, 09:20 PM #2550QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- This Forum
- Beiträge
- 1.825
- Points
- 15.884
- Level
- 81
- Downloads
- 0
- Uploads
- 0
Is there any way to make an action ocur only if a certian two buttons are pressed at the same time? Thank you for your time :icon_smil
Geändert von Ralan (05-31-2006 um 09:24 PM Uhr)
Taking things too far one step at a time


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