Submit Your Own Code

PSP Lua CodeBase : Menu

Description:
Just a simple menu, revised version of ARza's.untested but should be correct

By using this code, you accept the Creative Commons
Attribution-NonCommercial-ShareAlike 2.5 License. Details may be found at:
http://creativecommons.org/licenses/by-nc-sa/2.5/

  -- EVILMANA.COM PSP LUA CODEBASE
-- www.evilmana.com/tutorials/codebase
-- Menu
-- SUBMITTED BY: nathan42100

----------index.lua----------
currstate="startup"
function printCentered(y, text, color)
  local tl=string.len(text) 
  local xmod = 240-((tl*10)/2) 
  screen:print(xmod, y, text, color) 
end
-----------------
dofile("colors.lua")--contains all color codes, make one yourself
-----------------
screen:clear()
printCentered(131,"Starting up...",white)
screen.waitVblankStart(3)
screen.flip()
-----------------
dofile("config.txt")--contains the options changed in the options menu
-----------------
menu={}
menu[1] = "Single Player"
menu[2] = "Multi Player"
menu[3] = "Options"
menu[4] = "Update"
menu[5] = "Quit"
menu[currselect] =1 
menu[entries]=table.getn(menu) - 2
-----------------
menuBackground=Image.load("menuBackground.png")
-----------------
screen:clear()
printCentered(131,"Loaded!",white)
screen.waitVblankStart(3)
screen.flip()
currstate="menu"
-----------------
while not Controls.read():start()
pad=Controls.read()
screen:clear()
if currstate=="menu" then
screen:blit(0,0,menuBackground)
for i=1,menu[entries] do
if i==menu[currselect] then
printCentered((20+((i-1)*10)), menu[i], red)
else
printCentered((20+((i-1)*10)), menu[i], white)
end
end

if pad:cross() then
if i==1 then --SP
 dofile("singleplayer.lua")
elseif i==2 then --MP
 dofile("multiplayer.lua")
elseif i==3 then --Options
 dofile("options.lua")
elseif i==4 then --Update
 dofile("update.lua")
elseif i==5 then --Quit
 break
end
elseif pad:down() then
if menu[currselect]==5 then
menu[currselect]=1
else
menu[currselect]=menu[currselect]+1
end
elseif pad:up() then
if menu[currselect]==1 then
menu[currselect]=5
else
menu[currselect]=menu[currselect]-1
end
end

screen.flip()
screen.waitVblankStart()
end

Back to CodeBase
 

Please welcome jramada, our newest member.

Who's Online: 3 Guests, 0 Users

Total Members: 555
Total Posts: 13057
Total Topics: 1480
Total Categories: 8
Total Boards: 35

Recent Posts:

Re: Lua Loader? by osgeld
Re: Lua Loader? by acer5050
Re: Lua Loader? by bumuckl
Re: Lua Loader? by acer5050
Re: Lua Loader? by bumuckl
Lua Loader? by acer5050
Re: PGELua Help - need term for a special rotation fix (mathematical issue) by bumuckl
Re: PGELua Help - need term for a special rotation fix (mathematical issue) by tacticalpenguin


Copyright © 2006-2007 www.EvilMana.com All rights reserved.
EvilMana Logo by emcp and Charlie