The Basics Part 5

From PSP Developer wiki
Revision as of 19:15, 2 March 2019 by GregoryRasputin (talk | contribs) (Created page with "Lesson 02 The Basics Lua Programming Techniques This is part five of Whitehawk's second introductory Lua tutorial. If you haven't already read the first part, the second part,...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Lesson 02 The Basics Lua Programming Techniques This is part five of Whitehawk's second introductory Lua tutorial. If you haven't already read the first part, the second part, the third part, and the fourth part, go back now.

So are we done? Nope. We're not. But don't fret, the bulk of the work is done, we only have five lines to go. We need to put in the code to restart the application when you press [START] and to take a screenshot when you press [SELECT].

We'll do the screenshot code first:

         if pad:select() then screen:save("screenshot.tga") end

Notice that we did this whole "if" statement on one line. It's perfectly legal. The function "screen:save()" just takes a screenshot to the file that we specify inside the parenthesis. In this case, we are saving our screenshot to "screenshot.tga."

Now we'll just make the code to restart when the user presses [START]:

         if pad:start() then
                   break
         end

The break statement will exit us out of the infinite while loop (the game loop), effectively restarting the script.

And finally, we must insert a line to terminate our while loop (so the Player knows it's time to go back to the beginning of the loop and start over). end Now we are done! Remember that hug you gave yourself before? Well, don't even think about doing it again, because it creeped me out. But you can go test your script on your PSP! Congratulations. You are now a developer.

Special thanks to: Shine, indianajonesilm, and PSPUpdates.

Be sure to add the feed to your RSS Aggregator (or Google Homepage, or Firefox Live Bookmark) to stay updated with the latest tutorials.

If you have enjoyed this tutorial and have a spare buck or two, please consider donating to the author. Or, if you have a website, link to this tutorial series (helping spread the word means more homebrew for all!).

If there's a calling, I will consider making more tutorials. Please contact me with your feedback on the tutorials and on what you'd like to see in the next lessons. My e-mail is whitehawk45@gmailcom.