Editing Hello World Part 1

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 4: Line 4:
This tutorial series focusses on writing programs for the PlayStation Portable (PSP) in Lua. Lua is a general purpose scripting language allowing for rapid development and easy distribution. It is a cross-platform language (meaning that you can run your scripts with minor modifications on PC, PSP, Linux, and any other system that has a Lua interpreter). It is a bit different than C in that it is a scripting language. This means that you will not compile your program as you would if you were writing a C Program. You, rather, just have a .lua file which really is just a text file with a different extension. All of the processing goes on through the Lua interpreter (which has been ported to the PSP by Shine).
This tutorial series focusses on writing programs for the PlayStation Portable (PSP) in Lua. Lua is a general purpose scripting language allowing for rapid development and easy distribution. It is a cross-platform language (meaning that you can run your scripts with minor modifications on PC, PSP, Linux, and any other system that has a Lua interpreter). It is a bit different than C in that it is a scripting language. This means that you will not compile your program as you would if you were writing a C Program. You, rather, just have a .lua file which really is just a text file with a different extension. All of the processing goes on through the Lua interpreter (which has been ported to the PSP by Shine).
<br>
<br>
If, at any time in this tutorial series, you need help please head over to our forums and post a question. We are always happy to help a fellow programmer.
If, at any time in this tutorial series, you need help please head over to our forums and post a question. We are always happy to help a fellow programmer.
<br>
<br>
So, before you start, you will need to download the latest version of the Lua Player from the official website here (unless you are using the GTA EBOOT Loader, then you will need to get Lua Player 0.14 from the Lua Player archive).
So, before you start, you will need to download the latest version of the Lua Player from the official website here (unless you are using the GTA EBOOT Loader, then you will need to get Lua Player 0.14 from the Lua Player archive).
<br>
<br>
If you have a 1.50 Firmware PSP, you will need to take the two folders, 'luaplayer' and 'luaplayer%' in the PSP/GAME/ directory on your PSP's memory stick. With newer firmwares, you will need to use Fanjita's Eboot Loader. If you have a version 1.00 PSP, I trust you know how to install homebrew (if not, do a quick Google search and I'm sure you'll find what you're after).
If you have a 1.50 Firmware PSP, you will need to take the two folders, 'luaplayer' and 'luaplayer%' in the PSP/GAME/ directory on your PSP's memory stick. With newer firmwares, you will need to use Fanjita's Eboot Loader. If you have a version 1.00 PSP, I trust you know how to install homebrew (if not, do a quick Google search and I'm sure you'll find what you're after).
<br>
<br>
Now create a blank text file (you can do this in your favorite text editor, whether it be Notepad, WordPad, or whatever else tickles your fancy) in the 'luaplayer' folder. Rename it to "script.lua" (from "whatever.txt").
Now create a blank text file (you can do this in your favorite text editor, whether it be Notepad, WordPad, or whatever else tickles your fancy) in the 'luaplayer' folder. Rename it to "script.lua" (from "whatever.txt").
<br>
<br>
You are now all set up, so on to the tutorial!
You are now all set up, so on to the tutorial!
<br>
<br>
This is definitely a very easy program to create. It is only about 4 lines of code. They are very easy to understand. And no compiling is necessary!
This is definitely a very easy program to create. It is only about 4 lines of code. They are very easy to understand. And no compiling is necessary!
<br>
<br>
This program will just print one line of text that says "Hello World." It is the classic introductory program ("Hello World" programs have been written in perhaps every language in existence). The point is not to create a functional program per se, but rather to introduce you to the syntax of the language.
This program will just print one line of text that says "Hello World." It is the classic introductory program ("Hello World" programs have been written in perhaps every language in existence). The point is not to create a functional program per se, but rather to introduce you to the syntax of the language.
<br>
<br>
So, start your code in "script.lua" out with this line:
So, start your code in "script.lua" out with this line:
blue = Color.new(0, 0, 255)
blue = Color.new(0, 0, 255)
What this does is define a colour. The particular color that we have defined, this time, is blue. It creates a variable and stores the information that will tell the Lua Player what "blue" is. And the Lua Player will then interpret this line and allocate the appropriate system resources on the PSP to store it. But, the beauty of Lua is that we don't have to worry about that. The Player will handle all of the details.
What this does is define a colour. The particular color that we have defined, this time, is blue. It creates a variable and stores the information that will tell the Lua Player what "blue" is. And the Lua Player will then interpret this line and allocate the appropriate system resources on the PSP to store it. But, the beauty of Lua is that we don't have to worry about that. The Player will handle all of the details.
<br>
<br>
Let's examine the line of code more closely to see exactly how it is instantiating (which is just a long word for creating) this color object.
Let's examine the line of code more closely to see exactly how it is instantiating (which is just a long word for creating) this color object.
<br>
<br>
"blue = Color.new," is telling the Lua interpreter "Hey, doofus, make a new color and call it blue." So now when we use the abstract identifier "blue," we are referencing the tangible information coding for the color blue in the PSP's memory.
"blue = Color.new," is telling the Lua interpreter "Hey, doofus, make a new color and call it blue." So now when we use the abstract identifier "blue," we are referencing the tangible information coding for the color blue in the PSP's memory.
<br>
<br>
"(0, 0, 255)" is the most important part of the code for us. This is how we actually tell the player what color we want our variable, "blue," to be. When we typed blue = Color.new, we could have typed, 'red', 'yellow', 'green' or even 'Cublecursome.' But if we had used this same "(0, 0, 255)," it would have still come out as blue. The interpreter has no idea what "blue" means, all it knows is what we tell it. We simply used "blue" as the identifier for simplicity. Obviously, if we had named it "white," and it was actually storing the information for the color blue, it would have gotten confusing down the road in our program (and much more so if our program was going to be more complex).
"(0, 0, 255)" is the most important part of the code for us. This is how we actually tell the player what color we want our variable, "blue," to be. When we typed blue = Color.new, we could have typed, 'red', 'yellow', 'green' or even 'Cublecursome.' But if we had used this same "(0, 0, 255)," it would have still come out as blue. The interpreter has no idea what "blue" means, all it knows is what we tell it. We simply used "blue" as the identifier for simplicity. Obviously, if we had named it "white," and it was actually storing the information for the color blue, it would have gotten confusing down the road in our program (and much more so if our program was going to be more complex).
<br>
<br>
So the three numbers, in this case "0" "0" and "255", tell the PSP what the color displayed will be. These numbers are part of the RGB color mode. The first number stands for red, the second for green, and the third for blue.
So the three numbers, in this case "0" "0" and "255", tell the PSP what the color displayed will be. These numbers are part of the RGB color mode. The first number stands for red, the second for green, and the third for blue.
<br>
<br>
 
Continue this tutorial with part two.
Continue this tutorial with [[Hello World Part 2|part two]].
Please note that all contributions to PSP Developer wiki are considered to be released under the GNU Free Documentation License 1.2 (see PSP Developer wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following hCaptcha:

Cancel Editing help (opens in new window)