My first Lua menu :)

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

Moderators: Shine, Insert_witty_name

Post Reply
Ngel
Posts: 4
Joined: Wed Nov 23, 2005 12:51 am

My first Lua menu :)

Post by Ngel »

It's my first project and i really love to use lua!!!
I will get my new psp in the end of this month, hope it would be 1.5 :\
Here is the code:

Code: Select all

-- Ngel V1.0 Menu Test !

green = Color.new(0, 255, 0)
select = 10
icon = Image.load("icon.png")


function delay(delay)
	for i = 1,delay do
	end
end

function choice(cho)
		screen:clear()
	if cho == 1 then
		screen:print(200, 200, "Option 1", green)
	end
	if cho == 2 then
		screen:print(200, 200, "Option 2", green)
	end
	if cho == 3 then
		screen:print(200, 200, "Option 3", green)
	end
	makemenu("0")
end

function makemenu(place)
if place == "down" then
	if select < 70 then
		select = select +30
		screen&#58;clear&#40;&#41;
	end
elseif place == "up" then
	if select > 10 then
		select = select - 30
		screen&#58;clear&#40;&#41;
	end
end
screen&#58;print&#40;200, 10, "Option 1", green&#41;
screen&#58;print&#40;200, 40, "Option 2", green&#41;
screen&#58;print&#40;200, 70, "Option 3", green&#41;
screen&#58;blit&#40;177, select-6, icon&#41;
screen.flip&#40;&#41;
screen.waitVblankStart&#40;&#41;
end

makemenu&#40;&#41;

while true do
	pad = Controls.read&#40;&#41;
	if pad&#58;down&#40;&#41; then
		makemenu&#40;"down"&#41;
		delay&#40;"9199900"&#41;
	end
	if pad&#58;up&#40;&#41; then
		makemenu&#40;"up"&#41;
		delay&#40;"9199900"&#41;
	end
	if pad&#58;start&#40;&#41; then
		break
	end
	if pad&#58;select&#40;&#41; then
		if select == 10 then
		choice&#40;1&#41;
		delay&#40;"9199900"&#41;
		end
		if select ==40 then
		choice&#40;2&#41;
		delay&#40;"9199900"&#41;
		end
		if select ==70 then
		choice&#40;3&#41;
		delay&#40;"9199900"&#41;
		end
	end	
end
Here is the icon.png:
Image

fixed the problem!
Post Reply