QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

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; .................

Reply
 
LinkBack Thread Tools
Old 10-05-2005, 03:22 PM   #91
 
Bilo's Avatar
 
Join Date: Sep 2005
Location: In your garage
Posts: 73
Trader Feedback: 0
Default

..............

Last edited by Bilo; 10-05-2005 at 04:38 PM..
Bilo is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-05-2005, 04:20 PM   #92

Developer
 
cools's Avatar
 
Join Date: Aug 2005
Posts: 472
Trader Feedback: 0
Default

I am sorry to say that this one doent even display the text... i have noticed in whitehawks tutorial that he did it, so i am going to try and recreate that effect.
__________________

PSP Monopoly | PSP Tic Tac Toe | PSP eMail and SMS | Drag Mini | Block Dude
http://www.cools.biaklan.com
Currently Working on ?????

Quote of the Week
cools is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-05-2005, 04:21 PM   #93
 
Bilo's Avatar
 
Join Date: Sep 2005
Location: In your garage
Posts: 73
Trader Feedback: 0
Default

Code:
board = Image.load("boardnew.png")
screen:blit(0, 0, board, false)
black = Color.new(0, 0, 0)
screen:print(200, 130, "Board", black)
screen.flip()
while true do
screen.waitVblankStart()

end
Sorry, I hadnt even tried what I told you to do. The above WILL work. I tested it


My excuse is that I'm not well. And so thats why what I told you to do was wrong

Last edited by Bilo; 10-05-2005 at 04:48 PM..
Bilo is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-05-2005, 05:05 PM   #94

Developer
 
cools's Avatar
 
Join Date: Aug 2005
Posts: 472
Trader Feedback: 0
Default

Thanks! It works perfectly! :icon_smil
__________________

PSP Monopoly | PSP Tic Tac Toe | PSP eMail and SMS | Drag Mini | Block Dude
http://www.cools.biaklan.com
Currently Working on ?????

Quote of the Week

Last edited by cools; 10-05-2005 at 05:42 PM..
cools is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-05-2005, 05:43 PM   #95
 
Jenay's Avatar
 
Join Date: Jun 2005
Posts: 52
Trader Feedback: 0
Default

I've commeted your program to help you find out why it was doing what it was doing..
Quote:
Originally Posted by cools
well more troubles sadly

Lua will only load the first part of my script, which displays text... It wont load any thing after that.

Code:
black = Color.new(0, 0, 0)
screen:print(200, 130, "Board", black)
screen.flip()
while true do              -- your program hangs here
screen.waitVblankStart()  -- because this is going to loop
end                      -- forever since true is always true

board = Image.load("boardnew.png")
screen:blit(0, 0, board, false) -- putting the picture over your text is going to erase the text. Maybe print the board first, then the text
screen:flip()
while true do
screen:waitVblankStart()
end
Jenay is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-05-2005, 05:46 PM   #96

Developer
 
cools's Avatar
 
Join Date: Aug 2005
Posts: 472
Trader Feedback: 0
Default

Thanks Jenay. Hopefully this will not happen again!
__________________

PSP Monopoly | PSP Tic Tac Toe | PSP eMail and SMS | Drag Mini | Block Dude
http://www.cools.biaklan.com
Currently Working on ?????

Quote of the Week
cools is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-05-2005, 05:49 PM   #97
 
Bilo's Avatar
 
Join Date: Sep 2005
Location: In your garage
Posts: 73
Trader Feedback: 0
Default

Quote:
Originally Posted by cools
Thanks! It works perfectly! :icon_smil




No problem
Bilo is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-05-2005, 06:10 PM   #98
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

Quote:
Originally Posted by Dremth
How can I make something where the user enters text? Like on the PSP when you click on a text box the dialog comes up that has the letters and numbers like on a cell phone. Is there a way to get that?

PLEASE PLEASE PLEASE EMAIL ME!!!!!!
Dremth@austin.rr.com
Wow that took me a while...
Ok put keyboard.lua (rename it to that) in the same file as your main code.
Then put this in your main code:
Code:
dofile("keyboard.lua")
When you want define a variable or print something you can define the variable or what it's printing as keyboard()
Code:
-- Examples
print(keyboard())
thetext = keyboard()
This will allow you to input what it is going to register the value as.

