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 superbatxs Sorry, i have to be honest. I wasn't thinking properly....just typing while i was doing my math ...
-
03-29-2007, 07:38 PM #6451Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
if you say so. But your excuse seems a little shabby. bah.
Zitat von superbatxs
--------------------------------------------------------------------------------------
-
03-29-2007, 09:13 PM #6452words 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
Uhm, i hope you realize you have like 5 indeitations for the if statement, than 2 for the code to execure, then 1 for hte end... That is quite random (to me) and will be unreadable in any semi-large project.
Zitat von Anti-QJ
Personally, my indentations are 2-5 spaces.
Code:int main() { for(;;) { if(condtion is true) { break; } } return 0; }
...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
-
03-30-2007, 06:04 AM #6453QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
Yea, the code that you just posted ( for(;;) { ) is exactly what i am using for the G-Pack's credit loading screens. It works very very well, and i greatly thank psp-programming for that. Lol, i didn't know they had that in lua because i never actually coded in lua well enough to use it.
Zitat von SG57
Calypso - Enjoy the excellent 2D space shooter:
http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195
"Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)
-
03-30-2007, 06:05 AM #6454
Hi... I am a noob at LUA and just beginning to learn it...
Could someone tell me how to make a program wait for a certain amount of time?
-
03-30-2007, 06:10 AM #6455QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
Either make your own timer or use this:
Zitat von blotus21
I put 60 there, which is a second. Every 60 is a second. For example, if i use 300 instead, it would be 5 seconds.Code:screen.waitVblankStart(60)
Use this to learn lua in an easy way:
http://www.psp-programming.com/tutor...a/lesson02.htmCalypso - Enjoy the excellent 2D space shooter:
http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195
"Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)
-
03-30-2007, 06:25 AM #6456
ah, thanks very much... I'll try to do it that way ^_^
-
03-30-2007, 07:05 AM #6457lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
To ME its real easy to read, When i have alot of lines of code, Its still easy for ME, I guess people just shave different preferences.
Zitat von SG57
-
03-30-2007, 07:52 AM #6458QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
That is definitely non-standard.Code:if x == 2 then blah end elseif x == 3 then blah end elseif x == 4 then blah end
This is more common place.Code:if x == 2 then blah elseif x == 3 then blah elseif x == 4 then blah end
http://astyle.sourceforge.net/[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]
-
03-30-2007, 02:04 PM #6459QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- U.S.
- Beiträge
- 405
- Points
- 7.014
- Level
- 55
- Downloads
- 0
- Uploads
- 0
How would I rotate an image? For example, to be able to turn an image (or twist, I guess) in order to shoot different things all around you? Thanks.
-
03-30-2007, 02:12 PM #6460Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
use the GU.
Zitat von andyauff
--------------------------------------------------------------------------------------
-
03-30-2007, 02:21 PM #6461QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- U.S.
- Beiträge
- 405
- Points
- 7.014
- Level
- 55
- Downloads
- 0
- Uploads
- 0
How would i do that? I thought it was for 3d. Sorry if I'm wrong, just trying to figure things out.
-
03-30-2007, 02:42 PM #6462Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
I thought it was a millasecond timer. and arent thier 100 milliseconds in a second?
Zitat von superbatxs
EDIT_____!!!!
NVM its vblanks and there are 60 vblanks in a second. so ur right.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!
-
03-30-2007, 03:26 PM #6463Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
everything software wise is based on the GU. (on the PSP) tactical penguin wrote a tutorial here:
Zitat von andyauff
http://forums.qj.net/f-psp-developme...ive-89527.html--------------------------------------------------------------------------------------
-
03-30-2007, 06:52 PM #6464
how do you add a thing so if you are at the main menu and you press credits it goes to credits what is the code for that and i would like it to be x that selects it
-
03-30-2007, 06:55 PM #6465
if pad:cross() then
btw, pspdude10594 = pspdude 10/5/94 = pspdude October 5th, 1994?牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
03-30-2007, 07:03 PM #6466
Haha.......lol. Youresam, you are my hero....:ROFL:
Zitat von youresam
-
03-30-2007, 07:11 PM #6467
sure whatever you want to think
Zitat von youresam
-
03-30-2007, 07:27 PM #6468
Uh, ok? Im assuming it was just random pounding on the keyboard. Nevermind then.
Zitat von pspdude10594
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
03-31-2007, 12:51 AM #6469
How come os.exit( ) freezes my PSP when I use it? I used the same method as the tutorial. It was something along the lines of this:
I'm looking to return to the XMB from an EBOOT compiled in Game Maker.
Code:if pressing X then do nothing elseif pressing O then os.exit( ) end
-
03-31-2007, 02:38 AM #6470
The command is slightly different in different versions of the player. Try using System.Quit() and see if that works
-
03-31-2007, 05:55 AM #6471QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
yeah System.Quit() works in Cools mod
[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]
-
03-31-2007, 06:58 AM #6472
- Registriert seit
- Dec 2006
- Beiträge
- 1
- Points
- 3.532
- Level
- 37
- Downloads
- 0
- Uploads
- 0
when I use this piece of code:
for line in songindex:lines() do
song[songlineread] = line
songlineread = songlineread + 1
end
It always adds a weird character (i'm assuming its a line end) to the end of each line, any way of removing it or stopping it from happening?
Thanks
-
03-31-2007, 02:50 PM #6473
Hey guys i am learning lua right now and i did some tutorials. Now i am trying to combine some to make a simple game like AOTM. Can you tell me why my guy won't shoot. It encounters an error everytime u try to shoot.
Code:green=Color.new(0,255,0) grass=Image.load("grass.png") player=Image.load("player.png") tree=Image.load("tree.png") bullet = Image.createEmpty(4,4) bullet:clear(green) screenwidth=480-player:width() screenheight=272-player:width() Player={} Player[1]={x=200, y=50} oldpad = Controls.read() currentBullet = 0 direction = "right" BulletInfo = {} for a = 1,800 do BulletInfo[a] = { pic = bullet , firing = false, direction = "right", x = Player[1].x + 32, y = Player[1].y + 16 } end function bulletSetup() if currentBullet < 800 then currentBullet = currentBullet + 1 else currentBullet = 1 end if direction == "left" then BulletInfo[currentBullet].x = Player[1].x BulletInfo[currentBullet].y = Player[1].y + 16 end if direction == "right" then BulletInfo[currentBullet].x = Player[1].x + 32 BulletInfo[currentBullet].y = Player[1].y + 16 end if direction == "up" then BulletInfo[currentBullet].x = Player[1].x + 16 BulletInfo[currentBullet].y = Player[1].y end if direction == "down" then BulletInfo[currentBullet].x = Player[1].x + 16 BulletInfo[currentBullet].y = Player[1].y + 32 end BulletInfo[currentBullet].direction = direction BulletInfo[currentBullet].firing = false end function bulletFire() for i = 1,800 do if BulletInfo[i].firing == true then screen:blit(BulletInfo[i].x,BulletInfo[i].y,BulletInfo[i].pic) end if BulletInfo[i].x < 0 or BulletInfo[i].x > 480 or BulletInfo[i].y < 0 or BulletInfo[i].y > 272 then BulletInfo[i].firing = false end end end while true do pad=Controls.read() screen:clear() bulletSetup() for a=0, 14 do for b=0, 8 do screen:blit(32 * a, 32 * b, grass) end end screen:blit(100,100,tree) screen:blit(300,220,tree) screen:blit(87,46,tree) screen:blit(400,150,tree) screen:blit(Player[1].x,Player[1].y,player) if pad:left() and Player[1].x>0 then Player[1].x=Player[1].x-3 end if pad:right() and Player[1].x<screenwidth then Player[1].x=Player[1].x+3 end if pad:up() and Player[1].y>0 then Player[1].y=Player[1].y-3 end if pad:down() and Player[1].y<screenheight then Player[1].y=Player[1].y+3 end if pad:triangle() then if BulletInfo[i].direction == "up" then BulletInfo[i].y = BulletInfo[i].y - 10 end end if pad:circle() then if BulletInfo[i].direction == "right" then BulletInfo[i].x = BulletInfo[i].x + 10 end end if pad:cross() then if BulletInfo[i].direction == "down" then BulletInfo[i].y = BulletInfo[i].y + 10 end end if pad:square() then if BulletInfo[i].direction == "left" then BulletInfo[i].x = BulletInfo[i].x - 10 end end bulletFire() screen.waitVblankStart() screen.flip() end
-
03-31-2007, 02:52 PM #6474QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
post your error please
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
03-31-2007, 03:00 PM #6475
GAME.LUA:105:attempt to index field '?' (a nil value)
There you go. Not sure what is wrong.
Thanks
-
03-31-2007, 04:30 PM #6476QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
screenwidth=480-player:width()
screenheight=272-player:width()
shouldn't it be:
screenwidth=480-Player:width()
screenheight=272-Player:width()
-
03-31-2007, 04:50 PM #6477
Not sure but the error is in line 105
-= Double Post =-
It has to do with something when i hit the button to shoot it encounters that error. I need this because next i am going to add enemies and collision hopefully.
Thanks to anyone that helps me out.Geändert von Bob Hoil (03-31-2007 um 04:57 PM Uhr) Grund: Automerged Doublepost
-
03-31-2007, 05:01 PM #6478QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
well in
you stated direction="right" but right above that line you stated direction="right"Code:BulletInfo = {} for a = 1,800 do BulletInfo[a] = { pic = bullet , firing = false, direction = "right", x = Player[1].x + 32, y = Player[1].y + 16 } end
maybe that has something to do with it, also dont blame me when i say this cause im new at Lua also, but where did "right" come from?
-
03-31-2007, 05:14 PM #6479
Well i just started so to start i am combing tutorials to make my first game then will write my next game from my head. In the bullet one it said to shoot right.
-
03-31-2007, 05:23 PM #6480QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
so tha character moves right? not right in the direction i mean right is in right


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