Tutoriales para LUA

Moderadores: Kravenbcn, largeroliker, fidelcastro, cerealkiller, pspCaracas, dark_sasuke, m0skit0, LnD, ka69, zacky06, driKton

Avatar de Usuario
zacky06
Moderador Global
Moderador Global
Mensajes: 1696
Registrado: 12 Jul 2010, 15:28
PSN ID: zakarias09
Steam ID: Zacky06
Contactar:

Tutoriales para LUA

Mensaje por zacky06 »

Buenas,ahora que la PS3 posee ya el luaplayer,estaría bien que se pusieran tutoriales para ir aprendiendo desde un nivel novato como el típico hola mundo y después ir complicando la cosa si hay interés,he buscado yo por mi cuenta pero claro esta en ingles y hay cosas que necesito saber,como por ejemplo que hace una función y etc,ademas tampoco se si usa las mismas funciones de la psp,ya que me ha dado por probar y toquetear el código que trae de muestra el ejemplo de la noticia y no consigo ver nada en el emulador este.

Por si alguien le pica la curiosidad pongo el código de ejemplo que incluye el luaplayer de PS3 y lo comparo con el hello world que tengo.

Ejemplo de helloworld de ps3
Spoiler:

Código: Seleccionar todo

InitGFX(720,480)
initPads(7)
setsixaxis(0,1)

textures = { }
table.insert(textures, 1, surface())
textures[1]:LoadIMG("helloworld.bmp")

screenW, screenH = screenRes()
tex1x, tex1y = textures[1]:getRes()

cx = (screenW/2)
cy = (screenH/2)
dx = 7
dy = 5

function translate()
       DrawText((screenH/2), 450, "Hello, World! Directly on screen")
       textures[1]:setRectPos(((screenW-tex1x)/2), ((screenH-tex1y)/2))
   DrawText((tex1x/2), (tex1y/2), "Hello, World! on a surface", textures[1])
end

function ReadKeys()
   local textx = 100
   local texty = 20

   DrawText(textx, texty, string.format("Left JoyX: %i -- Left JoyY: %i", LanalogX(0), LanalogY(0)))

   texty = texty+20
   DrawText(textx, texty, string.format("Right JoyX: %i -- Right JoyY: %i", RanalogX(0), RanalogY(0)))

   texty = texty+20
   DrawText(textx, texty, string.format("Xaxis: %f Yaxis: %f Zaxis: %f Gaxis: %f", Xaxis(0), Yaxis(0), Zaxis(0), Gaxis(0)))

   if up(0) >= 1 then
      texty = texty+20
      DrawText(textx, texty, "Pressed Up")
   end
   if down(0) >= 1 then
      texty = texty+20
      DrawText(textx, texty, "Pressed Down")
   end
   if left(0) >= 1 then
      texty = texty+20
      DrawText(textx, texty, "Pressed Left")
   end
   if right(0) >= 1 then
      texty = texty+20
      DrawText(textx, texty, "Pressed Right")
   end
   if R1(0) >= 1 then
      texty = texty+20
      DrawText(textx, texty, "Pressed R1")
   end
   if R2(0) >= 1 then
      texty = texty+20
      DrawText(textx, texty, "Pressed R2")
   end
   if R3(0) >= 1 then
      texty = texty+20
      DrawText(textx, texty, "Pressed R3")
   end
   if L1(0) >= 1 then
      texty = texty+20
      DrawText(textx, texty, "Pressed L1")
   end
   if L2(0) >= 1 then
      texty = texty+20
      DrawText(textx, texty, "Pressed L2")
   end
   if L3(0) >= 1 then
      texty = texty+20
      DrawText(textx, texty, "Pressed L3")
   end
end

while true do
   beginGFX()
   translate()

    cx = cx+dx
    cy = cy+dy
    if cx<0 or cx>screenW then dx=(dx-(dx*2)) end
    if cy<0 or cy>screenH then dy=(dy-(dy*2)) end

    BlitToScreen(textures[1])
    ReadKeys()
   DrawCircle(cx, cy, (math.sqrt(cx)+math.sqrt(cy)), 255, 255, 255, 1000)
   if cross(0) >= 1 then break end
   if start(0) >= 1 then Screenshot("test.bmp") end
   endGFX()

end


El ejemplo de helloworld de psp
Spoiler:

Código: Seleccionar todo

holamundo = Color.new(0, 255, 255)
 

screen:print(300, 100, "Hola mundo!", holamundo)
 

screen.flip()
 

while true do
  screen.waitVblankStart()
end
Imagen

Mis Consolas:
Ps2 Phat v9 + Modchip Matrix Infinity 1.99 & Ps2 Phat v3
Psp Phat White 1004 5.00M33-6 Psp 2004 Slim Black Piano 6.60 ME 1.3 Psp Go 6.60 LME 1.8
Ps3 Slim 320Gb OFW 4.30 - CFW Rebug 4.73.1 REX Cobra 7.03
Ps3 Slim 500Gb OFW 4.75

Responder