=================
Start - Enter Value
D-pad - select key
R - Space
L - Delete
Select - Like holding down shift
Control pad - Press the button corresponding with the character on the selected key
================

I've tested it and it seems to work on luaplayer v9 but not v11
Attached Files
File Type: txt keyboard.lua.txt‎ (14.6 KB, 73 views)
__________________
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me
[URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL]

Last edited by MagicianFB; 10-05-2005 at 06:18 PM..
MagicianFB is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-05-2005, 06:58 PM   #99
 
Join Date: Oct 2005
Posts: 3
Trader Feedback: 0
Default

I'm having a bit of trouble with the Timer function.

Using this as code:

Code:
Timer = Timer.new(0)
I get:

Code:
error: DEFUSE.LUA:27: attempt to index global 'Timer' (a nil value)
Error: No script file found.

Press start to restart
Thanks in advance for any help.
goldnetx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-05-2005, 06:59 PM   #100
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

Quote:
Originally Posted by goldnetx
I'm having a bit of trouble with the Timer function.

Using this as code:

Code:
Timer = Timer.new(0)
I get:

Code:
error: DEFUSE.LUA:27: attempt to index global 'Timer' (a nil value)
Error: No script file found.

Press start to restart
Thanks in advance for any help.
It's Timer:new(0)
You have to use a colon.
__________________
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me
[URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL]
MagicianFB is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-05-2005, 08:12 PM   #101
 
Join Date: Oct 2005
Posts: 3
Trader Feedback: 0
Default

Hm...I've got the timer now working, but I'm having another problem with it.

If I run the program once it works fine, but once I try and run it a second time I get this error:

Code:
error: DEFUSE.LUA:152: loop in gettable
Error: No script file found.

Press start to restart
The code I have at Line 152 is this:

Code:
Timer:start()
goldnetx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 07:49 AM   #102
 
Snaku's Avatar
 
Join Date: Jun 2005
Posts: 330
Trader Feedback: 0
Default

MagicianFB, can you tell a little about your rpg? Are you just using screen sized backgrounds or can you do the scrolling bg most rpgs have?
I'm interested in doing an rpg myself, and since there seems to be no rpg maker in site for psp, I'm learning lua now. It'd be nice to hear a little about your project so I have a general idea of how to get started.
Also, this may be a little advanced, but would there be a way to display some sort of fmv? I'm not expecting to be able to do a Final Fantasy or something as my very first project, but it seems like with the psp's power it shouldn't be a problem to have decent looking backgrounds and even a movie or two, right? Is there maybe a way for your lua script to make calls to the psp firmware functions? Like to use the psp's built in mp4 or mp3 playback? Or is that something that would need to be built into the actual lua player?

Last edited by Snaku; 10-06-2005 at 07:59 AM..
Snaku is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 08:34 AM   #103
 
lingon's Avatar
 
Join Date: Sep 2005
Posts: 122
Trader Feedback: 0
Default

Can u make lua loop this kind of code?
Code:
pad = Controls.read()

	if pad:circle() then
		screen:blit(0, 0, lua, false)
		screen:print(220, 170, "Fel", svart)
		screen:print(220, 190, "Triangel: Tillbaka", svart)
		screen:print(220, 210, "[]: Avsluta", svart)
		screen.flip()
	
		while true do
		
		jag = Controls.read()
		
		if jag:triangle() then
			screen:blit(0, 0, lua, false)
			screen:print(220, 170, "Hejsan", svart)
			screen:print(220, 190, "O: Nåt trevligt", svart)
			screen:print(220, 200, "X: Info", svart)
			screen:print(220, 210, "[]: Avsluta", svart)
			screen.flip()
		end
		end
lingon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 08:44 AM   #104
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

