Anuncios Google

Teclas no responden [LuaDEV]

He intentado realizar un pequeño homebrew en LuaDEV, un menu, pero cuando pulso cualquier flecha de dirección, este no responde, y al rato, el menu dice "not enough memory", aquí dejo el codigo por si he hecho algo mal.

currentselection = 1
 
while true do
screen.clear()
pinselector = image.load("resources/pin.png")
mainmenu = image.load("resources/mainmenu.png")
image.blit(mainmenu,0,0)
 
if currentselection == 1 then
image.blit(pinselector,189,116)
end
 
if currentselection == 2 then
image.blit(pinselector,189,155)
end
 
if currentselection == 3 then
image.blit(pinselector,189,195)
end
 
if controls.press("up") then
 if currentselection == 2 then
 currentselection = 1
 end
 if currentselection == 3 then
 currentselection = 2
 end
end
 
if controls.press("down") then
 if currentselection == 1 then
 currentselection = 2
 end
 if currentselection == 2 then
 currentselection = 3
 end
end
 
screen.flip()
screen.waitvblankstart()
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.

currentselection =

currentselection = 1
pinselector = image.load("resources/pin.png")
mainmenu = image.load("resources/mainmenu.png")
 
while true do
controls.read()
mainmenu:blit(0,0)
 
if currentselection == 1 then
	pinselector:blit(189,116)
elseif currentselection == 2 then
	pinselector:blit(189,155)
elseif currentselection == 3 then
	pinselector:blit(189,195)
end
 
if controls.press("up") then
	currentselection = currentselection - 1
	if currentselection <= 0 then currentselection = 3 end
end
 
if controls.press("down") then
	currentselection = currentselection + 1
	if currentselection >=4 then currentselection = 1 end
end
 
--Si quieres quita esa linea, es para actualizar rápidamente el código
	if controls.select() then aaaa() end 
 
screen.flip()
end

Imagen de Nevado0

Claro que no se te mueve, te

Claro que no se te mueve, te falta el controls.read(), aparte porque le das al interprete tantos datos? si con poner que al apretar arriba le sume uno al current tienes suficiente xD. No hace falta que pongas eso ponlo asi:
if controls.press("up") then
   currentslection = currentselection + 1
   if currentselection == 3 then currentselection = 1 end
end
 
-- y lo mismo con down.
-- Luego te recomendaria que buscaras una y para las imagenes que puedan seguir una operacion matematica para poder acortar el code con un for por ejemplo:
 
for i = 1,3 do
if currentselection == i then pinselector:blit(186,90*i-20) end
end



 Click en la imagen si kieres un avatar o una firma tan espectacular como los mios =P.

Psp 2001 Gen d3 + Memory stick 4 gb

Ps3 Fat 60GB + CFW Rebug 3.55 + Disco duro externo 250 GB+ Multiman

Imagen de Comandillos

Vaya

Es que hoy justamente me he puesto con LuaDEV, y al principio incluso creia que era "pad = Controls.read()" y todo... y ahora ya me he aclarado bastante, gracias :D


Imagen de Nevado0

Cualquier cosa mandame un mp

Cualquier cosa mandame un mp y encantado te ayudo =D.

Imagen de Dioni0396

Normal

si te cargas la ram, nos ves que en el while tienes puesto que a cada pasada cargue una imagen?

Por eso te quedas sin memoria en tan poco tiempo, debes poner la carga de imagenes fuera del bucle.

Imagen de Comandillos

Vale

Voy a "optimizar" el código y a ver si no me da problemas.

EDITO: ¿Sabes que a veces se me va la cabeza?, pensaba que con la carga te referías a blit..., estoy fatal, cuando he visto los dos loads metidos en el bucle..... jajja que fallo.

Gracias :D


Imagen de Dioni0396

ademas de que tienes otro fallo en el blit

los argumentos no son: imagen,x,y es al reves x,y,imagen.

Es decir que te dara error en el image.blit

Saludos.

Imagen de Comandillos

No

Pues no me da fallos, es que en LuaDEV es "image.blit
(imagen img, number x, number y)"

Pero aún sigue sin moverse el menu, no se porque.

EDITO:

Toma el código corregido, a ver si hay algun fallo...

currentselection = 1
pinselector = image.load("resources/pin.png")
mainmenu = image.load("resources/mainmenu.png")
 
while true do
screen.clear()
image.blit(mainmenu,0,0)
 
if currentselection == 1 then
image.blit(pinselector,189,116)
end
 
if currentselection == 2 then
image.blit(pinselector,189,155)
end
 
if currentselection == 3 then
image.blit(pinselector,189,195)
end
 
if controls.up() then
 if currentselection == 2 then
 currentselection = 1
 end
 if currentselection == 3 then
 currentselection = 2
 end
end
 
if controls.down() then
 if currentselection == 1 then
 currentselection = 2
 end
 if currentselection == 2 then
 currentselection = 3
 end
end
 
screen.flip()
screen.waitvblankstart()
end


Imagen de Dioni0396

Mira te lo voy a dar automatizado

currentselection = 1
pinselector = image.load("resources/pin.png")
mainmenu = image.load("resources/mainmenu.png")
 Te faltaba el controls.read()
while true do
controls.read()
screen.clear()
image.blit(mainmenu,0,0)
 
if currentselection == 1 then
image.blit(pinselector,189,116)
end
 
if currentselection == 2 then
image.blit(pinselector,189,155)
end
 
if currentselection == 3 then
image.blit(pinselector,189,195)
end
 
if controls.up() then
curretnselection = currentselection - 1
end
 
if controls.press("down") then
curretnselection = currentselection + 1
end
 
screen.flip()
end

Imagen de Nevado0

Wtf, se le seguira sin

Wtf, se le seguira sin mover...

Imagen de NauTiluS1

Por que no lo hacen con un

Por que no lo hacen con un bucle for y se dejan de romPerse la cabeza xD

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.