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; Is there a way to us c/c++ code in a lua script? For instance would it be possible to modify ...
-
03-29-2007, 02:22 AM #6421
Is there a way to us c/c++ code in a lua script? For instance would it be possible to modify some of the functions from Zettablade's vlib to to let them be used with the lua player, or would they have to compiled into the player itself?
-
03-29-2007, 02:26 AM #6422.info

- Registriert seit
- Jun 2006
- Ort
- ACT, Australia
- Beiträge
- 1.674
- Points
- 15.395
- Level
- 80
- Downloads
- 0
- Uploads
- 0
You either have to compile it into luaplayer or load it as an lrx
-
03-29-2007, 02:34 AM #6423
Sorry, but I'm still a newbie, what's an lrx?
-
03-29-2007, 02:40 AM #6424.info

- Registriert seit
- Jun 2006
- Ort
- ACT, Australia
- Beiträge
- 1.674
- Points
- 15.395
- Level
- 80
- Downloads
- 0
- Uploads
- 0
It's an extra library that lets you add more functions to your script
Ive used sysext lrx, for example that adds the ability to play .ogg, overclock the cpu, exit the application, launch static elf's etc.
-
03-29-2007, 03:02 AM #6425
Is an lrx a pre-compiled library, or is it like a script that can be edited?
-
03-29-2007, 07:19 AM #6426I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
It's a pre-compiled library. It's basically a .prx, with the L from LuaPlayer. :|
Zitat von Merick

-
03-29-2007, 04:03 PM #6427
hey can i just have a menu coded in lua so i can learn from it and study cause i am learning lua now and want a menu thank you
-
03-29-2007, 04:07 PM #6428lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Look in the code snippets thread, Its sticked in this forum.
-
03-29-2007, 04:23 PM #6429
ok but is there one that will help me with this type of menu
where there are 3 menu bgs with 3 options in them start credits and quit this is designed in
and the three images are
the first one is with the arrow pionting to start second one to credits and 3rd one to quit designed in not coded is there a menu in the snippets like that
-
03-29-2007, 04:26 PM #6430lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
So when you highlight an option, It will display the arrow picture next to it?
-
03-29-2007, 04:27 PM #6431
kinda if you want i can post the pics
-
03-29-2007, 04:31 PM #6432lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Guess what i found in the snippets thread?
Just with some minor indention ;)
Spoiler for Keep guessing...:Geändert von Anti-QJ (03-29-2007 um 04:43 PM Uhr)
-
03-29-2007, 04:42 PM #6433.info

- Registriert seit
- Jun 2006
- Ort
- ACT, Australia
- Beiträge
- 1.674
- Points
- 15.395
- Level
- 80
- Downloads
- 0
- Uploads
- 0
A basic menu is not hard to make, just simply declare the amount of menu items and make something like this:
and so on.Code:if pad:up() then menu = menu - 1 end if pad:down() then menu = menu + 1 end if menu > 5 then -- if menu is over the maximum amount menu = 1 end if menu == 1 then -- if the menu is number 1 screen:blit(0,0,arrow) end if menu == 2 then -- if menu is number 2 screen:blit(0,10,arrow) end
-
03-29-2007, 04:46 PM #6434
ok these are the images please no one copy these
menu1

menu2