Just put a while true loop around the entire thing, too
Quote:
Originally Posted by lingon
Can u make lua loop this kind of code?.
Code:
pad = Controls.read()

	if pad:circle() then
		screen:blit(0, 0, lua, false)
		screen:print(220, 170, "Fel", svart)
		screen:print(220, 190, "Triangel: Tillbaka", svart)
		screen:print(220, 210, "[]: Avsluta", svart)
		screen.flip()
	
		while true do
		
		jag = Controls.read()
		
		if jag:triangle() then
			screen:blit(0, 0, lua, false)
			screen:print(220, 170, "Hejsan", svart)
			screen:print(220, 190, "O: Nåt trevligt", svart)
			screen:print(220, 200, "X: Info", svart)
			screen:print(220, 210, "[]: Avsluta", svart)
			screen.flip()
		end
		end
I'm posting from school
__________________
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me
[URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL]
MagicianFB is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 09:12 AM   #105
 
lingon's Avatar
 
Join Date: Sep 2005
Posts: 122
Trader Feedback: 0
Default

Okay, thanks alot.
lingon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 12:18 PM   #106

Developer
 
SodR's Avatar
 
Join Date: Sep 2005
Location: Sweden
Posts: 941
Trader Feedback: 0
Default

Does anyone know how I can change a number to the numer-1 or +1 with the triggers (or any button) like in PSP Soduko?? So if I program a button to insert a 5 or any numer in 1, 1, then how can i change the 5 to go +1 each time I press the right trigger?
SodR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 12:56 PM   #107
 
Jenay's Avatar
 
Join Date: Jun 2005
Posts: 52
Trader Feedback: 0
Default

Code:
if pad:r() then
   if var >= 5 then
      var = var + 1
   else
      var = 5
   end -- if
end -- if
something like this?
Jenay is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 01:21 PM   #108

Developer
 
SodR's Avatar
 
Join Date: Sep 2005
Location: Sweden
Posts: 941
Trader Feedback: 0
Default

Quote:
Originally Posted by Jenay
Code:
if pad:r() then
   if var >= 5 then
      var = var + 1
   else
      var = 5
   end -- if
end -- if
something like this?
I only get this error when I use your code: "attempt to comprare number with nil"
SodR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 01:38 PM   #109
 
Join Date: Oct 2005
Posts: 6
Trader Feedback: 0
Default

hi im new to the whole modding a psp thing... im from england and just downgraded my firmware and started to learna bit of lua

heres the code of my first program (after that tutorial):

Quote:
System.usbDiskModeActivat e()

cursor = Image.load("cursor.png")

x = 200
y = 140

screen.waitVblankStart()

while true do

pad = Controls.read()


if pad:analogX() < -30
then x = x - 1 end

if pad:analogx() > 30
then x = x + 1 end

if pad:analogy() < -30
then y = y - 1 end

if pad:analogy() > 30
then y = y + 1 end

if pad:start()
then break end

screen:blit(x, y, cursor)
screen.flip()


end
im not sure if its going the right way to making a cursor move on the screen, ive had experience with java and things but all i get is an error that reads:

Quote:
error: SCRIPT2.LUA18 loop in gettable
help will be appreciated
tenksnit is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 01:52 PM   #110
 
lingon's Avatar
 
Join Date: Sep 2005
Posts: 122
Trader Feedback: 0
Default

Maybe it has something to do with this
Code:
if pad:analogy() < -30 --I think you should have a big Y here instead of  a small one
then y = y - 1 end

if pad:analogy() > 30
then y = y + 1 end
I'm not sure though. Try it out and see what happens =)
lingon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 01:54 PM   #111
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

Quote:
Originally Posted by lingon
Maybe it has something to do with this
Code:
if pad:analogy() < -30 --I think you should have a big Y here instead of  a small one
then y = y - 1 end

if pad:analogy() > 30
then y = y + 1 end
I'm not sure though. Try it out and see what happens =)
Yeah, I've never programmed using the analog stick, but I think you're right. It has to be analogX and analogY rather that analogx and analogy.

Edit: It make me sorta happy that this thread has lasted so long without being stickied.
__________________
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me
[URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL]
MagicianFB is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 01:57 PM   #112
 
Join Date: Oct 2005
Posts: 6
Trader Feedback: 0
Default

ah... you were both right... lol capitilization errors.... always the way

thanks
tenksnit is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 01:59 PM   #113

Developer
 
cools's Avatar
 
Join Date: Aug 2005
Posts: 472
Trader Feedback: 0
Default

