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; Originally Posted by Twenty 2 Ok i fixed the == part and I forgot to put a % in front ...

Reply
 
LinkBack Thread Tools
Old 10-08-2005, 04:03 PM   #151
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

Quote:
Originally Posted by Twenty 2
Ok i fixed the == part and I forgot to put a % in front of d. No when I test the program and when i press up it goes straight to 2 and wont go higher. When i press down it goes straight to zero.

Code:
m = 1
ran = math.random(100)
blue = Color.new(0, 0, 225)

while true do

pad = Controls.read()

if pad:up() then
screen:clear()
screen:print(230, 136, string.format("%d", m + 1), blue)
screen:flip() end

if pad:down() then
screen:clear()
screen:print(230, 136, string.format("%d", m - 1), blue)
screen:flip() end

if pad:cross() and m == ran then
screen:clear()
screen:print(230, 136, string.format("%d", m), blue)
screen:print(230, 136, "You guessed correctly!", blue)
screen:flip() end

if pad:start() then
break end

end
That's because it's going to fast.

Code:
while true do
	screen.waitVblankStart(5) -- add this
__________________
"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-08-2005, 04:05 PM   #152

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

It still has the same problem and it shouldnt stop at 2.
__________________
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-08-2005, 04:10 PM   #153
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

Quote:
Originally Posted by Twenty 2
It still has the same problem and it shouldnt stop at 2.
Oh, I see, m stays as one, you never redefined it. It shoul be this:
Code:
m = 1
ran = math.random(100)
blue = Color.new(0, 0, 225)

while true do

pad = Controls.read()

if pad:up() then
m = m+1
screen:clear()
screen:print(230, 136, string.format("%d", m), blue)
screen:flip() end

if pad:down() then
m = m-1
screen:clear()
screen:print(230, 136, string.format("%d", m), blue)
screen:flip() end

if pad:cross() and m == ran then
screen:clear()
screen:print(230, 136, string.format("%d", m), blue)
screen:print(230, 136, "You guessed correctly!", blue)
screen:flip() end

if pad:start() then
break end

end
__________________
"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-08-2005, 04:17 PM   #154

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

Ok thnx it works now, but it goes to fast. Is there anyway to slow it down? Also how would you set limits to the number so its 0-100,like "if m<100 then
m=m+1?
__________________
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-08-2005, 04:27 PM   #155
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

Quote:
Originally Posted by Twenty 2
Ok thnx it works now, but it goes to fast. Is there anyway to slow it down? Also how would you set limits to the number so its 0-100,like "if m<100 then
m=m+1?
the screen.waitVblanKStark() makes it wait a certain amount of time before reading the next line of code.
Example: screen.waitVblanKStark(8) make it wait 8/60 of a second.
Use this at the beginning of the while loop to slow it down.
__________________
"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-08-2005, 04:41 PM   #156
 
Join Date: Jun 2005
Posts: 130
Trader Feedback: 0
Default

hi am on the 2nd Tutorials in Lua and i get

error: script:127: \end/ expected (to close \while/ at line 65) near \<eof>/

here is the code

http://www.filefactory.com/get/f2.ph...3dda454f100e57
tupac12 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-08-2005, 04:42 PM   #157
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

As the error suggest, you left out an
Code:
end
somewhere in that code.
__________________
"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-08-2005, 04:51 PM   #158
 
Join Date: Jun 2005
Posts: 130
Trader Feedback: 0
Default

Quote:
Originally Posted by MagicianFB
As the error suggest, you left out an
Code:
end
somewhere in that code.
in line 65?

because its

Code:
while true do
there
tupac12 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-08-2005, 04:57 PM   #159
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

Quote:
Originally Posted by tupac12
in line 65?

because its

Code:
while true do
there
So that means you never closed that loop with an end statement.
__________________
"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-08-2005, 07:51 PM   #160
 
sofa king dumb's Avatar
 
Join Date: Aug 2005
Location: USA
Posts: 214
Trader Feedback: 0
Default

just a quick question, what does the "==" do
sofa king dumb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-08-2005, 08:00 PM   #161
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

Quote:
Originally Posted by sofa king dumb
just a quick question, what does the "==" do
It ask if the two values are equal
__________________
"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-09-2005, 05:22 AM   #162
 
lingon's Avatar
 
Join Date: Sep 2005
Posts: 122
Trader Feedback: 0
Default

This is supposed to be a timer program but I cant really get it to work. I suspect it has something to do with the tostring because I dont know much about these kinda things.

Code:
--Ett tidtagningsprogram

