Lesson 1: Hello World
Most people who are not brand new to coding know that Hello World is a program that displays the text "hello world" to the screen. I will show you how to do this. This will teach you how to load Collors, print text to the screen and perform a loop! So lets begin!
First of all we always want to add the colors first
to do this we type...
red = Color.new(255,0,0)
first is the name of the color
then an equal sign
then Color.new which means add a new color to are current colors
the numbers mean how much of red, green, and blue to add to the current color we are making
so green is (0,255,0) red is (255,0,0) blue is (0,0,255)
so far that is pretty easy so lets move on and make are loop.
To start a loop we always type
while true do
which is probably self explanatorynext in are loop we type
screen:print(100,200,"Hello, World!",red)
this means print to the screen Hello, World! at position 100 x, 200 y, with the color red.If you were to run it right now it might play but only stay on your screen for a second or it might return a error to you. You might say "Why is this?" or you might say"WTF!!!!"either way it will do this because are loop is not finished!The next thing you need to add is
screen.flip()
screen.waitVblankStart()
end
this is pretty simplefirst screen.flip() means bring the offscreen buffering on to the screen. This is necessary to any lua document.then screen.waitVblank() means wait however many frames are in the brackets then restart the loop. We didn't put a number there because we want it to loop instantly. And of course end means end the script.now save your text document as anyname.lua and put it in your lua player on your psp and play it! congrats you made your first lua programto continue click here
First of all we always want to add the colors first
to do this we type...
red = Color.new(255,0,0)
first is the name of the color
then an equal sign
then Color.new which means add a new color to are current colors
the numbers mean how much of red, green, and blue to add to the current color we are making
so green is (0,255,0) red is (255,0,0) blue is (0,0,255)
so far that is pretty easy so lets move on and make are loop.
To start a loop we always type
while true do
which is probably self explanatorynext in are loop we type
screen:print(100,200,"Hello, World!",red)
this means print to the screen Hello, World! at position 100 x, 200 y, with the color red.If you were to run it right now it might play but only stay on your screen for a second or it might return a error to you. You might say "Why is this?" or you might say"WTF!!!!"either way it will do this because are loop is not finished!The next thing you need to add is
screen.flip()
screen.waitVblankStart()
end
this is pretty simplefirst screen.flip() means bring the offscreen buffering on to the screen. This is necessary to any lua document.then screen.waitVblank() means wait however many frames are in the brackets then restart the loop. We didn't put a number there because we want it to loop instantly. And of course end means end the script.now save your text document as anyname.lua and put it in your lua player on your psp and play it! congrats you made your first lua programto continue click here