Editing The Basics Part 1
Jump to navigation
Jump to search
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 2: | Line 2: | ||
The Basics<br> | The Basics<br> | ||
Lua Programming Techniques<br> | Lua Programming Techniques<br> | ||
After having read | After having read Lua Lesson 01, you should have a basic concept of how to run Lua programs and how to setup a simple script. You are now ready to move on to some more advanced concepts that will prepare you to create fully featured applications and games.<br> | ||
Line 11: | Line 11: | ||
If you haven't read the first tutorial, I highly recommend it. If you decide to go on anyway, without reading it, and become baffled, and in the process having your mind transformed in to a gooey puddle of radioactive mush, don't come complaining to me. (Aside: actually it's not really that difficult, I just thought I'd add a little drama to the tutorial).<br> | |||
Before you start, you will need to download a zip file containing the images used in this tutorial. (The preceding phrase was a link, for those of you who skimmed right over it).<br> | |||
Before you start, you will need to download a | |||
Line 26: | Line 24: | ||
Now the USB port on the PSP will be activated when you run your script.<br> | Now the USB port on the PSP will be activated when you run your script.<br> | ||
Line 35: | Line 32: | ||
gray = Color.new(153, 153, 153) | gray = Color.new(153, 153, 153) | ||
black = Color.new(0 , 0 , 0) | black = Color.new(0 , 0 , 0) | ||
If you have forgotten how these lines work, go back to | If you have forgotten how these lines work, go back to the last lesson and refresh your memory.<br> | ||
Now we want to display a loading screen. Our loading screen will say "Loading: 0%" then "Loading: 1%" and so on and so forth until "Loading: 100%." To start it off, we need to print "Loading: 0%" to the screen. You should remember the screen:print function from Lua Lesson 01. But in case you don't, here's the code that you will need to insert: | |||
Now we want to display a loading screen. Our loading screen will say "Loading: 0%" then "Loading: 1%" and so on and so forth until "Loading: 100%." To start it off, we need to print "Loading: 0%" to the screen. You should remember the screen:print function from | |||
screen:print(194, 136, "Loading: 0%", pink) | screen:print(194, 136, "Loading: 0%", pink) | ||
screen.flip() | screen.flip() | ||
Line 45: | Line 41: | ||
Next, we need to load our images (which, if you missed it before, can be downloaded here). Extract the zip file into the folder where your script file is on your PSP. Then add this line. It will load the background. | |||
Next, we need to load our images (which, if you missed it before, can be downloaded | |||
background = Image.load("images/background.jpg") | background = Image.load("images/background.jpg") | ||
Before we move on, let's get a firm understanding of what this line of code actually does. The first thing we see is a variable name, background. We then set that variable equal to the result of the function on the right ("Image.load()") using the assignment operator, or equal sign. The actual loading of the image comes through the "Image.load()" function which is built into Lua. It takes one parameter, the path to the image file we want to load. Our image is in the "images" folder, and the picture we want to load is "background.jpg." Remember, you must always use the file's extension when loading it (in this case, it was a jpeg file, so we used the extension ".jpg").<nowiki>Insert non-formatted text here</nowiki> | Before we move on, let's get a firm understanding of what this line of code actually does. The first thing we see is a variable name, background. We then set that variable equal to the result of the function on the right ("Image.load()") using the assignment operator, or equal sign. The actual loading of the image comes through the "Image.load()" function which is built into Lua. It takes one parameter, the path to the image file we want to load. Our image is in the "images" folder, and the picture we want to load is "background.jpg." Remember, you must always use the file's extension when loading it (in this case, it was a jpeg file, so we used the extension ".jpg").<nowiki>Insert non-formatted text here</nowiki> | ||
When you understand, move on to | When you understand, move on to part two of this tutorial to continue your program. |