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 emericaska8r hey sorry for being off topic here, but how do you change what it says under your ...
-
12-22-2006, 09:08 PM #4801QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
lol, you need dev status. Funny thing is mine said "Neophyte" (even though i think it still should for now).
Zitat von emericaska8r
Also, about that, i am pming a moderator or administrator about that to get it removed...
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...)
-
12-22-2006, 09:11 PM #4802
oh, yea and like i just deposited all my points to the bank, and now it says i don't have enough points to enter the bank anymore. thats so gay
-
12-22-2006, 09:20 PM #4803lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Yea, You need to have 50 to enter it.
-
12-22-2006, 09:29 PM #4804QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
Ahem.......Sorry it was my fault to start this off topic; this is a lua help thread. Lol....
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...)
-
12-22-2006, 09:56 PM #4805Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
i fixed my other error and now am wondering a question i defined player width and player height like this:
but in the collision function i need to use player width also how do i call the variables if they look like the above code? or do i need to assign new varibales and assign them the dimensions of the image?Code:player:width() player:height()
--edit--
also i calls other variables such as (variable name).width how do I need to assign those as well?Geändert von %chrono trigger% (12-22-2006 um 10:18 PM Uhr)
**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
12-22-2006, 10:46 PM #4806Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von %chrono trigger%
you could do this:
Code:if (player.x + player:width() > whatever) etc.
but, its more efficient to do this:
Code:pW = player:width() --in your collision function-- if (player.x + pW > whatever) etc.
that way, the psp doesnt spend time each frame checking the width of the player over and over again.--------------------------------------------------------------------------------------
-
12-22-2006, 10:50 PM #4807Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
--edit--
ok im moving rather smoothly now except when i added this to my code:
it gives me an error saying attemtp to call method 'height' (a nil value)Code:Jewel = {} Jewel[1] = {x=350,y=150,height = Jewel:height(), width = Jewel:width() } Jewel[2] = {x=150,y=100,height = Jewel:height(), width = Jewel:width() } Jewel[3] = {x=200,y=250,height = Jewel:height(), width = Jewel:width() } Jewel[4] = {x=300,y=120,height = Jewel:height(), width = Jewel:width() } Jewel[5] = {x=100,y=225,height = Jewel:height(), width = Jewel:width() }Geändert von %chrono trigger% (12-22-2006 um 11:31 PM Uhr)
**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
12-23-2006, 12:56 AM #4808words 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
Well, seems to me like you don't have a 'Jewel' image created. Whether it be loaded via Image.load as an example, or created, via Image.createEmpty(n,n).