--Definiera färger
svart = Color.new(0, 0, 0)
vit = Color.new(255, 255, 255)

Timer = Timer.new(0)

--Definiera bilder 
lua = Image.load("lua.png")
luasplash = Image.load("luasplash.png")
klocka = Image.load("klocka.png")

function menu()
	screen:blit(0, 0, lua, false)
		screen:print(220, 170, "Carls tidtagningsprogramm", svart)
		screen:print(220, 190, "X:Info", svart)
		screen:print(220, 200, "O:Gå vidare till tidtagningen", svart)
		screen:print(220, 210, "Select: Avsluta", svart)
		screen.flip()
	
	while true do
		
		pad = Controls.read()
		
		if pad:cross() then
			screen:blit(0, 0,lua, false)
			screen:print(50, 200, "Detta program tillåter dig att ta tid.", svart)
			screen:print(50, 210, "Det skapades av Carl den 8 Okt 2005", svart)
			screen:print(220, 170, "Triangel:Tillbaka", svart)
			screen:print(220, 180, "Select: Avsluta", svart)
			screen.flip()
		end	

		if pad:triangle() then
			menu()
			screen.waitVblankStart()
			screen.flip()	
		end	

		if pad:circle() then
			menua()
		end
	end
end

function menua()
	screen:blit(0, 0, klocka, false)	
	screen:print(150, 180, "tryck R för att starta, L för att Stoppa och R+L för att återställa", svart)	

	while true do
		
		pad = Controls.read()
			
			screen:print(220, 133, tostring(math.floor(Timer:time()/1000/60) .. ":" .. math.floor((Timer:time()/1000/60-math.floor(Timer:time()/1000/60))*60) .. ":" .. string.sub(tostring(math.floor(Timer:time()/10)), -2)), svart)
			screen.flip()		
		
			if pad:r() then
				Timer:start()
				Timer:reset(0)
			end		
	
			if pad:l() then
				Timer:stop()
				break
			end

			if pad:triangle() then
				menu()			
			end	
	end
end

screen:blit(0, 0, luasplash, false)
screen.waitVblankStart()
screen.flip()
screen.waitVblankStart(180)
menu()
It just flips around, maybe too many screen.flip()?
I think I'm gonna start making my programs in english from now on =)

Last edited by lingon; 10-09-2005 at 09:40 AM..
lingon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-09-2005, 06:45 AM   #163

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

Too bad there aren't so many swedish programers here to enjoy your app.

Lol ja heter också Karl...
SodR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-09-2005, 07:00 AM   #164
 
lingon's Avatar
 
Join Date: Sep 2005
Posts: 122
Trader Feedback: 0
Default

Haha, hur stor är chansen för det? Det är inte så många som heter Carl/Karl nuförtiden.
Hursomhelst, Lua fixar ju inte å, ä, ö men jag funderar på om man skulle ta och göra två versioner utav ens programm, dom som blir bra asså. En svensk och en engelsk, om man orkar. Förresten, hur funkade det där med wait.VblankStart som jag Pm:ade om?
lingon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-09-2005, 01:26 PM   #165
 
lingon's Avatar
 
Join Date: Sep 2005
Posts: 122
Trader Feedback: 0
Default

come on guys...hlp plz
lingon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-09-2005, 02:32 PM   #166
i <3 fluffy rainbows
 
pspmachine's Avatar
 
Join Date: Jul 2005
Location: United Kingdom
Posts: 862
Trader Feedback: 0
Question Scrolling...

Hey!

Does anybody know how to make text scroll upwards, say like film credits?

Thanks in advance...


--pspmachine :icon_smil
pspmachine is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-09-2005, 03:28 PM   #167

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

Quote:
Originally Posted by lingon
come on guys...hlp plz
I dont have time to look at whats wrong but here is an example of MagicianFB's timer
Code:
-- Define Colors
white = Color.new(255, 255, 255)
yellow = Color.new(255, 255, 0)

-- Print Instructions
screen:print(5, 5, "Press L to begin and R to stop.", yellow)
screen:flip()

-- Create Timer
Timer = Timer.new(0)

-- Start Main Program
while true do
	screen.waitVblankStart(5)
	pad = Controls.read()
	if pad:l() then
		Timer:reset()
		Timer:start()
		while true do
			pad = Controls.read()
			screen:clear()
			screen:print(5, 5, "Press L to begin and R to stop.", yellow)
			screen:print(220, 133, tostring(math.floor(Timer:time()/1000/60) .. ":" .. math.floor((Timer:time()/1000/60-math.floor(Timer:time()/1000/60))*60) .. ":" .. string.sub(tostring(math.floor(Timer:time()/10)), -2)), white)
			screen:flip()
			if pad:r() then
				Timer:stop()
				break
			end
		end
	elseif pad:start() then
		break
	elseif pad:select() then
		screen:save("screenshot.png")
	end
