Ayuda para programar en lua

Hola a todos , gracias por tomarse le tiempo de leer este mensaje, creo este tema para preguntarles como podria resolver este problema en mi codigo fuente.
Mi problema es que cuando pulso x en la opcion de jugar se supone que tiene que cambiar de pantalla, y si lo hace pero cambia todas las pantallas que he programado de un tiron y quiero evitar eso.
Aqui esta mi codigo fuente y espero me puedan ayudar c:
de antemano gracias por leerme.

--Oldpad
oldpad = Controls.read()
--Oldap Fin
--Colores
blanco = Color.new(255,255,255)
negro = Color.new(0,0,0)
rojo = Color.new(255,0,0)
--Colores Fin
--Imagenes
Imagen1 = Image.load("Imagenes/Imagen1.jpg")
Fondo1 = Image.load("Imagenes/Fondo1.jpg")
Fondo2 = Image.load("Imagenes/Fondo2.jpg")
Fondo3 = Image.load("Imagenes/Fondo3.jpg")
--Imagenes Fin
--Variables
--Texto
TextoMenu1 = "Hola"
TextoMenu2 = "Adios"
TextoJugar = "Jugar"
P1 = "Quieres comenzar?"
P2 = "Cual es tu edad?"
R21 = "Entre 8 - 12 -> O"
R22 = "De 12 - ... -> X"
Si = "Si -> X"
Salir = "Salir -> Start"
--Primer Menu
Menu = 3
Opcion = Menu
Opcion1 = 2
Opcion2 = 2
Jugar = 2
Menu2 = 2
--Segundo Menu
Menu3 = 2
FM2 = 2
FM3 = 2
Menu4 = 2
FM41 = 2
FM42 = 2

--Variables Fin
--Bucle
while true do
screen:clear()
pad = Controls.read()
--screen blit y print Menu 1

screen:blit(1,1, Fondo1)

screen:print(150,10, Menu, blanco)

if Opcion1 == 1 then
screen:print(100,100, TextoMenu1, blanco)
else
screen:print(100,100, TextoMenu1, negro)
end

if Opcion2 == 1 then
screen:print(100,110, TextoMenu2, blanco)
else
screen:print(100,110, TextoMenu2, negro)
end

if Jugar == 1 then
screen:print(100,90, TextoJugar, blanco)
else
screen:print(100,90, TextoJugar, negro)
end
--screen blit y print Fin Menu 1
--Navegacion por el menu 1
if Menu == 1 then
Opcion1 = 1
end

if Menu == 2 then
Opcion1 = 2
end

if Menu == 3 then
Opcion1 = 2
end

if Menu == 2 then
Opcion2 = 1
end

if Menu == 1 then
Opcion2 = 2
end

if Menu == 3 then
Opcion2 = 2
end

if Menu == 3 then
Jugar = 1
end

if Menu == 2 then
Jugar = 2
end

if Menu == 1 then
Jugar = 2
end
--Navegacion por el Menu 1 Fin
--Controles Menu 1
if pad:down() and oldpad:down() ~=pad:down() then
Menu = Menu + 1
end

if Menu == 4 then
Menu = 1
end

if pad:up() and oldpad:up() ~=pad:up() then
Menu = Menu - 1
end

if Menu == 0 then
Menu = 3
end

if Jugar == 1 then
if pad:cross() and oldpad:cross() ~=pad:cross() then
Menu2 = 1
end
screen.waitVblankStart()
end
--Controles Menu 1 Fin
if Menu2 == 1 then
screen:clear()
end
if Menu2 == 1 then
FM2 = FM2 - 1
end

if Menu2 == 2 then
FM2 = 2
end

if FM2 == 1 then
screen:clear()
screen:blit(1,1, Imagen1)
screen:print(190, 150, P1, rojo)
screen:print(230, 170, Si, blanco)
screen:print(230, 190, Salir, blanco)
end

if pad:start() and oldpad:start() ~=pad:start() then
screen.waitVblankStart()
break
end

if pad:cross() and oldpad:cross() ~=pad:cross() then
Menu3 = Menu3 - 1
screen.waitVblankStart()
end

if Menu3 == 1 then
screen:clear()
end

if Menu3 == 1 then
FM3 = FM3 - 1
end

if Menu3 == 2 then
FM3 = 2
end

if FM3 == 1 then
screen:clear()
screen:blit(1,1, Fondo2)
screen:print(240,150, P2, rojo)
screen:print(240,170, R21, blanco)
screen:print(240, 190, R22, blanco)
end

if pad:circle() and oldpad:circle() ~=pad:circle() then
Menu4 = Menu4 -1
screen.waitVblankStart()
end

if pad:cross() and oldpad:cross() ~=pad:cross() then
Menu4 = Menu4 + 1
screen.waitVblankStart()
end

if Menu4 == 1 then
screen:clear()
end

if Menu4 == 3 then
screen:clear()
end

if Menu4 == 1 then
FM41 = FM41 - 1
end

if Menu4 == 1 then
FM42 = 2
end

if Menu4 == 3 then
FM42 = FM42 - 1
end

if Menu4 == 3 then
FM41 = 2
end

if FM41 == 1 then
screen:clear()
screen:blit(1,1, Fondo3)
screen:print(240, 150, "FM41", blanco)
end

if FM42 == 1 then
screen:clear()
screen:blit(1,1, Fondo3)
screen:print(240, 150, "FM42", blanco)
end

screen.waitVblankStart()
screen.flip()
oldpad = pad
end


Anuncios Google

Opciones de visualización de comentarios

Seleccione la forma que prefiera para mostrar los comentarios y haga clic en «Guardar las opciones» para activar los cambios.
Imagen de gdljjrod

Todo en el mismo script??

Creo que debes de partir en varios script tu code....

Opciones de visualización de comentarios

Seleccione la forma que prefiera para mostrar los comentarios y haga clic en «Guardar las opciones» para activar los cambios.