...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
-
12-23-2006, 03:00 AM #4809QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
does anyone know a lua game with scrolling? i have scrolling down, its that in my game i create objects that i want for to STAY on the scrolling background. (example, throw a ...rock or something, it lands and stays, i move character, screen scrolls, rock disappears from screen, go back, rock reappears in the place it was thrown.) i just need to know if someone else has done this so i can get an idea of how to do it myself.
so basically, does anyone know a game with scrolling and has newly created objects scroll with the map too?[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-23-2006, 03:14 AM #4810QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- Sweden
- Beiträge
- 460
- Points
- 6.520
- Level
- 52
- Downloads
- 0
- Uploads
- 0
You got to have two main axis, x and y.
Zitat von EminentJonFrost
For example:
Now you make Screen.x and Screen.y togglable, then you can start to place out your sprites and stuff. Simple enugh?Code:Screen.x = 0 Screen.y = 0 screen:blit(x+Screen.x,y+Screen.y,image) -- You can make this a function so you don't have to write the "+Screen.x" stuff over and over again.
[CENTER]Some of my homebrew Applications/Games:
[URL=http://forums.qj.net/showthread.php?t=47294&page=1&pp=10]Planet Fighter[/URL] | [URL=http://forums.qj.net/showthread.php?p=641672#post641672]Graphic Creator (V2.0)[/URL] | [URL=http://forums.qj.net/showthread.php?p=512717]Fire Pong[/URL] | [B][URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html#post1430891"][COLOR="Red"][SIZE="3"]Brushes v2.0[/COLOR][/SIZE][/B][/URL] [URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][B][SIZE="2"][COLOR="Black"]Released![/COLOR][/SIZE][/B][/URL]
[URL="http://haxxblaster.2u.se/"][COLOR="black"][FONT="Arial Black"]www.HaxxBlaster.com[/FONT][/COLOR][/URL]
[URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][IMG]http://img19.imageshack.us/img19/1346/brushesbannerqz3.png[/IMG][/URL][/CENTER]
-
12-23-2006, 03:36 AM #4811QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
i'm afraid not...whats making this difficult in my case is that, not only does the screen scroll, but the player can move (in a limited box, you can say) around too. so my object appears around my character and it moves how it should on-screen (like if my character goes up, it doesnt). but i want for it to stop, and be part of the background, which scrolls, so now my object must change from player-screen-based coordinates to map coordinates. its complicated...
oh yes, my view is top-down.[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-23-2006, 04:57 AM #4812QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- Sweden
- Beiträge
- 460
- Points
- 6.520
- Level
- 52
- Downloads
- 0
- Uploads
- 0
Yeah, i guessed your game was in a top-down view. I got a unfinnished game with sidescrolling, not top-down view, but it's nearly the same. I think you might want to have a look at it.
Zitat von EminentJonFrost
MSN: [email protected][CENTER]Some of my homebrew Applications/Games:
[URL=http://forums.qj.net/showthread.php?t=47294&page=1&pp=10]Planet Fighter[/URL] | [URL=http://forums.qj.net/showthread.php?p=641672#post641672]Graphic Creator (V2.0)[/URL] | [URL=http://forums.qj.net/showthread.php?p=512717]Fire Pong[/URL] | [B][URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html#post1430891"][COLOR="Red"][SIZE="3"]Brushes v2.0[/COLOR][/SIZE][/B][/URL] [URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][B][SIZE="2"][COLOR="Black"]Released![/COLOR][/SIZE][/B][/URL]
[URL="http://haxxblaster.2u.se/"][COLOR="black"][FONT="Arial Black"]www.HaxxBlaster.com[/FONT][/COLOR][/URL]
[URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][IMG]http://img19.imageshack.us/img19/1346/brushesbannerqz3.png[/IMG][/URL][/CENTER]
-
12-23-2006, 06:49 AM #4813QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
um, ok sure!
edit - i added you. sorry for the delayed response, my internet acted wierd....[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-23-2006, 07:11 AM #4814Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
well this collision is really throwing me off. Can i create a empty image and then paste a .png file on it?
**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
12-23-2006, 07:26 AM #4815QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
that wouldnt do anything different. theres no point (that i know of) to blitting an image, in an image, when all you want is...the first image. post some code up, i'll see if i can be of assistance! :)
Zitat von %chrono trigger%
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-23-2006, 07:27 AM #4816Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
jeres the first half of my code:
Code:red = Color.new(255,0,0) background = Image.load("b.png") player = Image.load("a.png") jewel = Image.load("c.png") playerWidth = 50 playerHeight = 50 screenwidth = 480 - player:width() screenheight = 272 - player:width() Player = {} Player[1] = {x=10,y=10} Background = {} Background[1] = {x=0,y=0} Jewel = {} Jewel[1] = {x=350,y=150, height = jewel:height(), width = jewel:width() } Jewel[2] = {x=150,y=100, height = jewel:height(), width = jewel:width() } Jewel[3] = {x=200,y=250, height = jewel:height(), width = jewel:width() } Jewel[4] = {x=300,y=120, height = jewel:height(), width = jewel:width() } Jewel[5] = {x=100,y=225, height = jewel:height(), width = jewel:width() } Jewel:height() Jewel:width() function collisionCheck(Jewel) if (Player[1].x + playerWidth > Jewel[1].x) and (Player[1].x < Jewel[1].x + Jewel[1].width) and (Player[1].y + playerHeight > Jewel[1].y) and (Player[1].y < Jewel[1].y + Jewel[1].height) then Player.x = oldx Player.y = oldy end end function collisionCheck(Jewel) if (Player[1].x + playerWidth > Jewel[2].x) and (Player[1].x < Jewel[2].x + Jewel[2].width) and (Player[1].y + playerHeight > Jewel[2].y) and (Player[1].y < Jewel[2].y + Jewel[2].height) then Player.x = oldx Player.y = oldy end end function collisionCheck(Jewel) if (Player[1].x + playerWidth > Jewel[3].x) and (Player[1].x < Jewel[3].x + Jewel[3].width) and (Player[1].y + playerHeight > Jewel[3].y) and (Player[1].y < Jewel[3].y + Jewel[3].height) then Player.x = oldx Player.y = oldy end end function collisionCheck(Jewel) if (Player[1].x + playerWidth > Jewel[4].x) and (Player[1].x < Jewel[4].x + Jewel[4].width) and (Player[1].y + playerHeight > Jewel[4].y) and (Player[1].y < Jewel[4].y + Jewel[4].height) then Player.x = oldx Player.y = oldy end end function collisionCheck(Jewel) if (Player[1].x + playerWidth > Jewel[5].x) and (Player[1].x < Jewel[5].x + Jewel[5].width) and (Player[1].y + playerHeight > Jewel[5].y) and (Player[1].y < Jewel[5].y + Jewel[5].height) then Player.x = oldx Player.y = oldy end end**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
12-23-2006, 07:31 AM #4817QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
you put player:width twice..Code:screenwidth = 480 - player:width() --did you MEAN to do this? screenheight = 272 - player:width()
also, it could be confusing to have an image and an array both called 'player'. i know one is capitalized, and that it should work fine, but it could lead to problems later.
i shortened this:
in place of this:Code:Jewel = {} for a = 1, 5 do Jewel[a] = {x=350,y=150, height = jewel:height(), width = jewel:width() } end
Code:Jewel = {} Jewel[1] = {x=350,y=150, height = jewel:height(), width = jewel:width() } Jewel[2] = {x=150,y=100, height = jewel:height(), width = jewel:width() } Jewel[3] = {x=200,y=250, height = jewel:height(), width = jewel:width() } Jewel[4] = {x=300,y=120, height = jewel:height(), width = jewel:width() } Jewel[5] = {x=100,y=225, height = jewel:height(), width = jewel:width() }[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-23-2006, 07:34 AM #4818Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
yes i did thats not the problem and disregard Jewel:height() and the width one they shouldnt be there
**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
12-23-2006, 07:42 AM #4819QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
HERES the problem:
Zitat von %chrono trigger%
remember how i shortened the part before? you announced the SAME function 5 times, so it only affected 1 jewel, since you kept changing which jewel number each time you defined it.Code:function collisionCheck(Jewel) if (Player[1].x + playerWidth > Jewel[1].x) and (Player[1].x < Jewel[1].x + Jewel[1].width) and (Player[1].y + playerHeight > Jewel[1].y) and (Player[1].y < Jewel[1].y + Jewel[1].height) then Player.x = oldx Player.y = oldy end end
try this:
Code:function collisionCheck(Jewel) for a = 1, 5 do if (Player[a].x + playerWidth > Jewel[a].x) and (Player[a].x < Jewel[a].x + Jewel[a].width) and (Player[a].y + playerHeight > Jewel[a].y) and (Player[a].y < Jewel[a].y + Jewel[a].height) then Player.x = oldx Player.y = oldy end end end
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-23-2006, 07:42 AM #4820
- Registriert seit
- Jul 2006
- Beiträge
- 36
- Points
- 3.957
- Level
- 40
- Downloads
- 0
- Uploads
- 0
ok I wasnt sure if i should post this in this thread or not but here it is:
For school im doing a long term project on developing a program for the psp in c/c++.
I thought i had longer than i had so i cant learn the amount of info i need in time.
Basically is there a way that i can imbed a lua file in an eboot so that even if you open up the eboot you couldnt tell that its a lua file or w/e inside. This way i could just pretend its in c and i could make it better and get a better grade since im pretty good at lua
-
12-23-2006, 07:45 AM #4821QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
i dont think so...but i dont know about eboots, so you'll want a second opinion.
Zitat von jamz1825
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-23-2006, 07:47 AM #4822Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
therers my new optimized code so i dont have to many if statements but it gives me the error attempt to index field '?' (a nil value)Code:function collisionCheck(Jewel) local i = 1 while i <=5 do if (Player[1].x + playerWidth > Jewel[i].x) and (Player[1].x < Jewel[i].x + Jewel[i].width) and (Player[1].y + playerHeight > Jewel[i].y) and (Player[1].y < Jewel[i].y + Jewel[i].height) then Player.x = oldx Player.y = oldy end i = i +1 end end**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
12-23-2006, 07:51 AM #4823QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
change every '1' in a these: [ ] to an 'i'. and it should work.
Zitat von %chrono trigger%
also, put this: for i = 1, 5 do
instead of: while i <=5 do
it cycles the code with 'i' changing its values, therefore, affecting 5 jewels. it basically works the same, but you can code how you want. :)[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-23-2006, 07:54 AM #4824Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
like that?
Zitat von %chrono trigger%
-edit-
i guess i did something wrong as i am getting another error**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
12-23-2006, 11:59 AM #4825QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
like this:
:)Code:function collisionCheck(Jewel) for i = 1, 5 do if (Player[i].x + playerWidth > Jewel[i].x) and (Player[i].x < Jewel[i].x + Jewel[i].width) and (Player[i].y + playerHeight > Jewel[i].y) and (Player[i].y < Jewel[i].y + Jewel[i].height) then Player.x = oldx Player.y = oldy end end end[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-23-2006, 03:21 PM #4826
what does the:
do?Code:local i = 1
-
12-23-2006, 05:00 PM #4827Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von emericaska8r
'local' means that only the function you called it in can access the variable. for example, if i did this:
Code:function BOB() local joe = 0 end while true do joe = joe + 1 end
that would result in an error. but this:
that would work perfectly.Code:function BOB() local joe = 0 joe = joe + 1 end while true do BOB() end
--------------------------------------------------------------------------------------
-
12-23-2006, 06:08 PM #4828QJ 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
got a problem ( a stupid one at that), for some reason, in my 2d side scroller, when my charactor moves right and hits the midde of the screen, the background scrolls AND my character still moves forward, yet, when he goes left it works Perfectly, i dont understand, it was working good before, but I must have been stupid and put something in the code to make it stop working, i copied the left movement code to the right and configured it to the right animation but still no good, here is my movement code,
Spoiler for code:
the 2 blocks of code in front are for when the player reaches the middle of the screen, he is "supposedly" stops going forward 4 pixels and the background starts to scroll, (supposedly cuz this doesn't happen for when you press right) the other two code is for when he reaches the end of the screens, it stops scrolling and he starts to walk normally and make sures to stop when he reaches the end of the screen. Help for this would be great, if you need the full code + resources then PM me, I am absilutly sure this is a really simple problem that i just cant find.
thanks in advance, Later!
-Jaws-
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
12-23-2006, 06:12 PM #4829words 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
Im too busy to look into that deeply, but give this try for your FIRST to if's there...
Code:if pad:right() and santaX >= 200 and bg4.x > 0 then scroll = "true" santaState = "runningR" santaDirection = "right" santaX = 200 bg1.x = bg1.x - 3 bg2.x = bg2.x - 3 bg3.x = bg3.x - 3 bg4.x = bg4.x - 3 else scroll = "false" end if pad:left() and santaX <= 155 and bg1.x < 0 then scroll = "true" santaState = "runningL" santaDirection = "left" santaX = 155 bg1.x = bg1.x + 3 bg2.x = bg2.x + 3 bg3.x = bg3.x + 3 bg4.x = bg4.x + 3 else scroll = "false" 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
-
12-23-2006, 06:19 PM #4830QJ 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
Ahhh yup, that did , thanks again! (another reason to credit you:) )
thanks man
y i didn't think to simply state santa's X value is beyond me...
thanks again :)NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:


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