end
__________________
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-09-2005, 03:34 PM   #168
i <3 fluffy rainbows
 
pspmachine's Avatar
 
Join Date: Jul 2005
Location: United Kingdom
Posts: 862
Trader Feedback: 0
Default

And my question?

--pspmachine
pspmachine is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-09-2005, 04:02 PM   #169

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

Theres a credit scroller at http://lumo.at.tt/ but it goes from right to left.
__________________
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-09-2005, 06:13 PM   #170
 
sofa king dumb's Avatar
 
Join Date: Aug 2005
Location: USA
Posts: 214
Trader Feedback: 0
Default

how would i make it display for example a score, would this be right?
screenrint(55, 55, "your score is"x, black) --with x being the score
screen.flip()
sofa king dumb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-09-2005, 06:16 PM   #171
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

Quote:
Originally Posted by sofa king dumb
how would i make it display for example a score, would this be right?
screenrint(55, 55, "your score is"x, black) --with x being the score
screen.flip()
"your score is" .. x
This is how you put things together:
Code:
 ..
__________________
"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-09-2005, 06:23 PM   #172
 
Join Date: Oct 2005
Posts: 3
Trader Feedback: 0
Default

edit: *already covered*
goldnetx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-09-2005, 11:53 PM   #173
i <3 fluffy rainbows
 
pspmachine's Avatar
 
Join Date: Jul 2005
Location: United Kingdom
Posts: 862
Trader Feedback: 0
Default

Quote:
Originally Posted by Twenty 2
Theres a credit scroller at http://lumo.at.tt/ but it goes from right to left.
Thanks alot buddy!

--pspmachine
pspmachine is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-10-2005, 09:49 AM   #174
 
lingon's Avatar
 
Join Date: Sep 2005
Posts: 122
Trader Feedback: 0
Default

Thx, twenty 2. I'll see what I can make out of it =)
lingon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-10-2005, 12:46 PM   #175
 
sofa king dumb's Avatar
 
Join Date: Aug 2005
Location: USA
Posts: 214
Trader Feedback: 0
Default

how do you do colissions in lua?
sofa king dumb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-10-2005, 03:07 PM   #176

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

How do you make a sprite repeat when i button is pressed?
__________________
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-10-2005, 04:58 PM   #177
 
Join Date: Oct 2005
Posts: 6
Trader Feedback: 0
Default

ok, im not sure if im talking rubbish here but how do u create an eboot from a lua script? 0_o ive seen some programs on the files list "created in lua" but how do they become eboots? all so confusing...

Thanks
tenksnit is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-10-2005, 05:06 PM   #178

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

It doesnt have an eboot, you download Luaplayer 11 which does. It just uses script.lua which is put in the aplications.
__________________
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-10-2005, 11:29 PM   #179
 
Join Date: Oct 2005
Posts: 6
Trader Feedback: 0
Default

ok, sorry ill re-phrase my queston:

i have seen programs availabe for download in the file section, they say they have been written in lua, but open using an eboot file, is there a way to somehow convert the lua script to be run by an eboot

e.g, run straight from the game menu, and not going through the lua player...

thanks
tenksnit is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-11-2005, 03:36 PM   #180
Premium Member
 
Lancer's Avatar
 
Join Date: Sep 2005
Posts: 44
Trader Feedback: 0
Default

Quote:
Originally Posted by sofa king dumb
how do you do colissions in lua?
I wrote a function to detect collisions a couple of days ago. I'm not sure what the method is called (bounding box?), but the function returns true if the boxes are colliding.

Code:
function squarecollision(sq1xpos, sq1xsize, sq1ypos, sq1ysize, sq2xpos, sq2xsize, sq2ypos, sq2ysize)
   if sq1xpos <= (sq2xpos + sq2xsize) and (sq1xpos + sq1xsize) >= sq2xpos then
      if sq1ypos <= (sq2ypos + sq2ysize) and (sq1ypos + sq1ysize) >= sq2ypos then
         return true
      else
         return false
      end
   end
end
Just in case you don't understand the variables:

sq = square
1/2 = box 1 or 2
x/y = x or y axis
pos = position
size = size
Lancer 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 07:10 PM.



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