Im having some trouble creating dice. I just want to show the random number in a spot, then get rid of it, but i keep getting an error.

Code:
while true do
pad  = Controls.read()
dice2 = math.random(6)
if pad:cross() then
if dice2==1
then screen:print(90, 50, "1", black)
screen.flip()
if dice2==2
then screen:print(90, 50, "2", black)
screen.flip()
if dice2==3
then screen:print(90, 50, "3", black)
screen.flip()
if dice2==4
then screen:print(90, 50, "4", black)
screen.flip()
if dice2==5
then screen:print(90, 50, "5", black)
screen.flip()
if dice2==6
then screen:print(90, 50, "6", black)
screen.flip()
screen.waitVblankStart()
end
end
__________________

PSP Monopoly | PSP Tic Tac Toe | PSP eMail and SMS | Drag Mini | Block Dude
http://www.cools.biaklan.com
Currently Working on ?????

Quote of the Week
cools is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 03:25 PM   #114

Developer
 
Join Date: Jun 2005
Location: At my house...
Posts: 885
Trader Feedback: 0
Default

Quote:
Originally Posted by cools
Im having some trouble creating dice. I just want to show the random number in a spot, then get rid of it, but i keep getting an error.

Code:
while true do
pad  = Controls.read()
dice2 = math.random(6)
if pad:cross() then
if dice2==1
then screen:print(90, 50, "1", black)
screen.flip()
if dice2==2
then screen:print(90, 50, "2", black)
screen.flip()
if dice2==3
then screen:print(90, 50, "3", black)
screen.flip()
if dice2==4
then screen:print(90, 50, "4", black)
screen.flip()
if dice2==5
then screen:print(90, 50, "5", black)
screen.flip()
if dice2==6
then screen:print(90, 50, "6", black)
screen.flip()
screen.waitVblankStart()
end
end
Use elseif statements.
__________________
F.A.L.O?

Last edited by Twenty 2; 10-06-2005 at 03:36 PM..
Twenty 2 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 03:50 PM   #115
 
Join Date: Oct 2005
Posts: 6
Trader Feedback: 0
Default

can anybody tell me how to set transparency colour for the pngs, e.g i want to make the edges of a cursor transparent

thanks
tenksnit is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 03:54 PM   #116

Developer
 
Join Date: Jun 2005
Location: At my house...
Posts: 885
Trader Feedback: 0
Default

If you use fireworks then you set the canvas to transparent and draw on to it.
__________________
F.A.L.O?
Twenty 2 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 04:20 PM   #117
 
Jenay's Avatar
 
Join Date: Jun 2005
Posts: 52
Trader Feedback: 0
Default

Quote:
Originally Posted by SodR
I only get this error when I use your code: "attempt to comprare number with nil"
put:
var = 0

at the begining of your code.
Jenay is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 04:26 PM   #118
 
Jenay's Avatar
 
Join Date: Jun 2005
Posts: 52
Trader Feedback: 0
Default

Quote:
Originally Posted by cools
Im having some trouble creating dice. I just want to show the random number in a spot, then get rid of it, but i keep getting an error.
Code:
while true do
pad  = Controls.read()
dice2 = math.random(6)
if pad:cross() then
screen:print(90, 50,string.format("%d", dice2), black)
screen.flip()
screen.waitVblankStart()
end
end
try something like this.
Jenay is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 04:44 PM   #119

Developer
 
Join Date: Jun 2005
Location: At my house...
Posts: 885
Trader Feedback: 0
Default

You might actually want to try
Code:
blue = Color.new(0, 0, 225)
while true do
pad  = Controls.read()
dice2 = math.random(6)
if pad:cross() then
screen:clear()
screen:print(90, 50,string.format("%d", dice2), blue)
screen.flip()
screen.waitVblankStart()
end
end
I changed the color so you could actualy see the number and I added a screen clear so that it doesnt print over it self so you cant read it.
__________________
F.A.L.O?
Twenty 2 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 04:48 PM   #120
 
Faint's Avatar
 
Join Date: Jul 2005
Posts: 100
Trader Feedback: 0
Default

Can lua load .mp3 files?
Faint is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
code , lib , lua , luaplayer , noobs , programming , psp programming , scripting , thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 08:48 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us