[Controls help] Push the Up-button and the X button to...

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
MacorgaZ
Posts: 1
Joined: Mon Jun 26, 2006 12:25 am

[Controls help] Push the Up-button and the X button to...

Post by MacorgaZ »

Hi!
I'm new here to the forum, so if I do anything wrong, just tell me :).

I want to make a simple game, and for that i need a piece of code that checks if 2 buttons are pressed, like the Up-button and the X-button.

Would this code do:

Code: Select all

if pad:cross() and
   pad:up() then
screen:print(100, 250, "Blablabliboe", blue)
screen.flip()
end
Or is there something wrong in it?
I'm just a beginner (a bit better then newbie :p), so I don't know how to use If-statements that wel.

So, if anybody knows how i should do this, please tell me :).


Thanks in advance, MacorgaZ.
Debug
Posts: 16
Joined: Thu Oct 06, 2005 4:16 am

Post by Debug »

it should, try it, if not, try

Code: Select all

if pad:cross() then 
   if pad:up() then
      screen:print(100, 250, "Blablabliboe", blue)
      screen.flip()
   end
end

Code: Select all

catch(IOException e){
//oh crap
}
User avatar
daurnimator
Posts: 38
Joined: Sun Dec 11, 2005 8:36 pm
Location: melbourne, australia

Post by daurnimator »

it should work...
have you tested it?
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

pad = controls.read()

Code: Select all



if pad:cross() and 
   pad:up() then 
screen:print(100, 250, "Blablabliboe", blue) 
screen.flip() 
end 
Teggles
Posts: 27
Joined: Mon Jan 16, 2006 9:30 am

Post by Teggles »

If you would like the text to remain on the screen after pressing the buttons (then disappear after pressing again), you would use variables. Here is an example:

Code: Select all

local display = 0
local pad = Controls.read()

while (true) do
	pad = Controls.read()
	if (pad:up()) and (pad:cross()) then
		if (display == 0) then
			display = 1
		elseif (display == 1) then
			display = 0
		end
	end

	screen:clear()
	if (display == 1) then
		screen:print(0, 0, "blah", Color.new(0, 0, 0))
	end
	screen.flip()
end
Post Reply