menu3
-
03-29-2007, 04:47 PM #6435QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
I think that could should be:
Zitat von Yongobongo
I just changed some things in it. In your code, if you go above of the 5th option in the menu, the code resets to the 1st option. It should be 5th option if the menu goes above the 5th option. Vice versa for the minimum option.Code:if pad:up() then menu = menu - 1 end if pad:down() then menu = menu + 1 end if menu > 5 then -- if menu is over the maximum amount menu = 5 end if menu < 1 then -- if menu is below the minimum amount menu = 1 end if menu == 1 then -- if the menu is number 1 screen:blit(0,0,arrow) end if menu == 2 then -- if menu is number 2 screen:blit(0,10,arrow) end
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-29-2007, 04:48 PM #6436lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Just edit the code I posted to display your arrow instead of the arrow it makes.
Also edit it to blit the arrow on both sides.
Should be very simple, I just don't want to give you the code cause i would rather have you learn something ;)
-
03-29-2007, 04:51 PM #6437
ok thanks
-= Double Post =-
would it look something like this
code-
blue = Color.new(0, 153, 255)
orange = Color.new(155, 102, 0)
gray = Color.new(153, 153, 153)
black = Color.new(0 , 0, 0)
---Variables---
Select = 1
MaxSelect = 3
WOC1 = Image.load("images/WoC1.jpg")
WOC2 = Image.load("images/WoC2.png")
WOC3 = Image.load("images/WoC3.png")
---Loop----
while true do
pad = Controls.read()
screen:clear()
--Player decision---
if pad:down()
Select = Select + 1
end
if pad:up() then
Select = Select - 1
end
--Menu Options---
if Select == 1 then
screen:blit(0,0,WOC1)
screen:flip()
end
if Select == 2 then
screen:blit(0,0,WOC2)
screen:flip()
end
if Select == 3 then
screen:blit(0,0,WOC3)
screen:flip()
end
if Select < 1 then
screen:blit(0,0,WOC3)
screen:flip()
end
if Select > 3 then
screen:blit(0,0,WOC1)
end
screen:flip()
screen.waitVblankStart()
endGeändert von pspdude10594 (03-29-2007 um 04:55 PM Uhr) Grund: Automerged Doublepost
-
03-29-2007, 04:56 PM #6438lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
I think it should be:
Zitat von superbatxs
Code:if pad:up() then menu = menu - 1 end elseif pad:down() then menu = menu + 1 end elseif menu => 4 then menu = 1 end elseif menu <= 0 then menu = 3 end elseif menu == 1 then screen:blit(0,0,arrow) end elseif menu == 2 then screen:blit(0,10,arrow) end elseif menu == 3 then screen:blit(0,20,arrow) end
-
03-29-2007, 04:59 PM #6439
does that look ok or needs work
Zitat von pspdude10594
-
03-29-2007, 05:02 PM #6440QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
So if a menu option is more than 4, make the menu option 1? Or if a menu option is equal to 4, make the menu option 1? It depends on the user. You can have a menu either way. Btw, I was talking about 5 menu options. Also, you don't have to have that. Instead of
Zitat von Anti-QJ
you can putCode:elseif menu =>4 then menu = 1 end
Btw, i am not sure if it needs an else if....you can just if alone.Code:if menu > 3 then menu = 1 end
--Double post--
Just a simple code cleanup. Yea, that could work. Btw, you don't need the colors, unless you use them later.Code:--Variables Select = 1 MaxSelect = 3 WOC1 = Image.load("images/WoC1.png") WOC2 = Image.load("images/WoC2.png") WOC3 = Image.load("images/WoC3.png") ---Loop---- while true do pad = Controls.read() --Player decision--- if pad:down() Select = Select + 1 end if pad:up() then Select = Select - 1 end --Menu Options--- if Select == 1 then screen:blit(0,0,WOC1) screen:flip() end if Select == 2 then screen:blit(0,0,WOC2) screen:flip() end if Select == 3 then screen:blit(0,0,WOC3) screen:flip() end if Select > 3 then Select == 1 end if Select < 1 then Select == 3 end screen.waitVblankStart() endCalypso - 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-29-2007, 05:03 PM #6441lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
You need to had a statement where if X is press it will do this, You can do that...Code:blue = Color.new(0, 153, 255) orange = Color.new(155, 102, 0) gray = Color.new(153, 153, 153) black = Color.new(0 , 0, 0) ---Variables--- Select = 1 MaxSelect = 3 WOC1 = Image.load("images/WoC1.png") WOC2 = Image.load("images/WoC2.png") WOC3 = Image.load("images/WoC3.png") ---Loop---- while true do pad = Controls.read() screen:clear() --Player decision--- if pad:down() Select = Select + 1 end if pad:up() then Select = Select - 1 end --Menu Options--- if Select == 1 then screen:blit(0,0,WOC1) screen:flip() end elseif Select == 2 then screen:blit(0,0,WOC2) screen:flip() end elseif Select == 3 then screen:blit(0,0,WOC3) screen:flip() end if Select <= 0 then screen:blit(0,0,WOC3) screen:flip() end elseif Select => 4 then screen:blit(0,0,WOC1) end screen:flip() screen.waitVblankStart() end
-= Double Post =-
=> means "equal" or "greater than"
Zitat von superbatxs
<= means "equal" or less than"
"elseif" is a good idea when you have alot of if statements.Geändert von Anti-QJ (03-29-2007 um 05:06 PM Uhr) Grund: Automerged Doublepost
-
03-29-2007, 05:10 PM #6442QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
Lol, you can use either ways. I was just saying that you don't have to have "elseif", you can just put "if".
Zitat von Anti-QJ
Edit:
Anti-Qj, in your code
What if you keep pressing up? What if you are at Select == -1? If you keep press up, and when you eventually try to go above the 1st option, you will get the 3rd option. But if you keep pressing up, it will stay as the third option. Here is what should work:Code:if Select <= 0 then screen:blit(0,0,WOC3) screen:flip() end elseif Select => 4 then screen:blit(0,0,WOC1) screen:flip() end
Code:if Select < 1 then Select == 1 end elseif Select > 3 then Select == 3 end
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-29-2007, 05:12 PM #6443lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
But if you have alot of if statements, a elseif is a good idea.
Zitat von superbatxs
Bad
GoodCode:if blah then blah end if blah then blah end if blah then blah end
Code:if blah then blah end elseif blah then blah end elseif blah then blah end
-
03-29-2007, 05:16 PM #6444QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
Edited previous post*
Zitat von Anti-QJ
Also, doesn't matter to me.....both do the same thing. In fact, "if" is less code than "elseif".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-29-2007, 05:20 PM #6445lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
..
Zitat von superbatxs
..:Argh:
-= Double Post =-
As mentioned before, I dont want to give him the full code, He jsut wanted to know how to use an arrow as a selector.;)
Zitat von superbatxs
Geändert von Anti-QJ (03-29-2007 um 05:23 PM Uhr) Grund: Automerged Doublepost
-
03-29-2007, 06:45 PM #6446
I should point out that there's a mistake there....and that multiple Ifs are longer than Elseifs.
Elseifs basically allow you to skip the "end" until you've finished putting in Elseifs.Code:if blah then something elseif blah then something end --AS OPPOSED TO-- if blah then something end if blah then something end
-
03-29-2007, 06:59 PM #6447lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Thats what i have been saying...
Look, Say you have a program that has this snippet in it...
Well, it will check if x is equal to 2, if it is then it will run but it will still check if x is equal to 3 and 4 which is wasting time.Code:if x == 2 then blah end if x == 3 then blah end if x == 4 then blah end
Now if you put...
It will check and if 2 is equal to x it will run whatever the blah is, but now since you have a elseif statement it will(as mentioned before0 ignore the other two if statements because we already know what x is, x = 5Code:if x == 2 then blah end elseif x == 3 then blah end elseif x == 4 then blah end
It basically saves some time.
PS. Sorry about the indention if you cant read it, I just am use to indention now.
-
03-29-2007, 07:02 PM #6448Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
your ignorance scares me. if they both do the same thing, why in the world would lua even have it? as aint-qj explained, using else/elseif's saves many cpu cycles, which you desperately need when working with a console such as the psp.
Zitat von superbatxs
--------------------------------------------------------------------------------------
-
03-29-2007, 07:06 PM #6449lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
I just didn't like how he said " "if" is less code then "elseif" "
That just seems like something a nub would say.
BTW, Doesn't this look nice?
Why in the world did i say that?Code:if x == 2 then blah end elseif x == 3 then blah end elseif x == 4 then blah end
Because i think super should learn how to indent.
-
03-29-2007, 07:21 PM #6450QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
Sorry, i have to be honest. I wasn't thinking properly....just typing while i was doing my math homework (or was I.....?). Honestly, i do use "else if" in my menu code in C.
Zitat von Grimfate126
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...)


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